public class RelationService extends DefaultComponent implements RelationManager
It handles a registry of graph instances through extension points.
Modifier and Type | Field and Description |
---|---|
protected Map<String,GraphDescription> |
graphDescriptions
Graph name -> description
|
Map<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 |
lastModified
Constructor and Description |
---|
RelationService() |
Modifier and Type | Method and 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.
|
activate, deactivate, getLastModified, registerExtension, setLastModified, setModifiedNow, stop, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted, getApplicationStartedOrder
public static final ComponentName NAME
protected final Map<String,Class<?>> graphTypes
protected final Map<String,GraphDescription> graphDescriptions
public final Map<String,GraphFactory> graphFactories
public final Map<String,Graph> graphRegistry
protected final Map<String,String> resourceAdapterRegistry
public RelationService()
public 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 <T> T getAdapter(Class<T> adapter)
Adaptable
null
if no such object can be found.getAdapter
in interface Adaptable
getAdapter
in class DefaultComponent
adapter
- the adapter class to look upnull
if this object does not have an adapter for
the given classpublic List<String> getGraphTypes()
protected void registerGraph(Object contribution)
The graph has to be declared as using a type already registered in the graph type registry.
protected void unregisterGraph(Object contribution)
public Graph getGraphByName(String name)
RelationManager
getGraphByName
in interface RelationManager
name
- string name of the graph used at registrationpublic Graph getGraph(String name, CoreSession session)
RelationManager
A CoreSession
should be passed to provide a context in which to store relations when using a "core"
graph.
getGraph
in interface RelationManager
name
- string name of the graph used at registrationsession
- the core sessionprotected Graph getGraphFromRegistries(GraphDescription graphDescription, CoreSession session)
public Graph getTransientGraph(String type)
RelationManager
getTransientGraph
in interface RelationManager
type
- The graph type.public Resource getResource(String namespace, Serializable object, Map<String,Object> context)
RelationManager
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
.
getResource
in interface RelationManager
public Set<Resource> getAllResources(Serializable object, Map<String,Object> context)
RelationManager
Context can hold any object useful for the adapters, like a CoreSession
.
getAllResources
in interface RelationManager
public Serializable getResourceRepresentation(String namespace, Resource resource, Map<String,Object> context)
RelationManager
Context can hold any object useful for the adapters, like a CoreSession
.
getResourceRepresentation
in interface RelationManager
public List<String> getGraphNames()
RelationManager
getGraphNames
in interface RelationManager
public void start(ComponentContext context)
Component
start
in interface Component
start
in class DefaultComponent
Copyright © 2018 Nuxeo. All rights reserved.