org.glassfish.jersey.server.mvc.spi
Class AbstractErrorTemplateMapper<T extends Throwable>

java.lang.Object
  extended by org.glassfish.jersey.server.mvc.spi.AbstractErrorTemplateMapper<T>
Type Parameters:
T - A type of the exception processed by the exception mapper.
All Implemented Interfaces:
javax.ws.rs.ext.ExceptionMapper<T>, org.glassfish.jersey.spi.ExtendedExceptionMapper<T>
Direct Known Subclasses:
ErrorTemplateExceptionMapper

@Singleton
public abstract class AbstractErrorTemplateMapper<T extends Throwable>
extends Object
implements org.glassfish.jersey.spi.ExtendedExceptionMapper<T>

Default implementation of ExtendedExceptionMapper used to declare special handling for exception types that should be processed by MVC.

Extensions should override getErrorStatus(Throwable) and getErrorModel(Throwable) to provide a response status and model derived from a raised throwable.

By default every exception is mapped and used as a model in a viewable and passed to the MVC runtime for further processing.

Since:
2.3
Author:
Michal Gajdos (michal.gajdos at oracle.com)

Constructor Summary
AbstractErrorTemplateMapper()
           
 
Method Summary
protected  Object getErrorModel(T throwable)
          Get a model for error template.
protected  javax.ws.rs.core.Response.Status getErrorStatus(T throwable)
          Get a response status of to-be-processed error template.
 boolean isMappable(T throwable)
           
 javax.ws.rs.core.Response toResponse(T throwable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractErrorTemplateMapper

public AbstractErrorTemplateMapper()
Method Detail

isMappable

public final boolean isMappable(T throwable)
Specified by:
isMappable in interface org.glassfish.jersey.spi.ExtendedExceptionMapper<T extends Throwable>

toResponse

public final javax.ws.rs.core.Response toResponse(T throwable)
Specified by:
toResponse in interface javax.ws.rs.ext.ExceptionMapper<T extends Throwable>

getErrorModel

protected Object getErrorModel(T throwable)
Get a model for error template. Default value is the throwable itself.

Parameters:
throwable - throwable raised during processing a resource method.
Returns:
a model for error template.

getErrorStatus

protected javax.ws.rs.core.Response.Status getErrorStatus(T throwable)
Get a response status of to-be-processed error template. Default value is Response.Status#OK.

Parameters:
throwable - throwable raised during processing a resource method.
Returns:
response status of error response.


Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.