Class ServerInterceptor

  • All Implemented Interfaces:
    org.springframework.web.servlet.HandlerInterceptor
    Direct Known Subclasses:
    ProtocolInterceptor, RepositoryInterceptor

    public abstract class ServerInterceptor
    extends Object
    implements org.springframework.web.servlet.HandlerInterceptor
    Base class for single-use request interceptors. This implementation sets the thread name to something sensible at the start of the request handling and resets the name at the end. This is useful for logging frameworks that make use of thread names, such as Log4J. Should not be a singleton bean! Configure as inner bean in openrdf-servlet.xml
    Author:
    Herko ter Horst
    • Constructor Detail

      • ServerInterceptor

        public ServerInterceptor()
    • Method Detail

      • preHandle

        public boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 Object handler)
                          throws Exception
        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Throws:
        Exception
      • afterCompletion

        public void afterCompletion​(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    Object handler,
                                    Exception exception)
                             throws Exception
        Specified by:
        afterCompletion in interface org.springframework.web.servlet.HandlerInterceptor
        Throws:
        Exception
      • getThreadName

        protected abstract String getThreadName()
                                         throws ServerHTTPException
        Determine the thread name to use. Called before the request is forwarded to a handler.
        Returns:
        a name that makes sense based on the request
        Throws:
        ServerHTTPException - if it was impossible to determine a name due to an internal error
      • setRequestAttributes

        protected void setRequestAttributes​(javax.servlet.http.HttpServletRequest request)
                                     throws ClientHTTPException,
                                            ServerHTTPException
        Set attributes for this request. Called before the request is forwarded to a handler. By default, this method does nothing.
        Parameters:
        request - the request
        Throws:
        ClientHTTPException - if it was impossible to set one or more attributes due to a bad request on the part of the client
        ServerHTTPException - if it was impossible to set one or more attributes due to an internal error
      • cleanUpResources

        protected void cleanUpResources()
                                 throws ServerHTTPException
        Clean up resources used in handling this request. Called after the request is handled and a the view is rendered (or an exception has occurred). By default, this method does nothing.
        Throws:
        ServerHTTPException - if some resources could not be cleaned up because of an internal error