Class DalRequestFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class DalRequestFilter
    extends Object
    implements javax.servlet.Filter
    The DalRequestFilter ensures that the request thread is handled inside of a DalThreadHandler this ensures that all requests are handled within a transaction which is committed or rolled back at the end of the request.

    This request filter also initializes the Dal layer (see the DalLayerInitializer). Although this is not required (session factory initialization is done automatically at first database access), it is better for test/debug purposes to do the initialization here. The DalRequestFilter is enabled by setting it in the web.xml file: <filter> <filter-name>dalFilter</filter-name> <filter-class>org.openbravo.dal.core.DalRequestFilter</filter-class> </filter> <filter-mapping> <filter-name>dalFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> Note the url-pattern can be defined more strictly if it is possible to identify the pages which require a session/transaction.

    Author:
    mtaal
    • Constructor Detail

      • DalRequestFilter

        public DalRequestFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig fConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.servlet.ServletException