Class RelationService
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.ecm.platform.relations.services.RelationService
-
- All Implemented Interfaces:
Serializable
,RelationManager
,Adaptable
,Component
,Extensible
,TimestampedService
public class RelationService extends DefaultComponent implements RelationManager
Relation service.It handles a registry of graph instances through extension points.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,GraphDescription>
graphDescriptions
Graph name -> descriptionMap<String,GraphFactory>
graphFactories
Graph name -> factory.Map<String,Graph>
graphRegistry
Graph name -> graph instance.protected Map<String,Class<?>>
graphTypes
Graph type -> class.static ComponentName
NAME
protected Map<String,String>
resourceAdapterRegistry
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description RelationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
getAdapter(Class<T> adapter)
Returns an object which is an instance of the given class associated with this object.Set<Resource>
getAllResources(Serializable object, Map<String,Object> context)
Computes all resources corresponding to the given object.Graph
getGraph(String name, CoreSession session)
Gets a registered graph by name.Graph
getGraphByName(String name)
Gets a registered graph by name.protected Graph
getGraphFromRegistries(GraphDescription graphDescription, CoreSession session)
Gets the graph from the registries.List<String>
getGraphNames()
Gets the list containing the graph names.List<String>
getGraphTypes()
Resource
getResource(String namespace, Serializable object, Map<String,Object> context)
Gets a resource given a namespace and a serializable object.Serializable
getResourceRepresentation(String namespace, Resource resource, Map<String,Object> context)
Gets an object representing this resource given a namespace.Graph
getTransientGraph(String type)
Gets a transient graph.protected Graph
newGraph(String className)
void
registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
protected void
registerGraph(Object contribution)
Registers a graph instance.void
start(ComponentContext context)
Start the component.void
unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
protected void
unregisterGraph(Object contribution)
Unregisters a graph.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, stop, unregister, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
NAME
public static final ComponentName NAME
-
graphDescriptions
protected final Map<String,GraphDescription> graphDescriptions
Graph name -> description
-
graphFactories
public final Map<String,GraphFactory> graphFactories
Graph name -> factory.
-
-
Method Detail
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContribution
in classDefaultComponent
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from interface:Adaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.- Specified by:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classDefaultComponent
- Parameters:
adapter
- the adapter class to look up- Returns:
- a object castable to the given class, or
null
if this object does not have an adapter for the given class
-
registerGraph
protected void registerGraph(Object contribution)
Registers a graph instance.The graph has to be declared as using a type already registered in the graph type registry.
-
unregisterGraph
protected void unregisterGraph(Object contribution)
Unregisters a graph.
-
getGraphByName
public Graph getGraphByName(String name)
Description copied from interface:RelationManager
Gets a registered graph by name.- Specified by:
getGraphByName
in interfaceRelationManager
- Parameters:
name
- string name of the graph used at registration- Returns:
- the graph
-
getGraph
public Graph getGraph(String name, CoreSession session)
Description copied from interface:RelationManager
Gets a registered graph by name.A
CoreSession
should be passed to provide a context in which to store relations when using a "core" graph.- Specified by:
getGraph
in interfaceRelationManager
- Parameters:
name
- string name of the graph used at registrationsession
- the core session- Returns:
- the graph
-
getGraphFromRegistries
protected Graph getGraphFromRegistries(GraphDescription graphDescription, CoreSession session)
Gets the graph from the registries.
-
getTransientGraph
public Graph getTransientGraph(String type)
Description copied from interface:RelationManager
Gets a transient graph.- Specified by:
getTransientGraph
in interfaceRelationManager
- Parameters:
type
- The graph type.- Returns:
- the graph.
-
getResource
public Resource getResource(String namespace, Serializable object, Map<String,Object> context)
Description copied from interface:RelationManager
Gets a resource given a namespace and a serializable object.There can be several resources with different namespaces associated to an incoming object. A document can for instance be used to refer to itself as a precise version as well as to the set of all versions.
Context can hold any object useful for the adapters, like a
CoreSession
.- Specified by:
getResource
in interfaceRelationManager
-
getAllResources
public Set<Resource> getAllResources(Serializable object, Map<String,Object> context)
Description copied from interface:RelationManager
Computes all resources corresponding to the given object.Context can hold any object useful for the adapters, like a
CoreSession
.- Specified by:
getAllResources
in interfaceRelationManager
- Returns:
- the resources as a set
-
getResourceRepresentation
public Serializable getResourceRepresentation(String namespace, Resource resource, Map<String,Object> context)
Description copied from interface:RelationManager
Gets an object representing this resource given a namespace.Context can hold any object useful for the adapters, like a
CoreSession
.- Specified by:
getResourceRepresentation
in interfaceRelationManager
-
getGraphNames
public List<String> getGraphNames()
Description copied from interface:RelationManager
Gets the list containing the graph names.- Specified by:
getGraphNames
in interfaceRelationManager
-
start
public void start(ComponentContext context)
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
-