Interface IXServletSimpleHandler
-
- All Superinterfaces:
IXServletBasicHandler
- All Known Implementing Classes:
RedirectAbsoluteXServletHandler,RedirectToServletXServletHandler
public interface IXServletSimpleHandler extends IXServletBasicHandler
Special interface for a simple servlet handler.- Author:
- Philip Helger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default com.helger.servlet.response.UnifiedResponsecreateUnifiedResponse(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 LocalDateTimegetLastModificationDateTime(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)Get the last modification date time for the current request.default StringgetSupportedETag(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)Get the ETag supported for this request.voidhandleRequest(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.servlet.response.UnifiedResponse aUnifiedResponse)This is the main request handling method.default com.helger.commons.state.EContinueinitRequestState(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.EContinueonException(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.servlet.response.UnifiedResponse aUnifiedResponse, Throwable t)Called when an exception occurred inhandleRequest(IRequestWebScopeWithoutResponse, UnifiedResponse).default voidonRequestBegin(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope)Called before a valid request is handled.default voidonRequestEnd(Throwable aCaughtException)Called after a valid request was processed.-
Methods inherited from interface com.helger.xservlet.handler.IXServletBasicHandler
onServletDestroy, onServletInit
-
-
-
-
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 requestaRequestScope- 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. Nevernull.aUnifiedResponse- The response object to be filled. Nevernull.- Returns:
EContinue.BREAKto stop processing (e.g. because a resource does not exist),EContinue.CONTINUEto 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 afterinitRequestState(IRequestWebScopeWithoutResponse, UnifiedResponse).- Parameters:
aRequestScope- The request scope that will be used for processing the request. Nevernull.- Returns:
nullif 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. Nevernull.- Returns:
nullif 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. Nevernull.
-
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 theHttpServletResponse. Everything must be handled with the unified response! Nevernull.aUnifiedResponse- The response object to be filled. Nevernull.- 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 inhandleRequest(IRequestWebScopeWithoutResponse, UnifiedResponse). This method is only called for non-request-cancel operations.- Parameters:
aRequestScope- The source request scope. Nevernull.aUnifiedResponse- The response to the current request. Nevernull.t- The Throwable that occurred. Nevernull.- Returns:
EContinue.CONTINUEto propagate the Exception,EContinue.BREAKto swallow it. May not benull.
-
onRequestEnd
@OverrideOnDemand default void onRequestEnd(@Nullable Throwable aCaughtException)
Called after a valid request was processed. This method is only called if the handleRequest method was invoked. If an exception occurred this method is called afteronException(IRequestWebScopeWithoutResponse, UnifiedResponse, Throwable)- Parameters:
aCaughtException-nullif no exception occurred, non-nullin case of exception.
-
-