public class RestfulContainer
extends org.exoplatform.container.ConcurrentPicoContainer
implements javax.ws.rs.ext.Providers
Path it may be retrieved by method getMatchedResource(String, List). If
class annotated with Provider and implement one of JAX-RS extension interfaces instance of
component may be retrieved by corresponded methods of Providers interface. E.g:
Suppose we have a resource class org.example.MyResource annotated with @Path("my-resource") and base
URL is http://example.com/:
@Path("my-resource")
public class MyResource
{
@GET
@Path("{id}")
public String get()
{
...
}
}
Need register resource in container.
RestfulContainer container = ... container.registerComponentImplementation(MyResource.class);Suppose we have a GET request for
http://example.com/my-resource/101. We need to find resource matched
to relative path /my-resource/101.
List<String> paramValues = new ArrayList<String>();
Object resource = container.getMatchedResource("/my-resource/101", paramValues);
...
Resource should be the instance of org.example.MyResource.class. Container supports injection JAX-RS runtime
information into a class field or constructor parameters with annotation Context.
NOTE Methods registerXXX of this container may throws
PicoRegistrationException if component violates the restrictions of framework, e.g. if resource with the
same
URI pattern or provider with the same purpose already registered in this container.
Context,
MessageBodyReader,
MessageBodyWriter,
ContextResolver,
ExceptionMapper,
Serialized Form| Modifier | Constructor and Description |
|---|---|
|
RestfulContainer() |
protected |
RestfulContainer(org.picocontainer.defaults.ComponentAdapterFactory factory,
org.picocontainer.PicoContainer parent) |
protected |
RestfulContainer(org.picocontainer.PicoContainer parent) |
| Modifier and Type | Method and Description |
|---|---|
List<org.picocontainer.ComponentAdapter> |
getComponentAdapters(Class<? extends Annotation> annotation)
Retrieve all the component adapters for types annotated with
annotation inside this container. |
List<org.picocontainer.ComponentAdapter> |
getComponentAdaptersOfType(Class componentType,
Class<? extends Annotation> annotation)
Retrieve all the component adapters of the specified type and annotated with
annotation inside this container. |
List<Object> |
getComponents(Class<? extends Annotation> annotation)
Retrieve all the component instances annotated with
annotation. |
<T> List<T> |
getComponentsOfType(Class<T> componentType,
Class<? extends Annotation> annotation)
Retrieve all the component instances of the specified type and annotated with
annotation. |
<T> javax.ws.rs.ext.ContextResolver<T> |
getContextResolver(Class<T> contextType,
javax.ws.rs.core.MediaType mediaType) |
<T extends Throwable> |
getExceptionMapper(Class<T> type) |
org.picocontainer.ComponentAdapter |
getMatchedResource(String requestPath,
List<String> parameterValues)
Get ComponentAdapter root resource matched to
requestPath. |
<T> javax.ws.rs.ext.MessageBodyReader<T> |
getMessageBodyReader(Class<T> type,
Type genericType,
Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType) |
<T> javax.ws.rs.ext.MessageBodyWriter<T> |
getMessageBodyWriter(Class<T> type,
Type genericType,
Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType) |
org.picocontainer.ComponentAdapter |
registerComponent(org.picocontainer.ComponentAdapter componentAdapter) |
org.picocontainer.ComponentAdapter |
registerComponentInstance(Object componentKey,
Object componentInstance) |
org.picocontainer.ComponentAdapter |
unregisterComponent(Object componentKey) |
accept, accept, addChildContainer, addComponentToCtx, canBeDisposed, canBeStarted, canBeStopped, dispose, getComponentAdapter, getComponentAdapterOfType, getComponentAdapters, getComponentAdaptersOfType, getComponentInstance, getComponentInstanceOfType, getComponentInstances, getComponentInstancesOfType, getParent, makeChildContainer, registerComponentImplementation, registerComponentImplementation, registerComponentImplementation, registerComponentImplementation, registerComponentInstance, removeChildContainer, removeComponentFromCtx, start, stop, unregisterComponentByInstance, verifypublic RestfulContainer()
protected RestfulContainer(org.picocontainer.PicoContainer parent)
protected RestfulContainer(org.picocontainer.defaults.ComponentAdapterFactory factory,
org.picocontainer.PicoContainer parent)
public org.picocontainer.ComponentAdapter registerComponent(org.picocontainer.ComponentAdapter componentAdapter)
throws org.picocontainer.defaults.DuplicateComponentKeyRegistrationException
registerComponent in interface org.picocontainer.MutablePicoContainerregisterComponent in class org.exoplatform.container.ConcurrentPicoContainerorg.picocontainer.defaults.DuplicateComponentKeyRegistrationExceptionpublic org.picocontainer.ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance) throws org.picocontainer.PicoRegistrationException
registerComponentInstance in interface org.picocontainer.MutablePicoContainerregisterComponentInstance in class org.exoplatform.container.ConcurrentPicoContainerorg.picocontainer.PicoRegistrationExceptionpublic org.picocontainer.ComponentAdapter unregisterComponent(Object componentKey)
unregisterComponent in interface org.picocontainer.MutablePicoContainerunregisterComponent in class org.exoplatform.container.ConcurrentPicoContainerpublic List<org.picocontainer.ComponentAdapter> getComponentAdapters(Class<? extends Annotation> annotation)
annotation inside this container. The component adapters
from the parent container are not returned.annotation - the annotation typeannotation inside this container.public List<org.picocontainer.ComponentAdapter> getComponentAdaptersOfType(Class componentType, Class<? extends Annotation> annotation)
annotation inside this container. The
component adapters from the parent container are not returned.componentType - the type of componentannotation - the annotation typeannotation inside
this container.public <T> List<T> getComponentsOfType(Class<T> componentType, Class<? extends Annotation> annotation)
annotation.componentType - the type of componentannotation - the annotation typepublic List<Object> getComponents(Class<? extends Annotation> annotation)
annotation.annotation - the annotation typepublic final org.picocontainer.ComponentAdapter getMatchedResource(String requestPath, List<String> parameterValues)
requestPath.requestPath - request pathparameterValues - list for placing values of URI templatesrequestPath or nullpublic final <T> javax.ws.rs.ext.MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
getMessageBodyReader in interface javax.ws.rs.ext.Providerspublic final <T> javax.ws.rs.ext.MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
getMessageBodyWriter in interface javax.ws.rs.ext.Providerspublic final <T extends Throwable> javax.ws.rs.ext.ExceptionMapper<T> getExceptionMapper(Class<T> type)
getExceptionMapper in interface javax.ws.rs.ext.Providerspublic final <T> javax.ws.rs.ext.ContextResolver<T> getContextResolver(Class<T> contextType, javax.ws.rs.core.MediaType mediaType)
getContextResolver in interface javax.ws.rs.ext.ProvidersCopyright © 2015. All rights reserved.