public.javadoc.org.spincast.core.controllers.SpincastFrontController.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
SpincastFrontController (org.spincast:spincast-framework 1.0.0 API)
org.spincast.core.controllers
Class SpincastFrontController<R extends RequestContext<R>,W extends WebsocketContext<?>>
- java.lang.Object
-
- org.spincast.core.controllers.SpincastFrontController<R,W>
-
- All Implemented Interfaces:
- FrontController
public class SpincastFrontController<R extends RequestContext<R>,W extends WebsocketContext<?>>
extends Object
implements FrontController
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
SpincastFrontController(Router<R,W> router,
SpincastConfig spincastConfig,
Dictionary dictionary,
Server server,
RequestContextFactory<R> requestCreationFactory,
SpincastRequestScope spincastRequestScope,
Type requestContextType,
JsonManager jsonManager,
XmlManager xmlManager)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods
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 objects in the cutom request scope
protected void
callRouteHandlers(R requestContext,
RoutingResult<R> routingResult)
Call the handlers, in order they are specified.
protected R
createForwardedRequestContext(R context,
String fullUrlOrRelativePathAndQueryString)
protected void
customExceptionHandling(Throwable ex,
R requestContext,
RoutingResult<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,
PublicException publicException)
Default exception handling for exceptions with
public information.
protected RoutingResult<R>
findRouteMatch(R requestContext)
Find the route handlers to call.
protected String
getDefaultExceptionHandlingCharset()
Charset used by the default exception handling.
protected Handler<R>
getDefaultNotFoundHandler()
Create the default Not Found handler
protected String
getDefaultNotFoundHandlerNotFoundMessage()
The message to send for the default Not Found handler.
protected Dictionary
getDictionary()
protected String
getInternalErrorHtmlContent(String errorMessage)
protected String
getInternalErrorJsonContent(String errorMessage)
protected String
getInternalErrorTextContent(String errorMessage)
protected String
getInternalErrorXmlContent(String errorMessage)
protected JsonManager
getJsonManager()
protected String
getNotFoundHtmlContent(String message)
protected String
getNotFoundJsonContent(String message)
protected String
getNotFoundPlainTextContent(String message)
protected String
getNotFoundXmlContent(String message)
protected RequestContextFactory<R>
getRequestContextFactory()
protected Type
getRequestContextType()
protected ContentTypeDefaults
getResponseContentTypeToUse(Object exchange)
protected Router<R,W>
getRouter()
protected Server
getServer()
protected SpincastConfig
getSpincastConfig()
protected SpincastRequestScope
getSpincastRequestScope()
protected XmlManager
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,
RoutingResult<R> originalRoutingResult)
Manage a ForwardRouteException exception.
protected void
manageRedirectException(RedirectException ex,
R context,
RoutingResult<R> routingResult)
Manage a RedirectException exception.
protected RoutingResult<R>
prepareNotFoundRouting(Object exchange,
R requestContext)
Prepares a direct Not Found routing.
protected RoutingResult<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.
-
-
Constructor Detail
-
SpincastFrontController
@Inject
public SpincastFrontController(Router<R,W> router,
SpincastConfig spincastConfig,
Dictionary dictionary,
Server server,
RequestContextFactory<R> requestCreationFactory,
SpincastRequestScope spincastRequestScope,
Type requestContextType,
JsonManager jsonManager,
XmlManager xmlManager)
The constructor.
-
Method Detail
-
getSpincastConfig
protected SpincastConfig getSpincastConfig()
-
getDictionary
protected Dictionary getDictionary()
-
getServer
protected Server getServer()
-
getRequestContextFactory
protected RequestContextFactory<R> getRequestContextFactory()
-
getSpincastRequestScope
protected SpincastRequestScope getSpincastRequestScope()
-
getRequestContextType
protected Type getRequestContextType()
-
getJsonManager
protected JsonManager getJsonManager()
-
getXmlManager
protected XmlManager getXmlManager()
-
handle
public void handle(Object exchange)
Front controller's handle() method, called by the HTTP
server.
- Specified by:
handle
in interface FrontController
- Parameters:
exchange
- an object representing the current request,
provided by the HTTP server
-
prepareNotFoundRouting
protected RoutingResult<R> prepareNotFoundRouting(Object exchange,
R requestContext)
Prepares a direct Not Found routing.
-
prepareNotFoundRouting
protected RoutingResult<R> prepareNotFoundRouting(Object exchange,
R requestContext,
boolean alreadyTried)
Prepares a direct Not Found routing.
-
addDefaultNotFoundRoute
protected void addDefaultNotFoundRoute()
Add the default Not Found route.
-
getDefaultNotFoundHandler
protected Handler<R> getDefaultNotFoundHandler()
Create the default Not Found handler
-
getDefaultNotFoundHandlerNotFoundMessage
protected String getDefaultNotFoundHandlerNotFoundMessage()
The message to send for the default Not Found handler.
-
resetResponse
protected void resetResponse(R requestContext)
-
customExceptionHandling
protected void customExceptionHandling(Throwable ex,
R requestContext,
RoutingResult<R> originalRoutingResult)
throws Throwable
Custom exception handling.
- Throws:
Throwable
-
addDependenciesInCustomRequestScope
protected void addDependenciesInCustomRequestScope(R requestContext)
Add dependencies to the custom request scope
-
addRequestContextInCustomRequestScope
protected void addRequestContextInCustomRequestScope(R requestContext)
Add the request context objects in the cutom request scope
-
callRouteHandlers
protected void callRouteHandlers(R requestContext,
RoutingResult<R> routingResult)
throws Exception
Call the handlers, in order they are specified.
- Throws:
Exception
-
manageRedirectException
protected void manageRedirectException(RedirectException ex,
R context,
RoutingResult<R> routingResult)
Manage a RedirectException exception.
-
manageForwardRouteException
protected void manageForwardRouteException(ForwardRouteException ex,
R context,
RoutingResult<R> originalRoutingResult)
throws Exception
Manage a ForwardRouteException exception.
- Throws:
Exception
-
createForwardedRequestContext
protected R createForwardedRequestContext(R context,
String fullUrlOrRelativePathAndQueryString)
-
validateExchange
protected Object validateExchange(Object exchange)
Validate/modify the exchange before the handling.
-
findRouteMatch
protected RoutingResult<R> findRouteMatch(R requestContext)
Find the route handlers to call.
-
defaultExceptionHandling
protected void defaultExceptionHandling(Object exchange,
Throwable ex)
throws Throwable
Default exception handling.
- Throws:
Throwable
-
defaultPublicExceptionHandling
protected void defaultPublicExceptionHandling(Object exchange,
PublicException publicException)
throws Throwable
Default exception handling for exceptions with
public information.
- Throws:
Throwable
-
defaultPrivateExceptionHandling
protected void defaultPrivateExceptionHandling(Object exchange,
Throwable exception)
throws Throwable
Default exception handling for private exceptions
- Throws:
Throwable
-
sendErrorUsingBestMatchContentType
protected void sendErrorUsingBestMatchContentType(Object exchange,
String errorMessage,
Integer statusCode)
throws Throwable
Send an error to the client.
- Throws:
Throwable
-
getDefaultExceptionHandlingCharset
protected String getDefaultExceptionHandlingCharset()
Charset used by the default exception handling.
-
getResponseContentTypeToUse
protected ContentTypeDefaults getResponseContentTypeToUse(Object exchange)
Copyright © 2019. All rights reserved.