public class SpincastFrontController<R extends IRequestContext<R>,W extends IWebsocketContext<?>> extends Object implements IFrontController
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SpincastFrontController(IRouter<R,W> router,
ISpincastConfig spincastConfig,
ISpincastDictionary spincastDictionary,
IServer server,
IRequestContextFactory<R> requestCreationFactory,
SpincastRequestScope spincastRequestScope,
Type requestContextType,
IJsonManager jsonManager,
IXmlManager xmlManager)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDefaultNotFoundRoute()
Add the default Not Found route.
|
protected void |
addDependenciesInCustomRequestScope(R requestContext)
Add dependencies to the custom request scope
|
protected void |
addRequestContextInCustomRequestScope(R requestContext)
Add the request context object in the cutom request scope
|
protected void |
callRouteHandlers(R requestContext,
IRoutingResult<R> routingResult)
Call the handlers, in order they are specified.
|
protected R |
createForwardedRequestContext(R context,
String fullUrlOrRelativePathAndQueryString) |
protected void |
customExceptionHandling(Throwable ex,
R requestContext,
IRoutingResult<R> originalRoutingResult)
Custom exception handling.
|
protected void |
defaultExceptionHandling(Object exchange,
Throwable ex)
Default exception handling.
|
protected void |
defaultPrivateExceptionHandling(Object exchange,
Throwable exception)
Default exception handling for private exceptions
|
protected void |
defaultPublicExceptionHandling(Object exchange,
IPublicException publicException)
Default exception handling for exceptions with
public information.
|
protected IRoutingResult<R> |
findRouteMatch(R requestContext)
Find the route handlers to call.
|
protected String |
getDefaultExceptionHandlingCharset()
Charset used by the default exception handling.
|
protected IHandler<R> |
getDefaultNotFoundHandler()
Create the default Not Found handler
|
protected String |
getDefaultNotFoundHandlerNotFoundMessage()
The message to send for the default Not Found handler.
|
protected String |
getInternalErrorHtmlContent(String errorMessage) |
protected String |
getInternalErrorJsonContent(String errorMessage) |
protected String |
getInternalErrorTextContent(String errorMessage) |
protected String |
getInternalErrorXmlContent(String errorMessage) |
protected IJsonManager |
getJsonManager() |
protected String |
getNotFoundHtmlContent(String message) |
protected String |
getNotFoundJsonContent(String message) |
protected String |
getNotFoundPlainTextContent(String message) |
protected String |
getNotFoundXmlContent(String message) |
protected IRequestContextFactory<R> |
getRequestContextFactory() |
protected Type |
getRequestContextType() |
protected ContentTypeDefaults |
getResponseContentTypeToUse(Object exchange) |
protected IRouter<R,W> |
getRouter() |
protected IServer |
getServer() |
protected ISpincastConfig |
getSpincastConfig() |
protected ISpincastDictionary |
getSpincastDictionary() |
protected SpincastRequestScope |
getSpincastRequestScope() |
protected IXmlManager |
getXmlManager() |
void |
handle(Object exchange)
Front controller's handle() method, called by the HTTP
server.
|
protected void |
lastResortExceptionHandling(Throwable originalException,
Throwable defaultHandlingException)
Called when the default exception handler itself throws
an exception...
|
protected void |
manageForwardRouteException(ForwardRouteException ex,
R context,
IRoutingResult<R> originalRoutingResult)
Manage a ForwardRouteException exception.
|
protected void |
manageRedirectException(RedirectException ex,
R context,
IRoutingResult<R> routingResult)
Manage a RedirectException exception.
|
protected IRoutingResult<R> |
prepareNotFoundRouting(Object exchange,
R requestContext)
Prepares a direct Not Found routing.
|
protected IRoutingResult<R> |
prepareNotFoundRouting(Object exchange,
R requestContext,
boolean alreadyTried)
Prepares a direct Not Found routing.
|
protected void |
resetResponse(R requestContext) |
protected void |
sendErrorUsingBestMatchContentType(Object exchange,
String errorMessage,
Integer statusCode)
Send an error to the client.
|
protected Object |
validateExchange(Object exchange)
Validate/modify the exchange before the handling.
|
@Inject public SpincastFrontController(IRouter<R,W> router, ISpincastConfig spincastConfig, ISpincastDictionary spincastDictionary, IServer server, IRequestContextFactory<R> requestCreationFactory, SpincastRequestScope spincastRequestScope, Type requestContextType, IJsonManager jsonManager, IXmlManager xmlManager)
protected ISpincastConfig getSpincastConfig()
protected ISpincastDictionary getSpincastDictionary()
protected IServer getServer()
protected IRequestContextFactory<R> getRequestContextFactory()
protected SpincastRequestScope getSpincastRequestScope()
protected Type getRequestContextType()
protected IJsonManager getJsonManager()
protected IXmlManager getXmlManager()
public void handle(Object exchange)
handle in interface IFrontControllerexchange - an object representing the current request,
provided by the HTTP serverprotected IRoutingResult<R> prepareNotFoundRouting(Object exchange, R requestContext)
protected IRoutingResult<R> prepareNotFoundRouting(Object exchange, R requestContext, boolean alreadyTried)
protected void addDefaultNotFoundRoute()
protected IHandler<R> getDefaultNotFoundHandler()
protected String getDefaultNotFoundHandlerNotFoundMessage()
protected void resetResponse(R requestContext)
protected void customExceptionHandling(Throwable ex, R requestContext, IRoutingResult<R> originalRoutingResult) throws Throwable
Throwableprotected void addDependenciesInCustomRequestScope(R requestContext)
protected void addRequestContextInCustomRequestScope(R requestContext)
protected void callRouteHandlers(R requestContext, IRoutingResult<R> routingResult) throws Exception
Exceptionprotected void manageRedirectException(RedirectException ex, R context, IRoutingResult<R> routingResult)
protected void manageForwardRouteException(ForwardRouteException ex, R context, IRoutingResult<R> originalRoutingResult) throws Exception
Exceptionprotected R createForwardedRequestContext(R context, String fullUrlOrRelativePathAndQueryString)
protected Object validateExchange(Object exchange)
protected IRoutingResult<R> findRouteMatch(R requestContext)
protected void defaultExceptionHandling(Object exchange, Throwable ex) throws Throwable
Throwableprotected void defaultPublicExceptionHandling(Object exchange, IPublicException publicException) throws Throwable
Throwableprotected void defaultPrivateExceptionHandling(Object exchange, Throwable exception) throws Throwable
Throwableprotected void sendErrorUsingBestMatchContentType(Object exchange, String errorMessage, Integer statusCode) throws Throwable
Throwableprotected String getDefaultExceptionHandlingCharset()
protected ContentTypeDefaults getResponseContentTypeToUse(Object exchange)
Copyright © 2016. All rights reserved.