Interface IXServletSimpleHandler

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default com.helger.servlet.response.UnifiedResponse createUnifiedResponse​(com.helger.http.EHttpVersion eHttpVersion, com.helger.commons.http.EHttpMethod eHttpMethod, javax.servlet.http.HttpServletRequest aHttpRequest, com.helger.web.scope.IRequestWebScope aRequestScope)
      Create a unified response object.
      default LocalDateTime getLastModificationDateTime​(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)
      Get the last modification date time for the current request.
      default String getSupportedETag​(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)
      Get the ETag supported for this request.
      void handleRequest​(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.servlet.response.UnifiedResponse aUnifiedResponse)
      This is the main request handling method.
      default com.helger.commons.state.EContinue initRequestState​(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.servlet.response.UnifiedResponse aUnifiedResponse)
      This callback method is unconditionally called before the last-modification checks are performed.
      default com.helger.commons.state.EContinue onException​(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.servlet.response.UnifiedResponse aUnifiedResponse, Throwable t)
      default void onRequestBegin​(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)
      Called before a valid request is handled.
      default void onRequestEnd​(Throwable aCaughtException)
      Called after a valid request was processed.
    • Method Detail

      • createUnifiedResponse

        @Nonnull
        default com.helger.servlet.response.UnifiedResponse createUnifiedResponse​(@Nonnull
                                                                                  com.helger.http.EHttpVersion eHttpVersion,
                                                                                  @Nonnull
                                                                                  com.helger.commons.http.EHttpMethod eHttpMethod,
                                                                                  @Nonnull
                                                                                  javax.servlet.http.HttpServletRequest aHttpRequest,
                                                                                  @Nonnull
                                                                                  com.helger.web.scope.IRequestWebScope aRequestScope)
        Create a unified response object.
        Parameters:
        eHttpVersion - HTTP version of the current request.
        eHttpMethod - HTTP method of the current request.
        aHttpRequest - Current HTTP request
        aRequestScope - Current HTTP request scope
        Returns:
        The new unified response. Never null.
      • initRequestState

        @OverrideOnDemand
        default com.helger.commons.state.EContinue initRequestState​(@Nonnull
                                                                    com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope,
                                                                    @Nonnull
                                                                    com.helger.servlet.response.UnifiedResponse aUnifiedResponse)
        This callback method is unconditionally called before the last-modification checks are performed. So this method can be used to determine the requested object from the request. This method is not called if HTTP version or HTTP method are not supported.
        Parameters:
        aRequestScope - The request scope that will be used for processing the request. Never null.
        aUnifiedResponse - The response object to be filled. Never null.
        Returns:
        EContinue.BREAK to stop processing (e.g. because a resource does not exist), EContinue.CONTINUE to continue processing as usual.
      • getLastModificationDateTime

        @Nullable
        default LocalDateTime getLastModificationDateTime​(@Nonnull
                                                          com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)
        Get the last modification date time for the current request. If it was not modified since the last request time, a 304 (not modified) response code is returned. This method is always called for GET and HEAD requests. This method is called after initRequestState(IRequestWebScopeWithoutResponse, UnifiedResponse) .
        Parameters:
        aRequestScope - The request scope that will be used for processing the request. Never null.
        Returns:
        null if no last modification date time can be determined
      • getSupportedETag

        @Nullable
        default String getSupportedETag​(@Nonnull
                                        com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)
        Get the ETag supported for this request. If an ETag matches, a 304 (not modified) response code is returned. This method is always called for GET and HEAD requests.
        Parameters:
        aRequestScope - The request scope that will be used for processing the request. Never null.
        Returns:
        null if this servlet does not support ETags
      • onRequestBegin

        @OverrideOnDemand
        @Nonnull
        default void onRequestBegin​(@Nonnull
                                    com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)
        Called before a valid request is handled. This method is only called if HTTP version matches, HTTP method is supported and sending a cached HTTP response is not an option.
        Parameters:
        aRequestScope - The request scope that will be used for processing the request. Never null.
      • handleRequest

        void handleRequest​(@Nonnull
                           com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope,
                           @Nonnull
                           com.helger.servlet.response.UnifiedResponse aUnifiedResponse)
                    throws Exception
        This is the main request handling method. Overwrite this method to fill your HTTP response.
        Parameters:
        aRequestScope - The request scope to use. There is no direct access to the HttpServletResponse. Everything must be handled with the unified response! Never null.
        aUnifiedResponse - The response object to be filled. Never null.
        Throws:
        Exception - In case of an error
      • onException

        @OverrideOnDemand
        @Nonnull
        default com.helger.commons.state.EContinue onException​(@Nonnull
                                                               com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope,
                                                               @Nonnull
                                                               com.helger.servlet.response.UnifiedResponse aUnifiedResponse,
                                                               @Nonnull
                                                               Throwable t)
        Called when an exception occurred in handleRequest(IRequestWebScopeWithoutResponse, UnifiedResponse). This method is only called for non-request-cancel operations.
        Parameters:
        aRequestScope - The source request scope. Never null.
        aUnifiedResponse - The response to the current request. Never null.
        t - The Throwable that occurred. Never null.
        Returns:
        EContinue.CONTINUE to propagate the Exception, EContinue.BREAK to swallow it. May not be null.