|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.faces.context.ExceptionHandler
public abstract class ExceptionHandler
ExceptionHandler is the
central point for handling unexpected
Exception
s that are thrown during the Faces
lifecycle. The ExceptionHandler
must not be notified of
any Exception
s that occur during application startup or
shutdown.
See the specification prose document for the requirements for the
default implementation. Exception
s may be passed to the
ExceptionHandler
in one of two ways:
by ensuring that Exception
s are not caught, or
are caught and re-thrown.
This approach allows the ExceptionHandler
facility specified in section 12.3 to operate on the
Exception
.
By using the system event facility to publish an ExceptionEvent
that wraps the Exception
.
This approach requires manually publishing the ExceptionEvent
, but allows more information about the
Exception
to be stored in the event. The
following code is an example of how to do this.
//...
} catch (Exception e) {
FacesContext ctx = FacesContext.getCurrentInstance();
ExceptionEventContext eventContext = new ExceptionEventContext(ctx, e);
eventContext.getAttributes().put("key", "value");
ctx.getApplication().publishEvent(ExceptionEvent.class, eventContext);
}
Because the Exception
must not be re-thrown
when using this approach, lifecycle processing may continue
as normal, allowing more Exception
s to be
published if necessary.
With either approach, any ExceptionEvent
instances
that are published in this way are accessible to the handle()
method, which is called at the end of each lifecycle phase, as
specified in section 12.3.
Instances of this class are request scoped and are created by
virtue of FacesContextFactory.getFacesContext(java.lang.Object, java.lang.Object, java.lang.Object, javax.faces.lifecycle.Lifecycle)
calling ExceptionHandlerFactory.getExceptionHandler()
.
Constructor Summary | |
---|---|
ExceptionHandler()
|
Method Summary | |
---|---|
abstract ExceptionEvent |
getHandledExceptionEvent()
Return the first
|
abstract Iterable<ExceptionEvent> |
getHandledExceptionEvents()
The default implementation must
return an |
abstract Throwable |
getRootCause(Throwable t)
Unwrap the argument |
abstract Iterable<ExceptionEvent> |
getUnhandledExceptionEvents()
Return an |
abstract void |
handle()
Take action to handle the
|
abstract boolean |
isListenerForSource(Object source)
This method must return |
abstract void |
processEvent(SystemEvent exceptionEvent)
When called, the listener can assume that any guarantees given
in the javadoc for the specific |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExceptionHandler()
Method Detail |
---|
public abstract void handle() throws FacesException
Take action to handle the
Exception
instances residing inside the ExceptionEvent
instances that have been queued by calls to
Application().publishEvent(ExceptionEvent.class,
eventContext)
. The requirements of the default
implementation are detailed in section 6.2.1.
FacesException
- if and only if a problem occurs while
performing the algorithm to handle the Exception
, not
as a means of conveying a handled Exception
itself.public abstract ExceptionEvent getHandledExceptionEvent()
Return the first
ExceptionEvent
handled by this handler.
public abstract Iterable<ExceptionEvent> getUnhandledExceptionEvents()
Return an Iterable
over
all ExceptionEvent
s that have not yet been handled
by the handle()
method.
public abstract Iterable<ExceptionEvent> getHandledExceptionEvents()
The default implementation must
return an Iterable
over all
ExceptionEvent
s that have been handled by the handle()
method.
public abstract void processEvent(SystemEvent exceptionEvent) throws AbortProcessingException
When called, the listener can assume that any guarantees given
in the javadoc for the specific SystemEvent
subclass are true.
processEvent
in interface SystemEventListener
exceptionEvent
- the SystemEvent
instance that
is being processed.
AbortProcessingException
- if lifecycle processing should
cease for this request.public abstract boolean isListenerForSource(Object source)
This method must return true
if and only if this
listener instance is interested in receiving events from the
instance referenced by the source
parameter.
isListenerForSource
in interface SystemEventListener
source
- the source that is inquiring about the
appropriateness of sending an event to this listener instance.public abstract Throwable getRootCause(Throwable t)
Unwrap the argument t
until the unwrapping encounters an Object whose
getClass()
is not equal to
FacesException.class
or
javax.el.ELException.class
. If there is no root cause, null
is returned.
NullPointerException
- if argument t
is
null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |