List of usage examples for org.springframework.context.support GenericApplicationContext refresh
@Override public void refresh() throws BeansException, IllegalStateException
From source file:com.taobao.itest.spring.context.GenericXmlContextLoader.java
public ApplicationContext loadContext(String... locations) throws Exception { GenericApplicationContext context = new GenericApplicationContext(); new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations); context.refresh(); context.registerShutdownHook();//from w ww.j a v a 2 s . c o m return context; }
From source file:org.twinkql.template.AbstractTwinkqlTemplateFactory.java
/** * Gets the twinkql template./*w w w. j a v a 2s. c o m*/ * * @return the twinkql template * @throws Exception the exception */ public TwinkqlTemplate getTwinkqlTemplate() { DefaultListableBeanFactory parentBeanFactory = new DefaultListableBeanFactory(); parentBeanFactory.registerSingleton("twinkqlContext", this.getTwinkqlContext()); GenericApplicationContext parentContext = new GenericApplicationContext(parentBeanFactory); parentContext.refresh(); AnnotationConfigApplicationContext annotationConfigApplicationContext = this .decorateContext(new AnnotationConfigApplicationContext()); annotationConfigApplicationContext.setParent(parentContext); annotationConfigApplicationContext.scan(PACKAGE_SCAN); annotationConfigApplicationContext.refresh(); TwinkqlTemplate template = annotationConfigApplicationContext.getBean(TwinkqlTemplate.class); return template; }
From source file:nz.co.senanque.madura.bundle.BundleRootTest.java
@Test @Ignore // fails because of parent bean which is undefined. public void testGetApplicationContext() { GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("/bundle-spring.xml")); ctx.refresh(); Object bundleName = ctx.getBean("bundleName"); bundleName.toString();/* w w w . j a v a 2 s .c o m*/ }
From source file:com.himanshu.spring.context.loader.diffconfigpercontext.ServiceFactoryDiffConfigPerContext.java
private ApplicationContext getParentContext() { GenericApplicationContext parentContext = new GenericApplicationContext(); parentContext.getBeanFactory().registerSingleton("dummyBean", this); parentContext.getBeanFactory().registerSingleton("mainContext", context); parentContext.refresh(); return parentContext; }
From source file:ch.nydi.spring.context.support.TestGenericXmlContextLoader.java
/** * {@inheritDoc}//from w ww .j a v a 2 s .c om */ @Override public final ConfigurableApplicationContext loadContext(final String... locations) throws Exception { final DefaultListableBeanFactory beanFactory = new PrimaryResolverListableBeanFactory(); beanFactory.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer()); beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver()); final GenericApplicationContext context = new GenericApplicationContext(beanFactory); createBeanDefinitionReader(context).loadBeanDefinitions(locations); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:org.megam.deccanplato.provider.crm.test.MaluubaAdapterTest.java
@Test public void maluubaTest() { GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("applicationContext.xml")); ctx.refresh(); ProviderRegistry registry = (ProviderRegistry) ctx.getBean("registry"); List<String> busiMethod = new ArrayList<String>(); busiMethod.add("normalize"); //busiMethod.add("interpret"); List<String> busiActivity = new ArrayList<String>(); busiActivity.add("norm"); for (String function : busiMethod) { for (String activity : busiActivity) { CommonTest ctest = new CommonTest(); RequestData reqData;//from ww w . jav a 2 s . co m reqData = ctest.commonTest(function, activity, MALUUBA); testAdapterAccess(reqData); ctest.testBusinessImpl(); } } }
From source file:ch.rasc.wampspring.method.PayloadArgumentResolverTest.java
@SuppressWarnings("resource") @Before// www.j ava 2s .co m public void setup() throws Exception { DefaultListableBeanFactory dlbf = new DefaultListableBeanFactory(); dlbf.registerSingleton("mvcValidator", testValidator()); GenericApplicationContext ctx = new GenericApplicationContext(dlbf); ctx.refresh(); this.resolver = new PayloadArgumentResolver(ctx, new MethodParameterConverter(new ObjectMapper(), new GenericConversionService())); this.payloadMethod = getClass().getDeclaredMethod("handleMessage", String.class, String.class, String.class, String.class, String.class, String.class, String.class, Integer.class); this.paramAnnotated = getMethodParameter(this.payloadMethod, 0); this.paramAnnotatedNotRequired = getMethodParameter(this.payloadMethod, 1); this.paramAnnotatedRequired = getMethodParameter(this.payloadMethod, 2); this.paramWithSpelExpression = getMethodParameter(this.payloadMethod, 3); this.paramValidated = getMethodParameter(this.payloadMethod, 4); this.paramValidated.initParameterNameDiscovery(new LocalVariableTableParameterNameDiscoverer()); this.paramValidatedNotAnnotated = getMethodParameter(this.payloadMethod, 5); this.paramNotAnnotated = getMethodParameter(this.payloadMethod, 6); }
From source file:org.megam.deccanplato.provider.crm.test.XeroAdapterTest.java
@Test public void xeroTest() { GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); xmlReader.loadBeanDefinitions(new ClassPathResource("applicationContext.xml")); ctx.refresh(); ProviderRegistry registry = (ProviderRegistry) ctx.getBean("registry"); List<String> oauth = new ArrayList<String>(); //oauth.add("invoice"); //oauth.add("account"); //oauth.add("payment"); //oauth.add("contact"); //oauth.add("item"); //oauth.add("user"); //oauth.add("receipt"); oauth.add("employee"); List<String> oauthList = new ArrayList<String>(); //oauthList.add("list"); //oauthList.add("view"); //oauthList.add("create"); oauthList.add("update"); for (String activity : oauth) { for (String function : oauthList) { CommonTest ctest = new CommonTest(); RequestData reqData;//www. j a v a2 s . co m reqData = ctest.commonTest(activity, function, XERO); if (function.equalsIgnoreCase("list") && activity.equalsIgnoreCase("invoice")) { testAdapterAccess(reqData); } ctest.testBusinessImpl(); } } }
From source file:au.com.identityconcepts.shibboleth.test.TestCaseBase.java
/** * Creates a Spring context from the given resources. * /* w ww. j a va2 s. c o m*/ * @param configs context configuration resources * * @return the created context * * @throws ResourceException thrown if there is a problem reading the configuration resources */ protected ApplicationContext createSpringContext(List<Resource> configs) throws ResourceException { GenericApplicationContext gContext = new GenericApplicationContext(); SpringConfigurationUtils.populateRegistry(gContext, configs); gContext.refresh(); return gContext; }
From source file:fi.okm.mpass.shibboleth.profile.metadata.DataSourceMetadataResolverTest.java
@SuppressWarnings("unchecked") protected <Type> Type getBean(String fileName, Class<Type> claz, GenericApplicationContext context, boolean supressValid) { context.setDisplayName("ApplicationContext: " + claz); loadFile(fileName, context, supressValid); context.refresh(); return (Type) ((RelyingPartyMetadataProvider) context.getBean("dataSourceEntity")).getEmbeddedResolver(); }