List of usage examples for org.springframework.context.support GenericXmlApplicationContext refresh
@Override public void refresh() throws BeansException, IllegalStateException
From source file:com.home.ln_spring.ch5.env.EnvironmentSample.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.refresh(); ConfigurableEnvironment env = ctx.getEnvironment(); MutablePropertySources propertySources = env.getPropertySources(); Map appMap = new HashMap(); appMap.put("user.home", "/home/vitaliy/NetBeansProjects/Ln_Spring"); propertySources.addFirst(new MapPropertySource("SPRING3_MAP", appMap)); System.out.println("user.home: " + System.getProperty("user.home")); System.out.println("JAVA_HOME: " + System.getProperty("JAVA_HOME")); System.out.println("user.home: " + env.getProperty("user.home")); System.out.println("JAVA_HOME: " + env.getProperty("JAVA_HOME")); }
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(); 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.jsr330.Jsr330Example.java
public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:jsr330/jsr330.xml"); ctx.refresh(); MessageRenderer renderer = ctx.getBean("messageRenderer", MessageRenderer.class); renderer.render();/* w ww . ja va 2 s . c o m*/ }
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(); LoggingBean bean = (LoggingBean) ctx.getBean("loggingBean"); bean.someOperation();//from w w w . j ava 2 s.com }
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(); ContactSfDao contactSfDao = ctx.getBean("contactSfDao", ContactSfDao.class); System.out.println(contactSfDao.getFirstNameById(1)); }
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(); DestructiveBean bean = (DestructiveBean) ctx.getBean("destructiveBean"); // bean.destroy(); }
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(); 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);//from w w w. j a va2 s .c o m System.out.println(str2); }
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(); MessageDigester digester = (MessageDigester) context.getBean("digester"); digester.digest("Hello World!"); }
From source file:com.home.ln_spring.ch4.mi.MethodReplacementExample.java
public static void main(String args[]) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:replacement.xml"); ctx.refresh(); ReplacementTarget replacementTarget = (ReplacementTarget) ctx.getBean("replacementTarget"); ReplacementTarget standardTarget = (ReplacementTarget) ctx.getBean("standardTarget"); displayInfo(replacementTarget);/*from www .ja va 2 s . co m*/ displayInfo(standardTarget); }
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(); GenericXmlApplicationContext child = new GenericXmlApplicationContext(); child.load("classpath:app-context-xml.xml"); child.setParent(parent);//from ww w .j ava 2s. c om 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()); }