List of usage examples for org.springframework.context.support GenericXmlApplicationContext setParent
@Override public void setParent(@Nullable ApplicationContext parent)
From source file:com.home.ln_spring.ch4.HierarchicalAppContextUsage.java
public static void main(String args[]) { GenericXmlApplicationContext parent = new GenericXmlApplicationContext(); parent.load("classpath:parent.xml"); parent.refresh();// ww w .jav a 2 s . c o m GenericXmlApplicationContext child = new GenericXmlApplicationContext(); child.load("classpath:app-context-xml.xml"); child.setParent(parent); child.refresh(); SimpleTarget target1 = (SimpleTarget) child.getBean("target1"); SimpleTarget target2 = (SimpleTarget) child.getBean("target2"); SimpleTarget target3 = (SimpleTarget) child.getBean("target3"); System.out.println(target1.getVal()); System.out.println(target2.getVal()); System.out.println(target3.getVal()); }
From source file:com.mycompany.springtest02.HierarchicalAppContextUsage.java
public static void main(String[] args) { GenericXmlApplicationContext parent = new GenericXmlApplicationContext(); parent.load("classpath:META-INF/spring/parent.xml"); parent.refresh();//w w w.j a v a 2 s.co m GenericXmlApplicationContext child = new GenericXmlApplicationContext(); child.load("classpath:META-INF/spring/app-context-xml.xml"); child.setParent(parent); child.refresh(); SimpleTarget target1 = (SimpleTarget) child.getBean("target1"); SimpleTarget target2 = (SimpleTarget) child.getBean("target2"); SimpleTarget target3 = (SimpleTarget) child.getBean("target3"); System.out.println(target1.getVal()); System.out.println(target2.getVal()); System.out.println(target3.getVal()); }
From source file:com.amazonaws.services.simpleworkflow.flow.examples.deployment.DeploymentWorkflowImpl.java
@Override public Promise<String> deploy(String springTemplate) { Resource templateResource = new ByteArrayResource(springTemplate.getBytes()); GenericXmlApplicationContext appContext = new GenericXmlApplicationContext(); appContext.setParent(applicationContext); appContext.load(templateResource);//from w ww. j a v a 2 s .c o m appContext.refresh(); ApplicationStack applicationStack = appContext.getBean("applicationStack", ApplicationStack.class); applicationStack.deploy(); return applicationStack.getUrl(); }
From source file:org.springframework.integration.core.MessageIdGenerationTests.java
@Test public void testCustomIdGenerationWithParentChildIndependentCreation() throws Exception { ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext( "MessageIdGenerationTests-context-withGenerator.xml", this.getClass()); GenericXmlApplicationContext child = new GenericXmlApplicationContext(); child.load("classpath:/org/springframework/integration/core/MessageIdGenerationTests-context.xml"); child.setParent(parent); child.refresh();//from w ww .j a va 2 s .c o m IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class); MessageChannel inputChannel = child.getBean("input", MessageChannel.class); inputChannel.send(new GenericMessage<Integer>(0)); verify(idGenerator, atLeastOnce()).generateId(); child.close(); parent.close(); this.assertDestroy(); }
From source file:org.springframework.integration.core.MessageIdGenerationTests.java
@Test public void testCustomIdGenerationWithParentChildIndependentCreationChildrenRegistrarsOneAtTheTime() throws Exception { ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext( "MessageIdGenerationTests-context.xml", this.getClass()); GenericXmlApplicationContext childA = new GenericXmlApplicationContext(); childA.load(// w w w . jav a 2 s.c o m "classpath:/org/springframework/integration/core/MessageIdGenerationTests-context-withGenerator.xml"); childA.setParent(parent); childA.refresh(); childA.close(); GenericXmlApplicationContext childB = new GenericXmlApplicationContext(); childB.load( "classpath:/org/springframework/integration/core/MessageIdGenerationTests-context-withGenerator.xml"); childB.setParent(parent); childB.refresh(); parent.close(); childB.close(); this.assertDestroy(); }