List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:com.mac.halendpoint.endpoints.HalSocket.java
public HalSocket() { super(new InetSocketAddress(PORT)); ctx = new AnnotationConfigApplicationContext(DataSourceConfig.class); presetRepo = ctx.getBean(PresetRepository.class); isFirstConnection = true;// w ww . j a va 2s . c o m socketManager = new WebSocketManagerImpl(); router = new ProtocolRouter(); deviceManager = new DeviceStateRectifier(); deviceManager.setUpdatedStateListener(this); }
From source file:net.kamhon.ieagle.application.Application.java
protected static synchronized ApplicationContext initialize(final ServletContext servletContext) { try {/* w w w. ja v a 2s. co m*/ if (appContext == null) { appContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); } } catch (Exception ex) { log.info("WebApplicationContext not found!!! Using ClassPathXmlApplicationContext"); if (StringUtils.isBlank(contextPath)) { initContextPath(); } try { if (appContext == null && contextPath.endsWith(".class")) { appContext = new AnnotationConfigApplicationContext( Class.forName(contextPath.substring(0, contextPath.length() - ".class".length()))); } } catch (Exception e) { e.printStackTrace(); } try { if (appContext == null) appContext = new FileSystemXmlApplicationContext(contextPath); } catch (Exception e) { } try { if (appContext == null) appContext = new ClassPathXmlApplicationContext(contextPath); } catch (Exception e) { } createGenericApplicationContext(); } return appContext; }
From source file:com.cisco.cta.taxii.adapter.settings.SettingsConfigurationTest.java
@Test public void refuseMissingConfiguration() throws Exception { try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( SettingsConfiguration.class)) { fail("The context creation must fail because of missing configuration."); } catch (NestedRuntimeException e) { BindException be = (BindException) e.getRootCause(); assertThat(be.getFieldErrors(), is(not(emptyCollectionOf(FieldError.class)))); }/*from w w w.j ava2 s . c o m*/ }
From source file:ninja.javafx.smartcsv.fx.SmartCSV.java
@Override public void start(Stage primaryStage) throws Exception { appContext = new AnnotationConfigApplicationContext(SmartCSV.class); String name = appContext.getEnvironment().getProperty("application.name"); String version = appContext.getEnvironment().getProperty("application.version"); Platform.setImplicitExit(false);/*from w w w . j a v a 2 s. c o m*/ AboutController aboutController = appContext.getBean(AboutController.class); aboutController.setHostServices(getHostServices()); try { showUI(primaryStage, name, version); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.olivergierke.whoops.misc.lookup.LookupTest.java
@Test public void bootstrapJavaConfigContainer() { ApplicationContext context = new AnnotationConfigApplicationContext(Config.class); MyComponent component = context.getBean(MyComponent.class); assertThat(component, is(notNullValue())); List<MyPlugin> plugins = component.getPlugins(); assertThat(plugins.size(), is(2));/*from w ww .j a v a 2s . c o m*/ }
From source file:io.meles.spring.SpringContextRule.java
@Override public Statement apply(final Statement base, final Description description) { return new Statement() { @Override// w w w .ja v a 2s. c o m public void evaluate() throws Throwable { try (AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( config)) { SpringContextRule.this.applicationContext = applicationContext; base.evaluate(); } finally { applicationContext = null; } } }; }
From source file:com.centurylink.cloud.sdk.ClcSpringAdapterTest.java
@Test(groups = { SPRING_ADAPTER }) public void runTest() { ApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class); GroupService groupService = context.getBean(GroupService.class); ServerService serverService = context.getBean(ServerService.class); PolicyService policyService = context.getBean(PolicyService.class); TemplateService templateService = context.getBean(TemplateService.class); DataCenterService dataCenterService = context.getBean(DataCenterService.class); StatisticsService statisticsService = context.getBean(StatisticsService.class); LoadBalancerService loadBalancerService = context.getBean(LoadBalancerService.class); LoadBalancerPoolService loadBalancerPoolService = context.getBean(LoadBalancerPoolService.class); LoadBalancerNodeService loadBalancerNodeService = context.getBean(LoadBalancerNodeService.class); assertNotNull(groupService);//from w ww . j a v a 2s.c o m assertNotNull(serverService); assertNotNull(policyService); assertNotNull(templateService); assertNotNull(dataCenterService); assertNotNull(statisticsService); assertNotNull(loadBalancerService); assertNotNull(loadBalancerPoolService); assertNotNull(loadBalancerNodeService); List<LoadBalancerMetadata> loadBalancerMetadataList = loadBalancerService .find(new LoadBalancerFilter().dataCenters(DataCenter.US_EAST_STERLING)); assertNotNull(loadBalancerMetadataList); }
From source file:org.duracloud.mill.audit.generator.AuditLogGeneratorDriver.java
@Override protected void executeImpl(CommandLine cmd) { PropertyDefinitionListBuilder builder = new PropertyDefinitionListBuilder(); List<PropertyDefinition> list = builder.addAws().addMillDb().addDuracloudAuditSpace().addWorkDir().build(); new PropertyVerifier(list).verify(System.getProperties()); SystemConfig config = SystemConfig.instance(); config.setAuditLogSpaceId(System.getProperty(ConfigConstants.AUDIT_LOGS_SPACE_ID)); String logRootDir = System.getProperty(ConfigConstants.WORK_DIRECTORY_PATH) + File.separator + "audit-logs"; initializeLogRoot(logRootDir);//from www .j a v a 2 s . c om ApplicationContext context = new AnnotationConfigApplicationContext("org.duracloud.mill"); log.info("spring context initialized."); AuditLogGenerator generator = context.getBean(AuditLogGenerator.class); generator.execute(); log.info("exiting..."); }
From source file:coreexample.AppConfigTest.java
private ApplicationContext doTesting(Class<?> appConfigClass) { Locale expected = new Locale("en", "US"); ApplicationContext context = new AnnotationConfigApplicationContext(appConfigClass); Locale systemLocale = context.getBean("systemLocale", Locale.class); assertNotNull(systemLocale);/* w w w . j a va2 s . co m*/ assertNotSame(expected, context); return context; }
From source file:com.nkosy.designpatterns.behavioural.chainofresponsibilitypattern.test.chainofresponsibilitypattern.java
@BeforeMethod public void setUpMethod() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); }