Package org.jboss.resteasy.core

## Class ResourceMethodRegistry

- java.lang.Object
- - org.jboss.resteasy.core.ResourceMethodRegistry

- All Implemented Interfaces:
    `Registry`

      public class ResourceMethodRegistry
      extends Object
      implements Registry

  Registry of resources and methods/classes that can dispatch HTTP method requests.
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected ResteasyProviderFactory` | `providerFactory` |
    `static String` | `REGISTRY_MATCHING_EXCEPTION` |
    `protected ResourceBuilder` | `resourceBuilder` |
    `protected RootClassNode` | `root` |
    `protected RootNode` | `rootNode` |
    `protected StatisticsController` | `statisticsController` |
    `protected boolean` | `widerMatching` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ResourceMethodRegistry​(ResteasyProviderFactory providerFactory)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addJndiResource​(String jndiName)` | Add a JAX-RS endpoint that exists in JNDI.
    `void` | `addJndiResource​(String jndiName, String basePath)` | Add a JAX-RS endpoint that exists in JNDI.
    `void` | `addJndiResource​(String jndiName, ResourceClass resourceClass)` |
    `void` | `addJndiResource​(String jndiName, ResourceClass resourceClass, String basePath)` |
    `void` | `addPerRequestResource​(Class clazz)` | Register a vanilla JAX-RS resource class.
    `void` | `addPerRequestResource​(Class<?> clazz, ResourceBuilder resourceBuilder)` |
    `void` | `addPerRequestResource​(Class clazz, String basePath)` | Add a JAX-RS endpoint.
    `void` | `addPerRequestResource​(ResourceClass clazz)` |
    `void` | `addPerRequestResource​(ResourceClass clazz, String basePath)` |
    `void` | `addResourceFactory​(ResourceFactory ref)` | Bind an endpoint ResourceFactory.
    `void` | `addResourceFactory​(ResourceFactory ref, String base)` | ResourceFactory.getScannableClass() defines what class should be scanned for JAX-RS annotations.
    `void` | `addResourceFactory​(ResourceFactory ref, String base, Class<?> clazz)` | ResourceFactory.getScannableClass() is not used, only the clazz parameter and not any implemented interfaces of the clazz parameter.
    `void` | `addResourceFactory​(ResourceFactory ref, String base, Class<?>[] classes)` | ResourceFactory.getScannableClass() is not used, only the clazz parameter and not any implemented interfaces of the clazz parameter.
    `void` | `addResourceFactory​(ResourceFactory rf, String base, ResourceClass resourceClass)` |
    `void` | `addResourceFactory​(ResourceFactory ref, ResourceBuilder resourceBuilder)` |
    `void` | `addResourceFactory​(ResourceFactory ref, ResourceBuilder resourceBuilder, String base)` |
    `void` | `addResourceFactory​(ResourceFactory ref, ResourceBuilder resourceBuilder, String base, Class<?> clazz)` |
    `void` | `addResourceFactory​(ResourceFactory ref, ResourceBuilder resourceBuilder, String base, Class<?>[] classes)` |
    `void` | `addSingletonResource​(Object singleton)` | Add a JAX-RS endpoint.
    `void` | `addSingletonResource​(Object singleton, String basePath)` | Add a JAX-RS endpoint.
    `void` | `addSingletonResource​(Object singleton, ResourceClass resourceClass)` |
    `void` | `addSingletonResource​(Object singleton, ResourceClass resourceClass, String basePath)` |
    `void` | `checkAmbiguousUri()` | Resteasy 2.x does not properly handle sub-resource and sub-resource locator endpoints with the same uri.
    `Map<String,​List<ResourceInvoker>>` | `getBounded()` |
    `ResourceInvoker` | `getResourceInvoker​(HttpRequest request)` | Find a resource to invoke on.
    `int` | `getSize()` | Number of endpoints registered.
    `boolean` | `isWiderMatching()` |
    `protected void` | `processMethod​(ResourceFactory rf, String base, ResourceLocator method)` |
    `protected void` | `register​(ResourceFactory rf, String base, ResourceClass resourceClass)` |
    `void` | `removeRegistrations​(Class clazz)` | Find all endpoints reachable by clazz and unregister them.
    `void` | `removeRegistrations​(Class clazz, String base)` |
    `void` | `removeRegistrations​(ResourceClass resourceClass)` |
    `void` | `setWiderMatching​(boolean widerMatching)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### REGISTRY_MATCHING_EXCEPTION

          public static final String REGISTRY_MATCHING_EXCEPTION

      See Also:
        Constant Field Values

    - #### providerFactory

          protected ResteasyProviderFactory providerFactory

    - #### root

          protected RootClassNode root

    - #### widerMatching

          protected boolean widerMatching

    - #### rootNode

          protected RootNode rootNode

    - #### resourceBuilder

          protected ResourceBuilder resourceBuilder

    - #### statisticsController

          protected StatisticsController statisticsController

  - ### Constructor Detail

    - #### ResourceMethodRegistry

          public ResourceMethodRegistry​(ResteasyProviderFactory providerFactory)

  - ### Method Detail

    - #### isWiderMatching

          public boolean isWiderMatching()

    - #### setWiderMatching

          public void setWiderMatching​(boolean widerMatching)

    - #### addPerRequestResource

          public void addPerRequestResource​(Class clazz,
                                            String basePath)

      Description copied from interface: `Registry`
      Add a JAX-RS endpoint. Objects of clazz will be created and destroy and the beginning/end of every request.
      Specified by:
        `addPerRequestResource` in interface `Registry`
      Parameters:
        `clazz` - class
        `basePath` - prefix path of resource

    - #### addPerRequestResource

          public void addPerRequestResource​(Class clazz)

      Register a vanilla JAX-RS resource class.
      Specified by:
        `addPerRequestResource` in interface `Registry`
      Parameters:
        `clazz` - class

    - #### addPerRequestResource

          public void addPerRequestResource​(Class<?> clazz,
                                            ResourceBuilder resourceBuilder)

      Specified by:
        `addPerRequestResource` in interface `Registry`

    - #### addPerRequestResource

          public void addPerRequestResource​(ResourceClass clazz)

      Specified by:
        `addPerRequestResource` in interface `Registry`

    - #### addPerRequestResource

          public void addPerRequestResource​(ResourceClass clazz,
                                            String basePath)

      Specified by:
        `addPerRequestResource` in interface `Registry`

    - #### addSingletonResource

          public void addSingletonResource​(Object singleton)

      Description copied from interface: `Registry`
      Add a JAX-RS endpoint.
      Specified by:
        `addSingletonResource` in interface `Registry`
      Parameters:
        `singleton` - resource

    - #### addSingletonResource

          public void addSingletonResource​(Object singleton,
                                           String basePath)

      Description copied from interface: `Registry`
      Add a JAX-RS endpoint.
      Specified by:
        `addSingletonResource` in interface `Registry`
      Parameters:
        `singleton` - resource
        `basePath` - prefix path of resource

    - #### addSingletonResource

          public void addSingletonResource​(Object singleton,
                                           ResourceClass resourceClass)

      Specified by:
        `addSingletonResource` in interface `Registry`

    - #### addSingletonResource

          public void addSingletonResource​(Object singleton,
                                           ResourceClass resourceClass,
                                           String basePath)

      Specified by:
        `addSingletonResource` in interface `Registry`

    - #### addJndiResource

          public void addJndiResource​(String jndiName)

      Description copied from interface: `Registry`
      Add a JAX-RS endpoint that exists in JNDI.
      Specified by:
        `addJndiResource` in interface `Registry`
      Parameters:
        `jndiName` - JNDI name

    - #### addJndiResource

          public void addJndiResource​(String jndiName,
                                      String basePath)

      Description copied from interface: `Registry`
      Add a JAX-RS endpoint that exists in JNDI.
      Specified by:
        `addJndiResource` in interface `Registry`
      Parameters:
        `jndiName` - JNDI name
        `basePath` - prefix path of resource

    - #### addJndiResource

          public void addJndiResource​(String jndiName,
                                      ResourceClass resourceClass)

      Specified by:
        `addJndiResource` in interface `Registry`

    - #### addJndiResource

          public void addJndiResource​(String jndiName,
                                      ResourceClass resourceClass,
                                      String basePath)

      Specified by:
        `addJndiResource` in interface `Registry`

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref)

      Bind an endpoint ResourceFactory. ResourceFactory.getScannableClass() defines what class should be scanned for JAX-RS annotations. The class and any implemented interfaces are scanned for annotations.
      Specified by:
        `addResourceFactory` in interface `Registry`
      Parameters:
        `ref` - resource factory

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         ResourceBuilder resourceBuilder)

      Specified by:
        `addResourceFactory` in interface `Registry`

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         String base)

      ResourceFactory.getScannableClass() defines what class should be scanned for JAX-RS annotations. The class and any implemented interfaces are scanned for annotations.
      Specified by:
        `addResourceFactory` in interface `Registry`
      Parameters:
        `ref` - resource factory
        `base` - base URI path for any resources provided by the factory, in addition to rootPath

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         ResourceBuilder resourceBuilder,
                                         String base)

      Specified by:
        `addResourceFactory` in interface `Registry`

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         String base,
                                         Class<?> clazz)

      ResourceFactory.getScannableClass() is not used, only the clazz parameter and not any implemented interfaces of the clazz parameter.
      Specified by:
        `addResourceFactory` in interface `Registry`
      Parameters:
        `ref` - resource factory
        `base` - base URI path for any resources provided by the factory, in addition to rootPath
        `clazz` - specific class

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         ResourceBuilder resourceBuilder,
                                         String base,
                                         Class<?> clazz)

      Specified by:
        `addResourceFactory` in interface `Registry`

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         String base,
                                         Class<?>[] classes)

      ResourceFactory.getScannableClass() is not used, only the clazz parameter and not any implemented interfaces of the clazz parameter.
      Specified by:
        `addResourceFactory` in interface `Registry`
      Parameters:
        `ref` - resource factory
        `base` - base URI path for any resources provided by the factory, in addition to rootPath
        `classes` - specific class

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory ref,
                                         ResourceBuilder resourceBuilder,
                                         String base,
                                         Class<?>[] classes)

      Specified by:
        `addResourceFactory` in interface `Registry`

    - #### addResourceFactory

          public void addResourceFactory​(ResourceFactory rf,
                                         String base,
                                         ResourceClass resourceClass)

      Specified by:
        `addResourceFactory` in interface `Registry`

    - #### register

          protected void register​(ResourceFactory rf,
                                  String base,
                                  ResourceClass resourceClass)

    - #### checkAmbiguousUri

          public void checkAmbiguousUri()

      Resteasy 2.x does not properly handle sub-resource and sub-resource locator endpoints with the same uri. Resteasy 3.x does handle this properly. In assisting customers identify this issue during an upgrade from Resteasy 2 to 3 provides a waring when the situation is found.
      Specified by:
        `checkAmbiguousUri` in interface `Registry`

    - #### processMethod

          protected void processMethod​(ResourceFactory rf,
                                       String base,
                                       ResourceLocator method)

    - #### removeRegistrations

          public void removeRegistrations​(Class clazz)

      Find all endpoints reachable by clazz and unregister them.
      Specified by:
        `removeRegistrations` in interface `Registry`
      Parameters:
        `clazz` - class

    - #### removeRegistrations

          public void removeRegistrations​(Class clazz,
                                          String base)

      Specified by:
        `removeRegistrations` in interface `Registry`

    - #### removeRegistrations

          public void removeRegistrations​(ResourceClass resourceClass)

      Specified by:
        `removeRegistrations` in interface `Registry`

    - #### getBounded

          public Map<String,​List<ResourceInvoker>> getBounded()

    - #### getSize

          public int getSize()

      Number of endpoints registered.
      Specified by:
        `getSize` in interface `Registry`
      Returns:
        number of endpoints registered

    - #### getResourceInvoker

          public ResourceInvoker getResourceInvoker​(HttpRequest request)

      Find a resource to invoke on.
      Specified by:
        `getResourceInvoker` in interface `Registry`
      Returns:
        resource invoker