public class MarshallerRegistryImpl extends DefaultComponent implements MarshallerRegistry
MarshallerRegistry
.
This implementation is based on MarshallerInspector
class which is able to create marshaller instance and
inject properties. This class also manage marshaller's priorities.
lastModified
Constructor and Description |
---|
MarshallerRegistryImpl() |
Modifier and Type | Method and Description |
---|---|
void |
activate(ComponentContext context)
Activates the component.
|
void |
clear()
Be careful !!! That's deregister all marshallers.
|
void |
deactivate(ComponentContext context)
Deactivates the component.
|
void |
deregister(Class<?> marshaller)
Remove a marshaller from the registry.
|
<T> Collection<Marshaller<T>> |
getAllMarshallers(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype,
Set<MarshallerInspector> customs,
Set<MarshallerInspector> wildcards) |
<T> Collection<Reader<T>> |
getAllReaders(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides all
Reader instance that manage marshalling of a mimetype in a Java Type. |
<T> Collection<Writer<T>> |
getAllWriters(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides all
Writer instance that manage marshalling of the given Java Type and mimetype. |
<T> T |
getInstance(RenderingContext ctx,
Class<T> marshallerClass)
Provides an instance of a given marshaller class.
|
<T> Marshaller<T> |
getMarshaller(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype,
Set<MarshallerInspector> customs,
Set<MarshallerInspector> wildcards,
boolean forceInstantiation) |
<T> Reader<T> |
getReader(RenderingContext ctx,
Class<T> marshalledClazz,
javax.ws.rs.core.MediaType mediatype)
|
<T> Reader<T> |
getReader(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides a
Reader instance to manage marshalling of a mimetype in a Java Type. |
<T> T |
getUniqueInstance(RenderingContext ctx,
Class<T> marshallerClass)
Provides an instance of the given marshaller class.
|
<T> Reader<T> |
getUniqueReader(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides a
Reader instance to manage marshalling of a mimetype in a Java Type. |
<T> Writer<T> |
getUniqueWriter(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides a
Writer instance to manage marshalling of the given Java Type and mimetype. |
<T> Writer<T> |
getWriter(RenderingContext ctx,
Class<T> marshalledClazz,
javax.ws.rs.core.MediaType mediatype)
|
<T> Writer<T> |
getWriter(RenderingContext ctx,
Class<T> marshalledClazz,
Type genericType,
javax.ws.rs.core.MediaType mediatype)
Provides a
Writer instance to manage marshalling of the given Java Type and mimetype. |
void |
register(Class<?> marshaller)
Makes a marshaller class available.
|
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
getAdapter, getLastModified, registerExtension, setLastModified, setModifiedNow, start, stop, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted, getApplicationStartedOrder
public MarshallerRegistryImpl()
public void activate(ComponentContext context)
Component
This method is called by the runtime when a component is activated.
activate
in interface Component
activate
in class DefaultComponent
context
- the runtime contextpublic void deactivate(ComponentContext context)
Component
This method is called by the runtime when a component is deactivated.
deactivate
in interface Component
deactivate
in class DefaultComponent
context
- the runtime contextpublic void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution
in class DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
public void register(Class<?> marshaller)
MarshallerRegistry
register
in interface MarshallerRegistry
marshaller
- The marshaller class.public void deregister(Class<?> marshaller) throws MarshallingException
MarshallerRegistry
deregister
in interface MarshallerRegistry
marshaller
- The marshaller class.MarshallingException
- If marshaller class is null or if it's not a valid marshaller.public <T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
Writer
instance to manage marshalling of the given Java Type and mimetype.getWriter
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Writer
instance.public <T> Writer<T> getUniqueWriter(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
Writer
instance to manage marshalling of the given Java Type and mimetype. It creates a new
instance even for Instantiations.SINGLETON
marshallers.getUniqueWriter
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Writer
instance.public <T> Collection<Writer<T>> getAllWriters(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
Writer
instance that manage marshalling of the given Java Type and mimetype.getAllWriters
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Writer
instance.public <T> Writer<T> getWriter(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
getWriter
in interface MarshallerRegistry
public <T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
Reader
instance to manage marshalling of a mimetype in a Java Type.getReader
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Reader
instance.public <T> Reader<T> getUniqueReader(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
Reader
instance to manage marshalling of a mimetype in a Java Type. It creates a new instance
even for Instantiations.SINGLETON
marshallers.getUniqueReader
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Reader
instance.public <T> Collection<Reader<T>> getAllReaders(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
Reader
instance that manage marshalling of a mimetype in a Java Type.getAllReaders
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshalledClazz
- The java type to manage.genericType
- The generic Java type to manage.mediatype
- The expected mimetype.Reader
instance.public <T> Reader<T> getReader(RenderingContext ctx, Class<T> marshalledClazz, javax.ws.rs.core.MediaType mediatype)
MarshallerRegistry
getReader
in interface MarshallerRegistry
public <T> Marshaller<T> getMarshaller(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype, Set<MarshallerInspector> customs, Set<MarshallerInspector> wildcards, boolean forceInstantiation)
public <T> Collection<Marshaller<T>> getAllMarshallers(RenderingContext ctx, Class<T> marshalledClazz, Type genericType, javax.ws.rs.core.MediaType mediatype, Set<MarshallerInspector> customs, Set<MarshallerInspector> wildcards)
public <T> T getInstance(RenderingContext ctx, Class<T> marshallerClass)
MarshallerRegistry
getInstance
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshallerClass
- A valid marshaller instance.public <T> T getUniqueInstance(RenderingContext ctx, Class<T> marshallerClass)
MarshallerRegistry
Instantiations.SINGLETON
marshallers.getUniqueInstance
in interface MarshallerRegistry
ctx
- The marshalling context (see RenderingContext
).marshallerClass
- A valid marshaller instance.public void clear()
MarshallerRegistry
clear
in interface MarshallerRegistry
Copyright © 2017 Nuxeo. All rights reserved.