Class AbstractResourceDescriptorImpl

java.lang.Object
org.exoplatform.services.rest.BaseObjectModel
org.exoplatform.services.rest.impl.resource.AbstractResourceDescriptorImpl
All Implemented Interfaces:
ObjectModel, AbstractResourceDescriptor, ResourceDescriptor
Direct Known Subclasses:
ApplicationResource

public class AbstractResourceDescriptorImpl extends BaseObjectModel implements AbstractResourceDescriptor
Version:
$Id: $
Author:
Andrey Parfonov
  • Constructor Details

    • AbstractResourceDescriptorImpl

      public AbstractResourceDescriptorImpl(Class<?> resourceClass, ComponentLifecycleScope scope)
    • AbstractResourceDescriptorImpl

      public AbstractResourceDescriptorImpl(Class<?> resourceClass, MethodInvokerFactory invokerFactory)
      Constructs new instance of AbstractResourceDescriptor.
      Parameters:
      resourceClass - resource class
      invokerFactory - invoker factory
    • AbstractResourceDescriptorImpl

      public AbstractResourceDescriptorImpl(Object resource, MethodInvokerFactory invokerFactory)
      Constructs new instance of AbstractResourceDescriptor.
      Parameters:
      resource - resource instance
      invokerFactory - invoker factory
    • AbstractResourceDescriptorImpl

      public AbstractResourceDescriptorImpl(Class<?> resourceClass)
      Constructs new instance of AbstractResourceDescriptor.
      Parameters:
      resourceClass - resource class
    • AbstractResourceDescriptorImpl

      public AbstractResourceDescriptorImpl(Object resource)
      Constructs new instance of AbstractResourceDescriptor.
      Parameters:
      resource - resource instance
  • Method Details

    • accept

      public void accept(ResourceDescriptorVisitor visitor)
      Method is useful for validation.
      Specified by:
      accept in interface ResourceDescriptor
      Parameters:
      visitor - See ResourceDescriptorVisitor
    • getPathValue

      public PathValue getPathValue()
      Specified by:
      getPathValue in interface AbstractResourceDescriptor
      Returns:
      See PathValue
    • getResourceMethods

      public ResourceMethodMap<ResourceMethodDescriptor> getResourceMethods()
      Specified by:
      getResourceMethods in interface AbstractResourceDescriptor
      Returns:
      resource methods
      See Also:
    • getSubResourceLocators

      public SubResourceLocatorMap getSubResourceLocators()
      Specified by:
      getSubResourceLocators in interface AbstractResourceDescriptor
      Returns:
      sub-resource locators
      See Also:
    • getSubResourceMethods

      public SubResourceMethodMap getSubResourceMethods()
      Specified by:
      getSubResourceMethods in interface AbstractResourceDescriptor
      Returns:
      sub-resource methods
      See Also:
    • getUriPattern

      public UriPattern getUriPattern()
      Specified by:
      getUriPattern in interface AbstractResourceDescriptor
      Returns:
      See UriPattern
    • isRootResource

      public boolean isRootResource()
      Specified by:
      isRootResource in interface AbstractResourceDescriptor
      Returns:
      true if resource is root resource false otherwise. Root resource is class which has own Path annotation
    • processMethods

      protected void processMethods()
      Process method of resource and separate them to three types Resource Methods, Sub-Resource Methods and Sub-Resource Locators.
    • createMethodParametersList

      protected List<MethodParameter> createMethodParametersList(Class<?> resourceClass, Method method)
      Create list of MethodParameter .
      Parameters:
      resourceClass - class
      method - See Method
      Returns:
      list of MethodParameter
    • resolveHeadRequest

      protected void resolveHeadRequest()
      According to JSR-311:

      On receipt of a HEAD request an implementation MUST either: 1. Call method annotated with request method designation for HEAD or, if none present, 2. Call method annotated with a request method designation GET and discard any returned entity.

    • resolveOptionsRequest

      protected void resolveOptionsRequest()
      According to JSR-311:

      On receipt of a OPTIONS request an implementation MUST either: 1. Call method annotated with request method designation for OPTIONS or, if none present, 2. Generate an automatic response using the metadata provided by the JAX-RS annotations on the matching class and its methods.

    • getMetaAnnotation

      protected <T extends Annotation> T getMetaAnnotation(Method m, Class<T> annotation)
      Get all method with at least one annotation which has annotation annotation. It is useful for annotation GET, etc. All HTTP method annotations has annotation HttpMethod.
      Type Parameters:
      T - annotation type
      Parameters:
      m - method
      annotation - annotation class
      Returns:
      list of annotation
    • getMethodAnnotation

      protected <T extends Annotation> T getMethodAnnotation(Method method, Class<?> resourceClass, Class<T> annotationClass, boolean metaAnnotation)
      Tries to get JAX-RS annotation on method from the root resource class's superclass or implemented interfaces.
      Type Parameters:
      T - annotation type
      Parameters:
      method - method for discovering
      resourceClass - class that contains discovered method
      annotationClass - annotation type what we are looking for
      metaAnnotation - false if annotation should be on method and true in method should contain annotations that has supplied annotation
      Returns:
      annotation from class or its ancestor or null if nothing found
    • findMethodResourceMediaType

      protected <T extends ResourceMethodDescriptor> ResourceMethodDescriptor findMethodResourceMediaType(List<T> rmds, List<javax.ws.rs.core.MediaType> consumes, List<javax.ws.rs.core.MediaType> produces)
      Check is collection of ResourceMethodDescriptor already contains ResourceMethodDescriptor with the same media types.
      Parameters:
      rmds - Set of ResourceMethodDescriptor
      consumes - resource method consumed media type
      produces - resource method produced media type
      Returns:
      ResourceMethodDescriptor or null if nothing found
    • getMethodInvoker

      protected MethodInvoker getMethodInvoker()
    • toString

      public String toString()
      Overrides:
      toString in class Object