Class ExceptionMapperFactory

java.lang.Object
org.glassfish.jersey.internal.ExceptionMapperFactory
All Implemented Interfaces:
ExceptionMappers

public class ExceptionMapperFactory extends Object implements ExceptionMappers
Exception mappers implementation that aggregates exception mappers and server as the main entry point for exception mapper instance lookup.
Author:
Paul Sandoz, Santiago Pericas-Geertsen (Santiago.PericasGeertsen at oracle.com), Marek Potociar (marek.potociar at oracle.com), Jakub Podlesak (jakub.podlesak at oracle.com)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Configurator which initializes and register ExceptionMappers instance into InjectionManager and BootstrapBag.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ExceptionMapperFactory(org.glassfish.jersey.internal.inject.InjectionManager injectionManager)
    Create new exception mapper factory initialized with injection manager instance that will be used to look up all providers implementing ExceptionMapper interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Throwable>
    javax.ws.rs.ext.ExceptionMapper<T>
    find(Class<T> type)
    Get an exception mapping provider for a particular class of exception.
    <T extends Throwable>
    javax.ws.rs.ext.ExceptionMapper<T>
    findMapping(T exceptionInstance)
    Get an exception mapping provider for a particular exception instance.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ExceptionMapperFactory

      public ExceptionMapperFactory(org.glassfish.jersey.internal.inject.InjectionManager injectionManager)
      Create new exception mapper factory initialized with injection manager instance that will be used to look up all providers implementing ExceptionMapper interface.
      Parameters:
      injectionManager - injection manager.
  • Method Details

    • findMapping

      public <T extends Throwable> javax.ws.rs.ext.ExceptionMapper<T> findMapping(T exceptionInstance)
      Description copied from interface: ExceptionMappers
      Get an exception mapping provider for a particular exception instance.

      This method is similar to method ExceptionMappers.find(Class). In addition it takes into an account the result of the ExtendedExceptionMapper.isMappable(Throwable) of any mapper that implements Jersey ExtendedExceptionMapper API. If an extended exception mapper returns false from isMappable(Throwable), the mapper is disregarded from the search. Exception mapping providers are checked one by one until a first provider returns true from the isMappable(Throwable) method or until a first provider is found which best supports the exception type and does not implement ExtendedExceptionMapper API (i.e. it is a standard JAX-RS ExceptionMapper). The order in which the providers are checked is determined by the distance of the declared exception mapper type and the actual exception type.

      Note that if an exception mapping provider does not implement ExtendedExceptionMapper it is always considered applicable for a given exception instance.

      Specified by:
      findMapping in interface ExceptionMappers
      Type Parameters:
      T - type of the exception handled by the exception mapping provider.
      Parameters:
      exceptionInstance - exception to be handled by the exception mapping provider.
      Returns:
      an ExceptionMapper for the supplied exception instance type or null if none is found.
    • find

      public <T extends Throwable> javax.ws.rs.ext.ExceptionMapper<T> find(Class<T> type)
      Description copied from interface: ExceptionMappers
      Get an exception mapping provider for a particular class of exception. Returns the provider whose generic type is the nearest superclass of type.
      Specified by:
      find in interface ExceptionMappers
      Type Parameters:
      T - type of the exception handled by the exception mapping provider.
      Parameters:
      type - the class of exception.
      Returns:
      an ExceptionMapper for the supplied type or null if none is found.