public static ApplicationContext getApplicationContext(String selector, String factoryKey) { if (selector == null) selector = "configurations/default-spring-context.xml"; if (factoryKey == null) factoryKey = "spring-context.xml"; BeanFactoryReference reference = ContextSingletonBeanFactoryLocator.getInstance( System.getProperty("spring.configuration", selector)) .useBeanFactory(factoryKey); BeanFactory beanFactory = reference.getFactory(); return (ApplicationContext) beanFactory; }
public static Object getBean(String selector, String factoryKey, String name, Class type) { if (selector == null) selector = "configurations/default-spring-context.xml"; if (factoryKey == null) factoryKey = "spring-context.xml"; BeanFactoryReference reference = ContextSingletonBeanFactoryLocator.getInstance( System.getProperty("spring.configuration", selector)) .useBeanFactory(factoryKey); BeanFactory beanFactory = reference.getFactory(); return beanFactory.getBean(name, type); }