List of usage examples for org.springframework.context.support GenericXmlApplicationContext load
public void load(String... resourceLocations)
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. jav a 2 s . com DestructiveBean bean = (DestructiveBean) ctx.getBean("destructiveBean"); // bean.destroy(); }
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();/* w w w . j ava2 s . c om*/ LoggingBean bean = (LoggingBean) ctx.getBean("loggingBean"); bean.someOperation(); }
From source file:com.home.ln_spring.ch5.jsr330.Jsr330Example.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:jsr330/jsr330.xml"); ctx.refresh();//from w w w . j av a 2 s . com MessageRenderer renderer = ctx.getBean("messageRenderer", MessageRenderer.class); renderer.render(); }
From source file:com.home.ln_spring.ch8.sample.JdbcContactSfDaoSample.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:ch8/app-context-sf.xml"); ctx.refresh();//from w w w .j av a2 s. co m ContactSfDao contactSfDao = ctx.getBean("contactSfDao", ContactSfDao.class); System.out.println(contactSfDao.getFirstNameById(1)); }
From source file:com.home.ln_spring.ch5.env.PlaceHolderSample.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:env/env.xml"); ctx.refresh();/*from w w w .j av a 2 s . c o m*/ AppProperty ap = ctx.getBean("appProperty", AppProperty.class); System.out.println("application.home: " + ap.getApplicationHome()); System.out.println("user.home: " + ap.getUserHome()); }
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 a va2s . c o m*/ MessageDigester digester = (MessageDigester) context.getBean("digester"); digester.digest("Hello World!"); }
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 ww .j a va 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.mycompany.mavenproject3.xml.ConstructorConfusion.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:META-INF/spring/app-context-xml.xml"); ctx.refresh();//ww w. ja va2 s . c om ConstructorConfusion cc = (ConstructorConfusion) ctx.getBean("constructorConfusion"); System.out.println(cc); }
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();//from w w w . ja v a2 s . c o 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.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 ww . j a va2s . c o m*/ InjectRef ir = (InjectRef) context.getBean("injectRef"); System.out.println(ir); }