/** * Creates and returns the Spring application context. * * @return the application context */ protected ApplicationContext createApplicationContext() { // Create the Spring application context and register the JavaConfig classes we need. // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the uploader). AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); ApplicationContextHolder.setApplicationContext(applicationContext); applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class, DataBridgeEnvSpringModuleConfig.class); applicationContext.refresh(); return applicationContext; } }
/** * Creates and returns the Spring application context. * * @return the application context */ private ApplicationContext createApplicationContext() { // Create the Spring application context and register the JavaConfig classes we need. // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the application). AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); ApplicationContextHolder.setApplicationContext(applicationContext); applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class, DataBridgeEnvSpringModuleConfig.class); applicationContext.refresh(); return applicationContext; } }
/** * Creates and returns the Spring application context. * * @return the application context */ protected ApplicationContext createApplicationContext() { // Create the Spring application context and register the JavaConfig classes we need. // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the uploader). AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); ApplicationContextHolder.setApplicationContext(applicationContext); applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class, DataBridgeEnvSpringModuleConfig.class); applicationContext.refresh(); return applicationContext; } }
/** * Creates and returns the Spring application context. * * @return the application context */ private ApplicationContext createApplicationContext() { // Create the Spring application context and register the JavaConfig classes we need. // We will use core (in case it's needed), the service aspect that times the duration of the service method calls, and our specific beans defined in // the data bridge configuration. We're not including full service and DAO configurations because they come with database/data source dependencies // that we don't need and don't want (i.e. we don't want the database to be running as a pre-requisite for running the application). AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(); ApplicationContextHolder.setApplicationContext(applicationContext); applicationContext.register(CoreSpringModuleConfig.class, DataBridgeSpringModuleConfig.class, DataBridgeAopSpringModuleConfig.class, DataBridgeEnvSpringModuleConfig.class); applicationContext.refresh(); return applicationContext; } }
@Override protected void prepareContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) { // Set the application context in the context holder for access by static @Bean methods. ApplicationContextHolder.setApplicationContext(context); // Perform standard functionality. super.prepareContext(context, mergedConfig); } }
@Override protected void prepareContext(GenericApplicationContext context) { // Set the application context in the context holder for access by static @Bean methods. ApplicationContextHolder.setApplicationContext(context); // Perform standard functionality. super.prepareContext(context); } }
/** * Initializes the context loader listener which bootstraps Spring and provides access to the application context. * * @param servletContext the servlet context. */ protected void initContextLoaderListener(ServletContext servletContext) { // Add the context loader listener for the base (i.e. root) Spring configuration. // We register all our @Configuration annotated classes with the context so Spring will load all the @Bean's via these classes. // We also set the application context in an application context holder before "registering" so static @Bean's // (e.g. PropertySourcesPlaceholderConfigurer) will have access to it since they can't take advantage of autowiring or having a class be // ApplicationContextAware to get it. AnnotationConfigWebApplicationContext contextLoaderListenerContext = new AnnotationConfigWebApplicationContext(); ApplicationContextHolder.setApplicationContext(contextLoaderListenerContext); contextLoaderListenerContext .register(CoreSpringModuleConfig.class, DaoSpringModuleConfig.class, DaoEnvSpringModuleConfig.class, ServiceSpringModuleConfig.class, ServiceEnvSpringModuleConfig.class, UiSpringModuleConfig.class, UiEnvSpringModuleConfig.class, RestSpringModuleConfig.class, AppSpringModuleConfig.class); servletContext.addListener(new ContextLoaderListener(contextLoaderListenerContext)); }