pt.digitalis.dif.controller
Class ExceptionHandlers

java.lang.Object
  extended by pt.digitalis.dif.controller.ExceptionHandlers

public class ExceptionHandlers
extends Object

Exception Handler stages registry class. Allows registering of all stages that declare to handle specific exceptions.

Author:
Pedro Viegas pviegas@digitalis.pt
Created on:
2010/05/04

Field Summary
static String RAISED_EXCEPTION_ATTRIBUTE
          Attribute ID to save the raised exception caught by the exception handler
 
Constructor Summary
ExceptionHandlers()
           
 
Method Summary
static void addExceptionHandler(Class<Throwable> exceptionClass, String stageID)
          Registers a new Exception handler
static void addExceptionHandler(String exceptionClassName, String stageID)
          Registers a new Exception handler
static String getExceptionHandler(Class<? extends Throwable> exceptionClass)
          Gets the ID of the handler stage for the given exception
static String getExceptionHandler(String exceptionClassName)
          Gets the ID of the handler stage for the given exception
static String getExceptionHandler(Throwable exception)
          Gets the ID of the handler stage for the given exception
static void handleException(IDIFContext context, Exception exception)
          Handles redirection actions for a given exsception.
static boolean hasHandler(Class<? extends Throwable> exceptionClass)
          Inspector for a given exception.
static boolean hasHandler(Exception exception)
          Inspector for a given exception.
static boolean hasHandler(String exceptionClassName)
          Inspector for a given exception.
static void removeExceptionHandler(String key)
          Removes a registered exception handler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAISED_EXCEPTION_ATTRIBUTE

public static final String RAISED_EXCEPTION_ATTRIBUTE
Attribute ID to save the raised exception caught by the exception handler

See Also:
Constant Field Values
Constructor Detail

ExceptionHandlers

public ExceptionHandlers()
Method Detail

addExceptionHandler

public static void addExceptionHandler(Class<Throwable> exceptionClass,
                                       String stageID)
Registers a new Exception handler

Parameters:
exceptionClass - the exception class to register
stageID - the ID for the handler stage

addExceptionHandler

public static void addExceptionHandler(String exceptionClassName,
                                       String stageID)
Registers a new Exception handler

Parameters:
exceptionClassName - the exception class name to register
stageID - the ID for the handler stage

getExceptionHandler

public static String getExceptionHandler(Class<? extends Throwable> exceptionClass)
Gets the ID of the handler stage for the given exception

Parameters:
exceptionClass - the class of the exception
Returns:
the handler stage ID

getExceptionHandler

public static String getExceptionHandler(String exceptionClassName)
Gets the ID of the handler stage for the given exception

Parameters:
exceptionClassName - the class name of the exception
Returns:
the handler stage ID

getExceptionHandler

public static String getExceptionHandler(Throwable exception)
Gets the ID of the handler stage for the given exception

Parameters:
exception - the exception
Returns:
the handler stage ID

handleException

public static void handleException(IDIFContext context,
                                   Exception exception)
Handles redirection actions for a given exsception. Will determine the correct handler, add the necessary information to the request and redirect to the handler stage.

Parameters:
context - the current running stage context
exception - the exception raised to handle

hasHandler

public static boolean hasHandler(Class<? extends Throwable> exceptionClass)
Inspector for a given exception. Will determine of the given exception has a handler defined

Parameters:
exceptionClass - the exception class
Returns:
T if the exception has a registered handler

hasHandler

public static boolean hasHandler(Exception exception)
Inspector for a given exception. Will determine of the given exception has a handler defined

Parameters:
exception - the exception
Returns:
T if the exception has a registered handler

hasHandler

public static boolean hasHandler(String exceptionClassName)
Inspector for a given exception. Will determine of the given exception has a handler defined

Parameters:
exceptionClassName - the exception class name
Returns:
T if the exception has a registered handler

removeExceptionHandler

public static void removeExceptionHandler(String key)
Removes a registered exception handler

Parameters:
key -


Copyright © 2014 Digitalis Informática Lda. All Rights Reserved.