Package de.hybris.platform.spring
Class HybrisContextLoaderListener
- java.lang.Object
-
- org.springframework.web.context.ContextLoader
-
- org.springframework.web.context.ContextLoaderListener
-
- de.hybris.platform.spring.HybrisContextLoaderListener
-
- All Implemented Interfaces:
java.util.EventListener,javax.servlet.ServletContextListener
- Direct Known Subclasses:
BackofficeApplicationContextInitializer,HybrisStorefrontContextLoaderListener,TenantUnawareHybrisContextLoaderListener
public class HybrisContextLoaderListener extends org.springframework.web.context.ContextLoaderListenerSets the global application context as parent context for created WebApplicationContext. and registers aHttpSessionListenerforSupports loading additional web spring config files. The additional config files are specified in a hybris configuration property. The property name is built as follows: <display-name>.additionalWebSpringConfigs Where <display-name> is ServletContext.getServletContextName() which is actually the <display-name> element from the web.xml for the web application.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringADDITIONAL_WEB_SPRING_CONFIGSprotected static java.lang.StringADDITIONAL_WEB_SPRING_CONFIGS_FROM_EXTstatic java.lang.StringCORE_SPRING_DEVELOPMENT_MODE_FLAG_KEYstatic java.lang.StringWEB_SPRING_DEVELOPMENT_MODE_FLAG_KEY
-
Constructor Summary
Constructors Constructor Description HybrisContextLoaderListener()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCustomConfigLocations(org.springframework.web.context.ConfigurableWebApplicationContext applicationContext, java.util.List<java.lang.String> customConfLocations)protected voidadjustTenant(javax.servlet.ServletContext servletContext)protected voidattachTenantIDToServletContext(javax.servlet.ServletContext ctx, java.lang.String tenantID)voidcontextInitialized(javax.servlet.ServletContextEvent event)protected org.springframework.web.context.WebApplicationContextcreateWebApplicationContext(javax.servlet.ServletContext servletContext)protected voidcustomizeContext(javax.servlet.ServletContext servletContext, org.springframework.web.context.ConfigurableWebApplicationContext applicationContext)protected org.springframework.web.context.WebApplicationContextdoInitWebApplicationContext(javax.servlet.ServletContext servletContext)protected voidfillConfigLocations(java.lang.String appName, java.util.List<java.lang.String> locations)protected voidfillConfigLocationsFromExtension(java.lang.String appName, java.lang.String fromExtension, java.util.List<java.lang.String> locations)protected voidfillConfigLocationsFromExtensions(java.lang.String appName, java.util.List<java.lang.String> locations)protected voidfillConfigLocationsFromParameter(java.lang.String parameterKey, java.util.List<java.lang.String> locations)protected voidfillLegacyConfigLocations(java.lang.String appName, java.util.List<java.lang.String> locations)protected java.lang.StringgetTenanId(java.lang.String contextPath)static java.lang.StringgetTenantIDForWebapp(javax.servlet.ServletContext ctx)org.springframework.web.context.WebApplicationContextinitWebApplicationContext(javax.servlet.ServletContext servletContext)Overridden just for handling not found tenants.protected org.springframework.context.ApplicationContextloadParentContext(javax.servlet.ServletContext servletContext)protected java.lang.StringreadConfigParameter(java.lang.String parameterKey)protected voidregisterHttpSessionListener(javax.servlet.ServletContext servletContext)protected voidrunWithActiveJaloSession(java.lang.String tenantId, javax.servlet.http.HttpSession httpSession, java.lang.Runnable runnable)protected voidrunWithTenant(java.lang.String tenantId, java.lang.Runnable runnable)protected voidstartRegistry()
-
-
-
Field Detail
-
ADDITIONAL_WEB_SPRING_CONFIGS
protected static final java.lang.String ADDITIONAL_WEB_SPRING_CONFIGS
- See Also:
- Constant Field Values
-
ADDITIONAL_WEB_SPRING_CONFIGS_FROM_EXT
protected static final java.lang.String ADDITIONAL_WEB_SPRING_CONFIGS_FROM_EXT
- See Also:
- Constant Field Values
-
CORE_SPRING_DEVELOPMENT_MODE_FLAG_KEY
public static final java.lang.String CORE_SPRING_DEVELOPMENT_MODE_FLAG_KEY
- See Also:
- Constant Field Values
-
WEB_SPRING_DEVELOPMENT_MODE_FLAG_KEY
public static final java.lang.String WEB_SPRING_DEVELOPMENT_MODE_FLAG_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent event)
- Specified by:
contextInitializedin interfacejavax.servlet.ServletContextListener- Overrides:
contextInitializedin classorg.springframework.web.context.ContextLoaderListener
-
registerHttpSessionListener
protected void registerHttpSessionListener(javax.servlet.ServletContext servletContext)
-
runWithTenant
protected void runWithTenant(java.lang.String tenantId, java.lang.Runnable runnable)
-
runWithActiveJaloSession
protected void runWithActiveJaloSession(java.lang.String tenantId, javax.servlet.http.HttpSession httpSession, java.lang.Runnable runnable)
-
initWebApplicationContext
public org.springframework.web.context.WebApplicationContext initWebApplicationContext(javax.servlet.ServletContext servletContext)
Overridden just for handling not found tenants. It wraps around theloadParentContext(ServletContext).- Overrides:
initWebApplicationContextin classorg.springframework.web.context.ContextLoader
-
doInitWebApplicationContext
protected org.springframework.web.context.WebApplicationContext doInitWebApplicationContext(javax.servlet.ServletContext servletContext)
-
loadParentContext
protected org.springframework.context.ApplicationContext loadParentContext(javax.servlet.ServletContext servletContext) throws org.springframework.beans.BeansException- Overrides:
loadParentContextin classorg.springframework.web.context.ContextLoader- Throws:
org.springframework.beans.BeansException
-
customizeContext
protected void customizeContext(javax.servlet.ServletContext servletContext, org.springframework.web.context.ConfigurableWebApplicationContext applicationContext)- Overrides:
customizeContextin classorg.springframework.web.context.ContextLoader
-
adjustTenant
protected void adjustTenant(javax.servlet.ServletContext servletContext) throws TenantNotFoundException- Throws:
TenantNotFoundException
-
getTenantIDForWebapp
public static java.lang.String getTenantIDForWebapp(javax.servlet.ServletContext ctx)
-
attachTenantIDToServletContext
protected void attachTenantIDToServletContext(javax.servlet.ServletContext ctx, java.lang.String tenantID)
-
startRegistry
protected void startRegistry()
-
createWebApplicationContext
protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(javax.servlet.ServletContext servletContext)
- Overrides:
createWebApplicationContextin classorg.springframework.web.context.ContextLoader
-
getTenanId
protected java.lang.String getTenanId(java.lang.String contextPath)
-
fillConfigLocations
protected void fillConfigLocations(java.lang.String appName, java.util.List<java.lang.String> locations)
-
fillLegacyConfigLocations
protected void fillLegacyConfigLocations(java.lang.String appName, java.util.List<java.lang.String> locations)
-
fillConfigLocationsFromExtensions
protected void fillConfigLocationsFromExtensions(java.lang.String appName, java.util.List<java.lang.String> locations)
-
fillConfigLocationsFromExtension
protected void fillConfigLocationsFromExtension(java.lang.String appName, java.lang.String fromExtension, java.util.List<java.lang.String> locations)
-
fillConfigLocationsFromParameter
protected void fillConfigLocationsFromParameter(java.lang.String parameterKey, java.util.List<java.lang.String> locations)
-
addCustomConfigLocations
protected void addCustomConfigLocations(org.springframework.web.context.ConfigurableWebApplicationContext applicationContext, java.util.List<java.lang.String> customConfLocations)
-
readConfigParameter
protected java.lang.String readConfigParameter(java.lang.String parameterKey)
-
-