Java Code Examples for org.springframework.web.context.support.GenericWebApplicationContext#setId()
The following examples show how to use
org.springframework.web.context.support.GenericWebApplicationContext#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJettyComponent.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) { GenericWebApplicationContext wac = (GenericWebApplicationContext) BeanUtils.instantiateClass(GenericWebApplicationContext.class); // Assign the best possible id value. wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + contextPath); wac.setParent(parent); wac.setServletContext(sc); wac.refresh(); return wac; }
Example 2
Source File: SpringContextService.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Initialize a global Application Context containing all beans (core + plugins) * Now uses GenericApplicationContext for better performances. A wrong formatted * file will not block block context to be built (without the file), but a wrong * bean (i.e. cannot be instantiated) will cause a full context failure. Context * is less "failure-friendly" * * @param servletContext The servlet context * @throws LuteceInitException The lutece init exception * @since 2.4 */ public static void init( ServletContext servletContext ) throws LuteceInitException { try { // Register this service as a PluginEventListener PluginService.registerPluginEventListener( _instance ); // timing Date dateBegin = new Date( ); // Load the core context file : core_context.xml String strConfPath = AppPathService.getAbsolutePathFromRelativePath( PATH_CONF ); String strContextFile = PROTOCOL_FILE + strConfPath + FILE_CORE_CONTEXT; GenericWebApplicationContext gwac = new GenericWebApplicationContext( servletContext ); gwac.setId( getContextName( servletContext ) ); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader( gwac ); xmlReader.loadBeanDefinitions( strContextFile ); AppLogService.info( "Context file loaded : " + FILE_CORE_CONTEXT ); // Load all context files found in the conf/plugins directory // Files are loaded separatly with an individual try/catch block // to avoid stopping the process in case of a failure // The global context generation will fail if a bean in any file cannot be // built. String strConfPluginsPath = strConfPath + DIR_PLUGINS; File dirConfPlugins = new File( strConfPluginsPath ); FilenameFilter filterContext = new ContextFileFilter( ); String[] filesContext = dirConfPlugins.list( filterContext ); loadContexts( filesContext, strConfPluginsPath, xmlReader ); // we now load overriding beans AppLogService.info( "Loading plugins context overrides" ); String strCoreContextOverrideFile = strConfPath + DIR_OVERRIDE + FILE_CORE_CONTEXT; File fileCoreContextOverride = new File( strCoreContextOverrideFile ); if ( fileCoreContextOverride.exists( ) ) { AppLogService.debug( "Context file loaded : core_context" ); xmlReader.loadBeanDefinitions( PROTOCOL_FILE + strCoreContextOverrideFile ); } else { AppLogService.debug( "No core_context override found" ); } // load plugins overrides String strConfPluginsOverridePath = strConfPath + DIR_OVERRIDE_PLUGINS; File dirConfOverridePlugins = new File( strConfPluginsOverridePath ); if ( dirConfOverridePlugins.exists( ) ) { String[] filesOverrideContext = dirConfOverridePlugins.list( filterContext ); loadContexts( filesOverrideContext, strConfPluginsOverridePath, xmlReader ); } gwac.refresh( ); _context = gwac; AppLogService .info( "Spring context loaded in " + ( new Date( ).getTime( ) - dateBegin.getTime( ) ) + "ms" ); } catch ( Exception e ) { AppLogService.error( "Error initializing Spring Context Service " + e.getMessage( ), e ); throw new LuteceInitException( "Error initializing Spring Context Service", e ); } }