Class AbstractPlatformFilterChain

  • All Implemented Interfaces:
    javax.servlet.Filter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.EnvironmentAware, org.springframework.core.env.EnvironmentCapable, org.springframework.web.context.ServletContextAware
    Direct Known Subclasses:
    BackOfficeFilterChain, PlatformFilterChain

    public abstract class AbstractPlatformFilterChain
    extends org.springframework.web.filter.OncePerRequestFilter
    Instead of implementing all the different feature into one Filter this filter just provides a internal chain where you can add different other filters to add additional features to your request processing.

    As these filters are part of the internal chain, they are only triggered if this filter is triggered, therefore the same filter mapping configuration is automatically applied.

    This filter is extending the OncePerRequestFilter class provided by Spring in order to ensure, that the filter (and the configured filter of the internal chain) is only called once.

    There are several filters available providing a standard set of features like tenant handling, session handling and catalog version handling. You can simply add these filter to the internal chain by configuring the spring bean definition accordingly.

    This filter should be configured in the Spring configuration file of your web application and provide a list of bean ids of the beans which should be used in the internal chain as constructor arguments.

     <bean id="aggregationFilter" class="de.hybris.platform.servicelayer.web.AggregationFilter">
            <constructor-arg>
                    <list>
                            <ref bean="profileFilter"/>
                            <ref bean="log4jFilter"/>
                            <ref bean="tenantActivationFilter"/>
                            <ref bean="sessionFilter"/>
                            <ref bean="simpleCatalogVersionFilter"/>
                    </list>
            </constructor-arg>
     </bean>
     

    In order to use this configured bean instance in your web application, you now have to configure the DelegatingFilterProxy in the web.xml your web application in order to for your configured aggregationFilter to be called during request processing. Do not forget to also define the filter mapping to be used:

     <filter-mapping>
            <filter-name>platformFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
     </filter-mapping>
     

    Right now there are no filters which allow you to have the following functionality, which have been provided by the WebSessionFunctions:

      * Dynamic tenant handling: Switching the tenant dynamically by specifying the tenantId as a query parameter.
      * System Init check: Checking for each request if the hybris system is initialized.
      * Status pages: Serving special pages to the client if the system is currently shutting down or a special info token is
      provided.
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  AbstractPlatformFilterChain.InternalFilterChain
      Simple & straight forward implementation of the FilterChain interface used by the PlatformFilterChain for it's internal chain.
    • Field Summary

      • Fields inherited from class org.springframework.web.filter.OncePerRequestFilter

        ALREADY_FILTERED_SUFFIX
      • Fields inherited from class org.springframework.web.filter.GenericFilterBean

        logger
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractPlatformFilterChain​(java.util.List<javax.servlet.Filter> internalFilters)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doFilterInternal​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)  
      protected java.util.Collection<java.lang.String> getExcludedUrlPaths()  
      protected abstract boolean isBackOfficeFilterChain()
      Returns true if filter is used in backoffice application.
      void setExcludedUrlPaths​(java.util.List<java.lang.String> excludedUrlPaths)  
      void setPreFilter​(AbstractPlatformPreFilter preFilter)  
      protected boolean shouldBreakFiltering​(java.lang.String requestURI)  
      protected static <E extends java.lang.Throwable>
      void
      throwAnyException​(java.lang.Throwable exception)  
      protected static void throwUncheckedException​(java.lang.Throwable exception)  
      • Methods inherited from class org.springframework.web.filter.OncePerRequestFilter

        doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch
      • Methods inherited from class org.springframework.web.filter.GenericFilterBean

        addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractPlatformFilterChain

        public AbstractPlatformFilterChain​(java.util.List<javax.servlet.Filter> internalFilters)
    • Method Detail

      • getExcludedUrlPaths

        protected java.util.Collection<java.lang.String> getExcludedUrlPaths()
      • setExcludedUrlPaths

        public void setExcludedUrlPaths​(java.util.List<java.lang.String> excludedUrlPaths)
      • doFilterInternal

        protected void doFilterInternal​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        javax.servlet.FilterChain filterChain)
                                 throws javax.servlet.ServletException,
                                        java.io.IOException
        Specified by:
        doFilterInternal in class org.springframework.web.filter.OncePerRequestFilter
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • isBackOfficeFilterChain

        protected abstract boolean isBackOfficeFilterChain()
        Returns true if filter is used in backoffice application.
      • shouldBreakFiltering

        protected boolean shouldBreakFiltering​(java.lang.String requestURI)
      • throwUncheckedException

        protected static void throwUncheckedException​(java.lang.Throwable exception)
      • throwAnyException

        protected static <E extends java.lang.Throwable> void throwAnyException​(java.lang.Throwable exception)
                                                                         throws E extends java.lang.Throwable
        Throws:
        E extends java.lang.Throwable