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>graphDescriptionsGraph name -> descriptionMap<String,GraphFactory>graphFactoriesGraph name -> factory.Map<String,Graph>graphRegistryGraph name -> graph instance.protected Map<String,Class<?>>graphTypesGraph type -> class.static ComponentNameNAMEprotected 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> TgetAdapter(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.GraphgetGraph(String name, CoreSession session)Gets a registered graph by name.GraphgetGraphByName(String name)Gets a registered graph by name.protected GraphgetGraphFromRegistries(GraphDescription graphDescription, CoreSession session)Gets the graph from the registries.List<String>getGraphNames()Gets the list containing the graph names.List<String>getGraphTypes()ResourcegetResource(String namespace, Serializable object, Map<String,Object> context)Gets a resource given a namespace and a serializable object.SerializablegetResourceRepresentation(String namespace, Resource resource, Map<String,Object> context)Gets an object representing this resource given a namespace.GraphgetTransientGraph(String type)Gets a transient graph.protected GraphnewGraph(String className)voidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)protected voidregisterGraph(Object contribution)Registers a graph instance.voidstart(ComponentContext context)Start the component.voidunregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)protected voidunregisterGraph(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:
registerContributionin classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
- Overrides:
unregisterContributionin classDefaultComponent
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
Description copied from interface:AdaptableReturns an object which is an instance of the given class associated with this object. Returnsnullif no such object can be found.- Specified by:
getAdapterin interfaceAdaptable- Overrides:
getAdapterin classDefaultComponent- Parameters:
adapter- the adapter class to look up- Returns:
- a object castable to the given class, or
nullif 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:RelationManagerGets a registered graph by name.- Specified by:
getGraphByNamein 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:RelationManagerGets a registered graph by name.A
CoreSessionshould be passed to provide a context in which to store relations when using a "core" graph.- Specified by:
getGraphin 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:RelationManagerGets a transient graph.- Specified by:
getTransientGraphin 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:RelationManagerGets 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:
getResourcein interfaceRelationManager
-
getAllResources
public Set<Resource> getAllResources(Serializable object, Map<String,Object> context)
Description copied from interface:RelationManagerComputes all resources corresponding to the given object.Context can hold any object useful for the adapters, like a
CoreSession.- Specified by:
getAllResourcesin interfaceRelationManager- Returns:
- the resources as a set
-
getResourceRepresentation
public Serializable getResourceRepresentation(String namespace, Resource resource, Map<String,Object> context)
Description copied from interface:RelationManagerGets an object representing this resource given a namespace.Context can hold any object useful for the adapters, like a
CoreSession.- Specified by:
getResourceRepresentationin interfaceRelationManager
-
getGraphNames
public List<String> getGraphNames()
Description copied from interface:RelationManagerGets the list containing the graph names.- Specified by:
getGraphNamesin interfaceRelationManager
-
start
public void start(ComponentContext context)
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
-