org.jboss.seam.rest.exceptions
Class SeamExceptionMapper

java.lang.Object
  extended by org.jboss.seam.rest.exceptions.SeamExceptionMapper
All Implemented Interfaces:
ExceptionMapper<Throwable>
Direct Known Subclasses:
CatchExceptionMapper

@Provider
@ApplicationScoped
public class SeamExceptionMapper
extends Object
implements ExceptionMapper<Throwable>

This ExceptionMapper implementation converts caught exceptions to HTTP responses based on exception mapping rules.

If there is no matching rule for an exception, the exception is rethrown wrapped within UnhandledException. Note that this implementation is replaced by CatchExceptionMapper in environments where Seam Catch is available.

Author:
Jozef Hartinger
See Also:
ExceptionMappingConfiguration

Constructor Summary
SeamExceptionMapper()
           
 
Method Summary
protected  void addExceptionMapping(Mapping mapping)
           
protected  Object createEntityBody(Mapping mapping, String message)
           
protected  String createMessage(String message, boolean interpolate, boolean useExceptionMessage, Throwable e, Interpolator interpolator)
           
 Map<Class<? extends Throwable>,Mapping> getMappings()
           
 void init(Instance<SeamRestConfiguration> configuration, ExceptionMappingExtension extension)
          Mappings are stored in a Map so that we can find them by the exception type.
 void init(ServletContext ctx)
          This observer method triggers #init(ExceptionMappingConfiguration) on bootstrap.
protected  void produceResponse(Throwable exception, Response.ResponseBuilder builder, Interpolator interpolator)
           
 Response toResponse(Throwable e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeamExceptionMapper

public SeamExceptionMapper()
Method Detail

init

@Inject
public void init(Instance<SeamRestConfiguration> configuration,
                        ExceptionMappingExtension extension)
Mappings are stored in a Map so that we can find them by the exception type.


addExceptionMapping

protected void addExceptionMapping(Mapping mapping)

init

public void init(@Observes@RestResource
                 ServletContext ctx)
This observer method triggers #init(ExceptionMappingConfiguration) on bootstrap.


toResponse

public Response toResponse(Throwable e)
Specified by:
toResponse in interface ExceptionMapper<Throwable>

produceResponse

protected void produceResponse(Throwable exception,
                               Response.ResponseBuilder builder,
                               Interpolator interpolator)

createMessage

protected String createMessage(String message,
                               boolean interpolate,
                               boolean useExceptionMessage,
                               Throwable e,
                               Interpolator interpolator)

createEntityBody

protected Object createEntityBody(Mapping mapping,
                                  String message)

getMappings

public Map<Class<? extends Throwable>,Mapping> getMappings()


Copyright © 2011 Seam Framework. All Rights Reserved.