BAEL-3719: Add missing code (#8470)

This commit is contained in:
kwoyke 2020-01-05 04:08:47 +01:00 committed by Grzegorz Piwowarek
parent 18794e11c2
commit 0577e41882
1 changed files with 49 additions and 0 deletions

View File

@ -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();
}
}