org.springframework.web.context.annotation.RequestScope Java Examples

The following examples show how to use org.springframework.web.context.annotation.RequestScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Oauth2ClientApplication.java    From training with Apache License 2.0 5 votes vote down vote up
@Bean
@RequestScope
OAuth2AuthorizedClient authorizedClient(
		OAuth2AuthorizedClientService authorizedClientService,
		OAuth2AuthenticationToken oauthToken) {
	return authorizedClientService.loadAuthorizedClient(
			oauthToken.getAuthorizedClientRegistrationId(),
			oauthToken.getName());
}
 
Example #2
Source File: Oauth2ClientApplication.java    From training with Apache License 2.0 5 votes vote down vote up
@Bean
@RequestScope
RestTemplate buildAuthenticatedRestTemplate(OAuth2AuthorizedClient authorizedClient) {
	return new RestTemplateBuilder()
			.interceptors((ClientHttpRequestInterceptor) (httpRequest, bytes, clientHttpRequestExecution) -> {
				httpRequest.getHeaders().add("Authorization", "Bearer " + authorizedClient.getAccessToken().getTokenValue());
				return clientHttpRequestExecution.execute(httpRequest, bytes);
			})
			.build();
}
 
Example #3
Source File: SpringBeanFactory.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
@Bean(name = "serverTiming")
@RequestScope
protected ServerTiming createServerTiming() {
    return (ServerTiming) Proxy.newProxyInstance(SpringBeanFactory.class.getClassLoader(), new Class[]{ServerTiming.class}, new InvocationHandler() {
        @Override
        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
            return method.invoke(ServerTimingFilter.getCurrentTiming(), args);
        }
    });
}
 
Example #4
Source File: WebSecurityConfig.java    From XS2A-Sandbox with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
public Principal getPrincipal() {
    return auth().orElse(null);
}
 
Example #5
Source File: WebSecurityConfig.java    From XS2A-Sandbox with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
public ObaMiddlewareAuthentication getMiddlewareAuthentication() {
    return auth().orElse(null);
}
 
Example #6
Source File: WebSecurityConfig.java    From XS2A-Sandbox with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
public AccessTokenTO getAccessToken() {
    return auth().map(this::extractToken).orElse(null);
}
 
Example #7
Source File: RequestContextHolderTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
@RequestScope
public RequestScopedService requestScopedService() {
	return new RequestScopedService();
}
 
Example #8
Source File: RequestContextHolderTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
@RequestScope
public RequestScopedService requestScopedService() {
	return new RequestScopedService();
}
 
Example #9
Source File: Oauth2ClientApplication.java    From training with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
OAuth2AuthenticationToken token() {
	Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
	return OAuth2AuthenticationToken.class.cast(authentication);
}
 
Example #10
Source File: AppConfiguration.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
public AnotherRequestBean requestBean() {
    return new AnotherRequestBean();
}
 
Example #11
Source File: ComponentConfig.java    From spring-webmvc-pac4j with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
public JEEContext getWebContext() {
    return new JEEContext(request, response, getSessionStore());
}
 
Example #12
Source File: ComponentConfig.java    From spring-webmvc-pac4j with Apache License 2.0 4 votes vote down vote up
@Bean
@RequestScope
public ProfileManager getProfileManager() {
    return new ProfileManager<>(getWebContext());
}
 
Example #13
Source File: ScopesConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
@RequestScope
public HelloMessageGenerator requestScopedBean() {
    return new HelloMessageGenerator();
}