BAEL-3719: Add missing code (#8470)
This commit is contained in:
parent
18794e11c2
commit
0577e41882
|
@ -0,0 +1,49 @@
|
||||||
|
package com.baeldung.scopes;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.annotation.ScopedProxyMode;
|
||||||
|
import org.springframework.web.context.annotation.ApplicationScope;
|
||||||
|
import org.springframework.web.context.annotation.RequestScope;
|
||||||
|
import org.springframework.web.context.annotation.SessionScope;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ScopesConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Scope("singleton")
|
||||||
|
public Person personSingleton() {
|
||||||
|
return new Person();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Scope("prototype")
|
||||||
|
public Person personPrototype() {
|
||||||
|
return new Person();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@RequestScope
|
||||||
|
public HelloMessageGenerator requestScopedBean() {
|
||||||
|
return new HelloMessageGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SessionScope
|
||||||
|
public HelloMessageGenerator sessionScopedBean() {
|
||||||
|
return new HelloMessageGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ApplicationScope
|
||||||
|
public HelloMessageGenerator applicationScopedBean() {
|
||||||
|
return new HelloMessageGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Scope(scopeName = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||||
|
public HelloMessageGenerator websocketScopedBean() {
|
||||||
|
return new HelloMessageGenerator();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue