List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext refresh
@Override public void refresh() throws BeansException, IllegalStateException
From source file:shiver.me.timbers.spring.security.JwtSpringSecurityAdaptor.java
private void autowireThis(HttpSecurity http) { final ApplicationContext parent = http.getSharedObject(ApplicationContext.class); checkForJwtAnnotation(parent);// w ww . ja va 2 s . com final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.setParent(parent); context.register(PropertySourcesPlaceholderConfigurer.class); context.register(getClass()); context.refresh(); context.getAutowireCapableBeanFactory().autowireBean(this); }
From source file:com.mine.cassandra.sink.CassandraSinkPropertiesTests.java
@Test public void statementExpressionCanBeCustomized() { String queryDsl = "Select(FOO.BAR).From(FOO)"; Expression expression = new SpelExpressionParser().parseExpression(queryDsl); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "statement-expression:" + queryDsl); context.register(Conf.class); context.refresh(); CassandraSinkProperties properties = context.getBean(CassandraSinkProperties.class); assertThat(properties.getStatementExpression().getExpressionString(), equalTo(expression.getExpressionString())); context.close();//from www . j a v a 2s. c om }
From source file:com.cisco.cta.taxii.adapter.settings.SettingsConfigurationTest.java
private ConfigurableApplicationContext context(PropertySource<?> source) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(SettingsConfiguration.class); ctx.getEnvironment().getPropertySources().addFirst(source); ctx.refresh(); return ctx;/*from w w w . j a v a 2 s . c o m*/ }
From source file:com.mine.cassandra.sink.CassandraSinkPropertiesTests.java
@Test public void queryTypeCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "query-type:" + CassandraMessageHandler.Type.UPDATE); context.register(Conf.class); context.refresh(); CassandraSinkProperties properties = context.getBean(CassandraSinkProperties.class); assertThat(properties.getQueryType(), equalTo(CassandraMessageHandler.Type.UPDATE)); context.close();/*from w w w . j a va2 s .c om*/ }
From source file:com.mine.cassandra.sink.CassandraSinkPropertiesTests.java
@Test public void consistencyLevelCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "consistency-level:" + ConsistencyLevel.LOCAL_QUOROM); context.register(Conf.class); context.refresh(); CassandraSinkProperties properties = context.getBean(CassandraSinkProperties.class); assertThat(properties.getConsistencyLevel(), equalTo(ConsistencyLevel.LOCAL_QUOROM)); context.close();/*from www .j a v a 2s. c o m*/ }
From source file:com.mine.cassandra.sink.CassandraSinkPropertiesTests.java
@Test public void retryPolicyCanBeCustomized() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, "retry-policy:" + RetryPolicy.DOWNGRADING_CONSISTENCY); context.register(Conf.class); context.refresh(); CassandraSinkProperties properties = context.getBean(CassandraSinkProperties.class); assertThat(properties.getRetryPolicy(), equalTo(RetryPolicy.DOWNGRADING_CONSISTENCY)); context.close();/*from w ww .j a v a2 s.c o m*/ }
From source file:com.sandornemeth.metrics.spring.autoconfigure.ReporterTestCaseBase.java
private AnnotationConfigApplicationContext doLoad(Class<?>[] configs, String... environment) { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); applicationContext.register(configs); applicationContext.register(MetricsAutoConfiguration.class); EnvironmentTestUtils.addEnvironment(applicationContext, environment); applicationContext.refresh(); return applicationContext; }
From source file:at.ac.univie.isc.asio.nest.D2rqNestAssemblerTest.java
@Test public void should_create_singleton_assembler_if_no_optional_listeners_present() throws Exception { final StaticApplicationContext parent = new StaticApplicationContext(); final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.getBeanFactory().registerSingleton("factory", new SpringContextFactory(parent)); context.register(D2rqNestAssembler.class); context.refresh(); final D2rqNestAssembler actual = context.getBean(D2rqNestAssembler.class); assertThat(actual, notNullValue());/* w w w . j av a2 s .c om*/ }
From source file:com.netflix.genie.web.security.oauth2.pingfederate.PingFederateConditionsUnitTests.java
private AnnotationConfigApplicationContext load(final Class<?> config, final String... env) { final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); EnvironmentTestUtils.addEnvironment(context, env); context.register(config);//from w ww .j a va 2 s . c o m context.refresh(); return context; }
From source file:org.twinkql.template.AbstractTwinkqlTemplateFactory.java
/** * Gets the twinkql template.//from w w w.j a v a2 s . 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; }