Class HybrisContextLoaderListener

  • All Implemented Interfaces:
    java.util.EventListener, javax.servlet.ServletContextListener
    Direct Known Subclasses:
    BackofficeApplicationContextInitializer, HybrisStorefrontContextLoaderListener, TenantUnawareHybrisContextLoaderListener

    public class HybrisContextLoaderListener
    extends org.springframework.web.context.ContextLoaderListener
    Sets the global application context as parent context for created WebApplicationContext. and registers a HttpSessionListener for

    Supports 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.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addCustomConfigLocations​(org.springframework.web.context.ConfigurableWebApplicationContext applicationContext, java.util.List<java.lang.String> customConfLocations)  
      protected void adjustTenant​(javax.servlet.ServletContext servletContext)  
      protected void attachTenantIDToServletContext​(javax.servlet.ServletContext ctx, java.lang.String tenantID)  
      void contextInitialized​(javax.servlet.ServletContextEvent event)  
      protected org.springframework.web.context.WebApplicationContext createWebApplicationContext​(javax.servlet.ServletContext servletContext)  
      protected void customizeContext​(javax.servlet.ServletContext servletContext, org.springframework.web.context.ConfigurableWebApplicationContext applicationContext)  
      protected org.springframework.web.context.WebApplicationContext doInitWebApplicationContext​(javax.servlet.ServletContext servletContext)  
      protected void fillConfigLocations​(java.lang.String appName, java.util.List<java.lang.String> locations)  
      protected void fillConfigLocationsFromExtension​(java.lang.String appName, java.lang.String fromExtension, java.util.List<java.lang.String> locations)  
      protected void fillConfigLocationsFromExtensions​(java.lang.String appName, java.util.List<java.lang.String> locations)  
      protected void fillConfigLocationsFromParameter​(java.lang.String parameterKey, java.util.List<java.lang.String> locations)  
      protected void fillLegacyConfigLocations​(java.lang.String appName, java.util.List<java.lang.String> locations)  
      protected java.lang.String getTenanId​(java.lang.String contextPath)  
      static java.lang.String getTenantIDForWebapp​(javax.servlet.ServletContext ctx)  
      org.springframework.web.context.WebApplicationContext initWebApplicationContext​(javax.servlet.ServletContext servletContext)
      Overridden just for handling not found tenants.
      protected org.springframework.context.ApplicationContext loadParentContext​(javax.servlet.ServletContext servletContext)  
      protected java.lang.String readConfigParameter​(java.lang.String parameterKey)  
      protected void registerHttpSessionListener​(javax.servlet.ServletContext servletContext)  
      protected void runWithActiveJaloSession​(java.lang.String tenantId, javax.servlet.http.HttpSession httpSession, java.lang.Runnable runnable)  
      protected void runWithTenant​(java.lang.String tenantId, java.lang.Runnable runnable)  
      protected void startRegistry()  
      • Methods inherited from class org.springframework.web.context.ContextLoaderListener

        contextDestroyed
      • Methods inherited from class org.springframework.web.context.ContextLoader

        closeWebApplicationContext, configureAndRefreshWebApplicationContext, determineContextClass, determineContextInitializerClasses, getCurrentWebApplicationContext, setContextInitializers
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • HybrisContextLoaderListener

        public HybrisContextLoaderListener()
    • Method Detail

      • contextInitialized

        public void contextInitialized​(javax.servlet.ServletContextEvent event)
        Specified by:
        contextInitialized in interface javax.servlet.ServletContextListener
        Overrides:
        contextInitialized in class org.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 the loadParentContext(ServletContext).
        Overrides:
        initWebApplicationContext in class org.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:
        loadParentContext in class org.springframework.web.context.ContextLoader
        Throws:
        org.springframework.beans.BeansException
      • customizeContext

        protected void customizeContext​(javax.servlet.ServletContext servletContext,
                                        org.springframework.web.context.ConfigurableWebApplicationContext applicationContext)
        Overrides:
        customizeContext in class org.springframework.web.context.ContextLoader
      • 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:
        createWebApplicationContext in class org.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)