List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext register
public void register(Class<?>... annotatedClasses)
From source file:io.gravitee.reporter.elastic.ElasticsearchReporterTest.java
public void init() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ReporterConfiguration.class); ctx.refresh();/* w ww.j a va2s .c om*/ this.reporter = ctx.getBean(ElasticsearchReporter.class); }
From source file:com.comcast.cats.domain.configuration.CatsHomeTest.java
public CatsHomeTest() { setCatsHome(getTargetDirectory());//w w w .j a va2s.c o m AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(); appCtx.register(CatsHome.class); appCtx.refresh(); ctx = appCtx; }
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();//from w w w.j a v a 2 s . co m return applicationContext; }
From source file:org.seasar.doma.boot.autoconfigure.TryLookupEntityListenerProviderTest.java
@Test public void testManaged() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(FooListener.class); context.refresh();/*ww w.jav a 2 s. co m*/ TryLookupEntityListenerProvider provider = new TryLookupEntityListenerProvider(); provider.setApplicationContext(context); FooListener listener = provider.get(FooListener.class, FooListener::new); assertThat(listener.managed, is(true)); }
From source file:com.visural.domo.spring.TransactionImplTest.java
private AnnotationConfigApplicationContext springBootstrap(ConnectionSource source) throws BeansException, IllegalStateException { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(AnnotationAwareAspectJAutoProxyCreator.class); CustomScopeConfigurer conf = new CustomScopeConfigurer(); Map<String, Object> scopes = new HashMap<String, Object>(); TransactionScope scope = new TransactionScope(); scopes.put(TransactionScope.Name, scope); conf.setScopes(scopes);/* ww w. j a va 2 s . co m*/ context.getBeanFactory().registerSingleton("transactionScope", scope); context.addBeanFactoryPostProcessor(conf); context.scan("com.visural"); context.refresh(); context.getBean(TransactionConfig.class).getConnectionProvider().registerDefaultConnectionSource(source); return context; }
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();/*from w w w. j a v a 2s . co m*/ return ctx; }
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 w w .j a va 2 s . co m*/ final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.setParent(parent); context.register(PropertySourcesPlaceholderConfigurer.class); context.register(getClass()); context.refresh(); context.getAutowireCapableBeanFactory().autowireBean(this); }
From source file:org.zephyrsoft.sdb2.Start.java
private Start(String[] args) { LOG.debug("starting application"); // parse command line arguments CmdLineParser parser = new CmdLineParser(options); parser.setUsageWidth(80);// www .j a v a 2 s . c o m try { parser.parseArgument(args); } catch (CmdLineException e) { System.err.println(e.getMessage()); options.setHelp(true); } if (options.isHelp()) { System.err.println("The available options are:"); parser.printUsage(System.err); } else { try { // set encoding to UTF-8 (the cache has to be reset to make the new definition effective) System.setProperty("file.encoding", "UTF-8"); Field charset = Charset.class.getDeclaredField("defaultCharset"); charset.setAccessible(true); charset.set(null, null); LOG.info("default time zone is {}", ZoneId.systemDefault().getId()); LOG.info("loading application context"); @SuppressWarnings("resource") AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(SpringConfiguration.class); context.refresh(); context.getAutowireCapableBeanFactory().autowireBean(this); mainController.loadSongs(options.getSongsFile()); mainWindow.startup(); } catch (Exception e) { LOG.error("problem while starting up the application", e); System.exit(-1); } } }
From source file:org.jbr.commons.container.java.JavaSpringContainer.java
/** * Constructs the application context used by this container. * /* w w w .j av a2 s .c o m*/ * @return this container's new application context * @throws SpringContainerException */ @Override protected AbstractApplicationContext createApplicationContext() throws SpringContainerException { final Class<?> contextConfigClass = getContextConfigClass(); final String profile = System.getProperty(JVM_PARM_PROFILE, getDefaultProfile()); log.info("Configuring Java SpringContainer using registered class [" + contextConfigClass + "] under profile [" + profile + "]"); final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.getEnvironment().setActiveProfiles(profile); context.register(contextConfigClass); context.registerShutdownHook(); return context; }
From source file:at.ac.univie.isc.asio.nest.D2rqNestAssembler.java
final void inject(final AnnotationConfigApplicationContext context, final NestConfig config) { context.register(NestBluePrint.class); final ConfigurableListableBeanFactory beans = context.getBeanFactory(); beans.registerSingleton("container-cleanup", new ContainerCleanUp(context, config, cleaners)); beans.registerSingleton("dataset", config.getDataset()); beans.registerSingleton("jdbc", config.getJdbc()); beans.registerSingleton("d2rq", config.getD2rq()); }