aerogear-controller 1.0.1

org.jboss.aerogear.controller.router.decorators
Class ErrorHandler

java.lang.Object
  extended by org.jboss.aerogear.controller.router.decorators.ErrorHandler
All Implemented Interfaces:
RouteProcessor

@Decorator
public class ErrorHandler
extends Object
implements RouteProcessor

ErrorHandler is a CDI Decorator that decorates a RouteProcessor.

By wrapping the call to RouteProcessor.process(RouteContext) with a try catch block, this class will handle any exception thrown and either forward to a the appropriate error route configured, or if no error route exists, forward to the default error view.


Field Summary
private  RouteProcessor delegate
           
private  EndpointInvoker endpointInvoker
           
 
Constructor Summary
ErrorHandler(RouteProcessor delegate, EndpointInvoker endpointInvoker)
           
 
Method Summary
private  String appendAnyMediaTypeToAcceptHeader(javax.servlet.http.HttpServletRequest request)
           
private  RouteContext errorContext(Throwable rootCause, RouteContext orgContext)
           
private  Object[] getMethodArguments(RouteContext routeContext, Throwable t)
           
private  Object invokeErrorMethod(RouteContext errorContext, Throwable rootCause)
           
 InvocationResult process(RouteContext routeContext)
          Handles the actual invocation of the target or the passed-in Route.
private  javax.servlet.http.HttpServletRequest wrapRequest(RouteContext routeContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

private final RouteProcessor delegate

endpointInvoker

private EndpointInvoker endpointInvoker
Constructor Detail

ErrorHandler

@Inject
public ErrorHandler(@Delegate
                           RouteProcessor delegate,
                           EndpointInvoker endpointInvoker)
Method Detail

process

public InvocationResult process(RouteContext routeContext)
                         throws Exception
Description copied from interface: RouteProcessor
Handles the actual invocation of the target or the passed-in Route.

Specified by:
process in interface RouteProcessor
Parameters:
routeContext - the RouteContext for the current request.
Throws:
Exception - if processing of the route causes an exception.

invokeErrorMethod

private Object invokeErrorMethod(RouteContext errorContext,
                                 Throwable rootCause)
                          throws Exception
Throws:
Exception

getMethodArguments

private Object[] getMethodArguments(RouteContext routeContext,
                                    Throwable t)

errorContext

private RouteContext errorContext(Throwable rootCause,
                                  RouteContext orgContext)

wrapRequest

private javax.servlet.http.HttpServletRequest wrapRequest(RouteContext routeContext)

appendAnyMediaTypeToAcceptHeader

private String appendAnyMediaTypeToAcceptHeader(javax.servlet.http.HttpServletRequest request)

aerogear-controller 1.0.1

Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.