Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext.

Prototype

public AnnotationConfigApplicationContext(String... basePackages) 

Source Link

Document

Create a new AnnotationConfigApplicationContext, scanning for bean definitions in the given packages and automatically refreshing the context.

Usage

From source file:philaman.cput.cardealer.test.repository.BranchRepositoryTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    ctx = new AnnotationConfigApplicationContext(AppConfig.class);
}

From source file:org.sbq.batch.mains.ActivityEmulator.java

private ActivityEmulator() {
    super();/*from  w ww. j  a v a 2s .co m*/
    blockingQueue = new LinkedBlockingQueue<Runnable>();
    executor = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, blockingQueue);
    appCtx = new AnnotationConfigApplicationContext(ActivityEmulatorConfiguration.class);
    userService = appCtx.getBean(UserService.class);
    Map<String, AtomicBoolean> writableUserStatusByLogin = new HashMap<String, AtomicBoolean>();
    for (User user : userService.findAllUsers()) {
        writableUserStatusByLogin.put(user.getLogin(), new AtomicBoolean(false));
    }
    userStatusByLogin = Collections.unmodifiableMap(writableUserStatusByLogin);
}

From source file:org.joyrest.spring.SpringJavaConfigurer.java

@Override
public ApplicationContext initialize(Object applicationConfig) {
    requireNonNull(applicationConfig, "ApplicationConfig must be non-null for configuring Spring.");

    boolean isConfigAnnotated = applicationConfig.getClass().isAnnotationPresent(Configuration.class);
    if (!isConfigAnnotated) {
        throw new IllegalArgumentException("Provided config is @Configuration annotated Spring Java Config");
    }//from ww  w . j  av  a  2s  . c o m

    context = new AnnotationConfigApplicationContext(applicationConfig.getClass());
    return initializeContext();
}

From source file:org.openwms.client.fx.core.CoreApplication.java

/**
 * @see javafx.application.Application#start(javafx.stage.Stage)
 *///from  ww  w  .  j  a v  a2s .  c o m
@Override
public void start(Stage stage) throws Exception {
    ApplicationContext context = new AnnotationConfigApplicationContext(AppConfiguration.class);
    CoreViewConfiguration screens = context.getBean(CoreViewConfiguration.class);
    screens.setPrimaryStage(stage);
    screens.addDossierBrowser().show();
}

From source file:de.olivergierke.samples.spring.ConfigClassExtensionTest.java

@Test
@SuppressWarnings("resource")
public void bootstrapsSelfInjectingConfigurationClass() {

    ApplicationContext context = new AnnotationConfigApplicationContext(ChildConfig.class);
    context.getBean(MyComponent.class);
}

From source file:springfox.documentation.spring.web.ObjectMapperConfigurerIntegrationTest.java

@Test
public void event_is_fired_when_default_rmh_is_loaded() {

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            TestDefaultConfig.class);

    context.getBean("defaultRmh", RequestMappingHandlerAdapter.class);

    assertEquals(TestObjectMapperListener.firedCount, 1L);
}

From source file:org.openmrs.module.amqpmodule.AmqpModuleActivator.java

/**
 * @see ModuleActivator#started()//from   ww w  .ja v  a 2 s .  c  o  m
 */
public void started() {
    log.info("Amqp Module Module started");
    // Start AMQP Consumer With the Module
    new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
}

From source file:mg.jerytodik.scheduler.listeners.JerytodikInitializerListener.java

@SuppressWarnings("resource")
@Override//from  ww  w .j av  a2  s .c  om
public void contextInitialized(final ServletContextEvent contextEvent) {
    super.contextInitialized(contextEvent);

    final ApplicationContext applicationContext = new AnnotationConfigApplicationContext(
            JeryTodikSchedulerConfig.class);

    final SchedulerFactoryBean schedulerFactoryBean = applicationContext.getBean(SchedulerFactoryBean.class);

    try {
        schedulerFactoryBean.start();
    } catch (Exception e) {
        LOGGER.error("Error occured.", e);
    }
}

From source file:org.infinitest.eclipse.PluginContextIntegrationTest.java

@Test
public void shouldWireComponentsTogetherByTypeUsingSpringAutowiring() {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(TestInfinitestConfig.class);

    assertThat(ctx.getBeansOfType(IResourceChangeListener.class)).isNotEmpty();
    assertThat(ctx.getBeansOfType(ResourceFinder.class)).isNotEmpty();
}

From source file:com.petecapra.restconfig.RESTConfigService.java

@Override
protected void initialize(RESTConfigConfiguration configuration, Environment environment) throws Exception {
    // TODO: externalise this and automatically scan context for resources and health checks
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    //ctx.scan("com.petecapra.restconfig");
    environment.addResource(ctx.getBean(EnvironmentsResource.class));
    environment.addResource(ctx.getBean(ApplicationsResource.class));
    environment.addResource(ctx.getBean(EnvironmentApplicationsResource.class));
    environment.addHealthCheck(ctx.getBean(DatabaseHealthCheck.class));
}