Add AllStrategies combined example
This commit is contained in:
parent
d27db567c1
commit
208fcaa915
|
@ -0,0 +1,33 @@
|
|||
package org.baeldung.startup;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
@Scope(value = "prototype")
|
||||
public class AllStrategiesExampleBean implements InitializingBean {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(AllStrategiesExampleBean.class);
|
||||
|
||||
public AllStrategiesExampleBean() {
|
||||
LOG.info("Constructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
LOG.info("InitializingBean");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
LOG.info("PostConstruct");
|
||||
}
|
||||
|
||||
public void init() {
|
||||
LOG.info("init-method");
|
||||
}
|
||||
}
|
|
@ -2,14 +2,10 @@ package org.baeldung.startup;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Component
|
||||
@Scope(value = "prototype")
|
||||
public class InitMethodExampleBean {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(InitMethodExampleBean.class);
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
|
||||
<bean id="initMethodExampleBean"
|
||||
class="org.baeldung.startup.InitMethodExampleBean"
|
||||
scope="prototype"
|
||||
init-method="init">
|
||||
</bean>
|
||||
|
||||
<bean id="allStrategiesExampleBean"
|
||||
class="org.baeldung.startup.AllStrategiesExampleBean"
|
||||
init-method="init">
|
||||
</bean>
|
||||
</beans>
|
|
@ -18,4 +18,9 @@ public class SpringStartupXMLConfigTest {
|
|||
public void whenPostConstruct_shouldLogEnv() throws Exception {
|
||||
ctx.getBean(InitMethodExampleBean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenAllStrategies_shouldLogOrder() throws Exception {
|
||||
ctx.getBean(AllStrategiesExampleBean.class);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue