List of usage examples for org.springframework.context.support GenericXmlApplicationContext getBean
@Override public Object getBean(String name) throws BeansException
From source file:com.tcp.client.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments//from w w w . jav a2s .c o m * @throws InterruptedException * @throws IOException */ public static void main(final String... args) throws InterruptedException, IOException { final GenericXmlApplicationContext context = Main.setupContext(); final SimpleGateway gateway = context.getBean(SimpleGateway.class); new EchoService().execute(gateway); }
From source file:com.home.ln_spring.ch4.mi.lookupDemo.java
public static void main(String args[]) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:lookup.xml"); DemoBean abstractDemoBean = (DemoBean) context.getBean("abstractLookupBean"); DemoBean standardDemoBean = (DemoBean) context.getBean("standardLookupBean"); displayInfo(standardDemoBean);//ww w .j a va2 s. c o m displayInfo(abstractDemoBean); }
From source file:com.home.ln_spring.ch4.NonSingleton.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:app-context-xml.xml"); ctx.refresh();//from w w w . j ava 2 s .co m String str1 = (String) ctx.getBean("nonSingleton"); String str2 = (String) ctx.getBean("nonSingleton"); System.out.println("Identity Equal?: " + (str1 == str2)); System.out.println("Value Equal:? " + str1.equals(str2)); System.out.println(str1); System.out.println(str2); }
From source file:com.home.ln_spring.ch5.interaction.LoggingBeanExample.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:interaction/logging.xml"); ctx.refresh();/*from w ww . j a va2s . c om*/ LoggingBean bean = (LoggingBean) ctx.getBean("loggingBean"); bean.someOperation(); }
From source file:com.home.ln_spring.ch5.interaction.ShutdownHookBeanExample.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:interaction/shutdownHook.xml"); ctx.refresh();//from ww w .ja va 2s .c o m DestructiveBean bean = (DestructiveBean) ctx.getBean("destructiveBean"); // bean.destroy(); }
From source file:com.home.ln_spring.ch4.xml.InjectRef.java
public static void main(String args[]) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:app-context-xml.xml"); context.refresh();/*from w w w .j av a 2 s. co m*/ InjectRef ir = (InjectRef) context.getBean("injectRef"); System.out.println(ir); }
From source file:com.home.ln_spring.ch4.inheritance.SimpleBean.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:app-context-xml.xml"); ctx.refresh();//w w w . j a va 2 s. c o m SimpleBean parent = (SimpleBean) ctx.getBean("inheritParent"); SimpleBean child = (SimpleBean) ctx.getBean("inheritChild"); System.out.println("Parent: " + parent + "\n"); System.out.println("Child: " + child + "\n"); }
From source file:com.home.ln_spring.ch4.xml.BeanNameAliasing.java
public static void main(String args[]) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:app-context-xml.xml"); context.refresh();/* w ww . j av a 2 s .c o m*/ String str1 = (String) context.getBean("name1"); String str2 = (String) context.getBean("name2"); String str3 = (String) context.getBean("name3"); String str4 = (String) context.getBean("name4"); String str5 = (String) context.getBean("name5"); String[] alias = (String[]) context.getAliases("name1"); System.out.println(str1 == str2); System.out.println(str2 == str3); System.out.println(str3 == str4); System.out.println(str4 == str5); System.out.println(str1 == str5); System.out.println(Arrays.asList(alias)); }
From source file:org.resthub.rpc.example.EchoClient.java
public static void main(String[] args) throws Exception { // CachingConnectionFactory connectionFactory = new CachingConnectionFactory("localhost", 5672); // connectionFactory.setUsername("guest"); // connectionFactory.setPassword("guest"); // /* w w w . ja v a2s . com*/ // AMQPProxyFactory factory = new AMQPProxyFactory(); // factory.setConnectionFactory(connectionFactory); // factory.setReadTimeout(3000); // EchoService service = factory.create(EchoService.class); // // System.out.println(service.echo("Hello AMQP!")); // connectionFactory.destroy(); GenericXmlApplicationContext context = new GenericXmlApplicationContext( "classpath:/applicationContext-client.xml"); EchoService service = (EchoService) context.getBean("echoService"); System.out.println(service.echo("Hello AMQP!")); context.close(); }
From source file:com.home.ln_spring.ch5.factory.MessageDigestrExample.java
public static void main(String[] args) { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load("classpath:factory/factory.xml"); context.refresh();/*from w ww . j av a2 s . com*/ MessageDigester digester = (MessageDigester) context.getBean("digester"); digester.digest("Hello World!"); }