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
-
Field Summary
Fields inherited from class org.exoplatform.services.rest.BaseObjectModel
clazz, constructors, fields, properties -
Constructor Summary
ConstructorsConstructorDescriptionAbstractResourceDescriptorImpl(Class<?> resourceClass) Constructs new instance of AbstractResourceDescriptor.AbstractResourceDescriptorImpl(Class<?> resourceClass, ComponentLifecycleScope scope) AbstractResourceDescriptorImpl(Class<?> resourceClass, MethodInvokerFactory invokerFactory) Constructs new instance of AbstractResourceDescriptor.AbstractResourceDescriptorImpl(Object resource) Constructs new instance of AbstractResourceDescriptor.AbstractResourceDescriptorImpl(Object resource, MethodInvokerFactory invokerFactory) Constructs new instance of AbstractResourceDescriptor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(ResourceDescriptorVisitor visitor) Method is useful for validation.protected List<MethodParameter> createMethodParametersList(Class<?> resourceClass, Method method) Create list ofMethodParameter.protected <T extends ResourceMethodDescriptor>
ResourceMethodDescriptorfindMethodResourceMediaType(List<T> rmds, List<javax.ws.rs.core.MediaType> consumes, List<javax.ws.rs.core.MediaType> produces) Check is collection ofResourceMethodDescriptoralready contains ResourceMethodDescriptor with the same media types.protected <T extends Annotation>
TgetMetaAnnotation(Method m, Class<T> annotation) Get all method with at least one annotation which has annotation annotation.protected <T extends Annotation>
TgetMethodAnnotation(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.protected MethodInvokerbooleanprotected voidProcess method of resource and separate them to three types Resource Methods, Sub-Resource Methods and Sub-Resource Locators.protected voidAccording to JSR-311:protected voidAccording to JSR-311:toString()Methods inherited from class org.exoplatform.services.rest.BaseObjectModel
getConstructorDescriptors, getFieldInjectors, getObjectClass, getProperties, getPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.exoplatform.services.rest.ObjectModel
getConstructorDescriptors, getFieldInjectors, getObjectClass, getProperties, getProperty
-
Constructor Details
-
AbstractResourceDescriptorImpl
-
AbstractResourceDescriptorImpl
Constructs new instance of AbstractResourceDescriptor.- Parameters:
resourceClass- resource classinvokerFactory- invoker factory
-
AbstractResourceDescriptorImpl
Constructs new instance of AbstractResourceDescriptor.- Parameters:
resource- resource instanceinvokerFactory- invoker factory
-
AbstractResourceDescriptorImpl
Constructs new instance of AbstractResourceDescriptor.- Parameters:
resourceClass- resource class
-
AbstractResourceDescriptorImpl
Constructs new instance of AbstractResourceDescriptor.- Parameters:
resource- resource instance
-
-
Method Details
-
accept
Method is useful for validation.- Specified by:
acceptin interfaceResourceDescriptor- Parameters:
visitor- SeeResourceDescriptorVisitor
-
getPathValue
- Specified by:
getPathValuein interfaceAbstractResourceDescriptor- Returns:
- See
PathValue
-
getResourceMethods
- Specified by:
getResourceMethodsin interfaceAbstractResourceDescriptor- Returns:
- resource methods
- See Also:
-
getSubResourceLocators
- Specified by:
getSubResourceLocatorsin interfaceAbstractResourceDescriptor- Returns:
- sub-resource locators
- See Also:
-
getSubResourceMethods
- Specified by:
getSubResourceMethodsin interfaceAbstractResourceDescriptor- Returns:
- sub-resource methods
- See Also:
-
getUriPattern
- Specified by:
getUriPatternin interfaceAbstractResourceDescriptor- Returns:
- See
UriPattern
-
isRootResource
public boolean isRootResource()- Specified by:
isRootResourcein interfaceAbstractResourceDescriptor- Returns:
- true if resource is root resource false otherwise. Root resource is
class which has own
Pathannotation
-
processMethods
protected void processMethods()Process method of resource and separate them to three types Resource Methods, Sub-Resource Methods and Sub-Resource Locators. -
createMethodParametersList
Create list ofMethodParameter.- Parameters:
resourceClass- classmethod- SeeMethod- 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
Get all method with at least one annotation which has annotation annotation. It is useful for annotationGET, etc. All HTTP method annotations has annotationHttpMethod.- Type Parameters:
T- annotation type- Parameters:
m- methodannotation- 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 discoveringresourceClass- class that contains discovered methodannotationClass- annotation type what we are looking formetaAnnotation- 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 ofResourceMethodDescriptoralready contains ResourceMethodDescriptor with the same media types.- Parameters:
rmds-SetofResourceMethodDescriptorconsumes- resource method consumed media typeproduces- resource method produced media type- Returns:
- ResourceMethodDescriptor or null if nothing found
-
getMethodInvoker
-
toString
-