separate configs
This commit is contained in:
@@ -3,12 +3,9 @@ package com.baeldung.scope;
|
||||
import com.baeldung.scope.prototype.PrototypeBean;
|
||||
import com.baeldung.scope.singletone.SingletonAppContextBean;
|
||||
import com.baeldung.scope.singletone.SingletonBean;
|
||||
import com.baeldung.scope.singletone.SingletonFunctionBean;
|
||||
import com.baeldung.scope.singletone.SingletonObjectFactoryBean;
|
||||
import com.baeldung.scope.singletone.SingletonProviderBean;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
@@ -45,19 +42,4 @@ public class AppConfig {
|
||||
return new SingletonObjectFactoryBean();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, PrototypeBean> beanFactory() {
|
||||
return name -> prototypeBeanWithParam(name);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = "prototype")
|
||||
public PrototypeBean prototypeBeanWithParam(String name) {
|
||||
return new PrototypeBean(name);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SingletonFunctionBean singletonFunctionBean() {
|
||||
return new SingletonFunctionBean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.scope;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import com.baeldung.scope.prototype.PrototypeBean;
|
||||
import com.baeldung.scope.singletone.SingletonFunctionBean;
|
||||
|
||||
@Configuration
|
||||
public class AppConfigFunctionBean {
|
||||
|
||||
@Bean
|
||||
public Function<String, PrototypeBean> beanFactory() {
|
||||
return name -> prototypeBeanWithParam(name);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = "prototype")
|
||||
public PrototypeBean prototypeBeanWithParam(String name) {
|
||||
return new PrototypeBean(name);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SingletonFunctionBean singletonFunctionBean() {
|
||||
return new SingletonFunctionBean();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user