public class TcManager extends TcProviderMultiplexer
TcManager
, delegating the actual provision and creation of
Graphs or MGraphs to registered
TcProvider
s. The class attempts to satisfy the request using the
register
WeightedTcProvider
in decreasing order of weight. If multiple
providers have the same weight the lexicographical order of the fully
qualified class name determines which one is used, namely the one that occurs
earlier. If a call to a registered provider causes an
IllegalArgumentException
,
NoSuchEntityException
or
UnsupportedOperationException
then the call is delegated to the
next provider.
Only one instance of this class should exist in a system, the public no
argument constructor is meant for initialization by dependency injection
systems such as OSGi-DS. Applications should use the static
getInstance()
method if they aren't using a framework that
injects them the instance.
This class returns
LockableMGraph
s a subtype of
MGraph
that allows read/write locks.
This class also registers all TripleCollections as services with the property
'name' indicating there name.
Security checks are done when a TripleCollection is retrieved. The returned
TripleCollection will do no further security checks. Because of this it
should not be passed to a context where different access control applies. If
an MGraph is retrieved without having write permission the returned mGraph
will be read-only.
If a TripleCollections needs to passed around across different security
contexts the one retrieved from the OSGi service whiteboard should be used as
this performs access control on every access.Modifier and Type | Field and Description |
---|---|
static String |
GENERAL_PURPOSE_TC |
protected QueryEngine |
queryEngine |
providerList
Constructor and Description |
---|
TcManager()
the constructor sets the singleton instance to allow instantiation by
OSGi-DS.
|
Modifier and Type | Method and Description |
---|---|
protected void |
activate(org.osgi.service.component.ComponentContext componentContext) |
protected void |
bindGpWeightedTcProvider(WeightedTcProvider provider)
Registers a provider
|
protected void |
bindQueryEngine(QueryEngine queryEngine) |
protected void |
bindWeightedTcProvider(WeightedTcProvider provider)
Registers a provider
|
Graph |
createGraph(UriRef name,
TripleCollection triples)
Creates a
Graph with a specified name |
LockableMGraph |
createMGraph(UriRef name)
Creates an initially empty
MGraph with a specified name |
protected void |
deactivate(org.osgi.service.component.ComponentContext componentContext) |
void |
deleteTripleCollection(UriRef name)
Deletes the
Graph or MGraph of a specified name. |
boolean |
executeSparqlQuery(AskQuery query,
TripleCollection defaultGraph)
Deprecated.
Query is discontinued
|
Graph |
executeSparqlQuery(ConstructQuery query,
TripleCollection defaultGraph)
Deprecated.
Query is discontinued
|
Graph |
executeSparqlQuery(DescribeQuery query,
TripleCollection defaultGraph)
Deprecated.
Query is discontinued
|
Object |
executeSparqlQuery(Query query,
TripleCollection defaultGraph)
Deprecated.
Query is discontinued
|
ResultSet |
executeSparqlQuery(SelectQuery query,
TripleCollection defaultGraph)
Deprecated.
Query is discontinued
|
Object |
executeSparqlQuery(String query,
boolean forceFastlane)
Executes any sparql query.
|
Object |
executeSparqlQuery(String query,
TripleCollection defaultGraph)
Executes any sparql query.
|
Object |
executeSparqlQuery(String query,
UriRef defaultGraphName)
Executes any sparql query.
|
Object |
executeSparqlQuery(String query,
UriRef defaultGraphName,
boolean forceFastlane)
Executes any sparql query.
|
Graph |
getGraph(UriRef name)
Get a
Graph by its name |
static TcManager |
getInstance()
This returns the singleton instance.
|
LockableMGraph |
getMGraph(UriRef name)
Get an
MGraph by its name. |
Set<UriRef> |
getNames(Graph graph)
get a set of the names of a
Graph |
TcAccessController |
getTcAccessController() |
TripleCollection |
getTriples(UriRef name)
This method is used to get a
TripleCollection indifferently
whether it's a Graph or an MGraph. |
protected void |
graphAppears(UriRef name)
subclasses overwrite this method to be notified when a new
Graph is available (either because it has been created or being
provided by a newly added WeightedTcProvider).
|
Set<UriRef> |
listGraphs()
Lists the name of the
Graph s available through this
TcProvider , implementations may take into account the
security context and omit Graph s for which access is not
allowed. |
Set<UriRef> |
listMGraphs()
Lists the name of the
MGraph s available through this
TcProvider , implementations may take into account the
security context and omit MGraph s for which access is not
allowed. |
Set<UriRef> |
listTripleCollections()
Lists the name of the
TripleCollection s available through this
TcProvider indifferently whether they are Graphs or an
MGraphs, implementations may take into account the security context and
omit TripleCollection s for which access is not allowed. |
protected void |
mGraphAppears(UriRef name)
subclasses overwrite this method to be notified when a new
MGraph is available (either because it has been created or being
provided by a newly added WeightedTcProvider).
|
protected void |
tcDisappears(UriRef name)
subclasses overwrite this method to be notified whenTripleCollection is
no longer available (either because it has been deleted or bacause its
WeightedTcProvider was removed).
|
protected void |
unbindGpWeightedTcProvider(WeightedTcProvider provider)
Unregister a provider
|
protected void |
unbindQueryEngine(QueryEngine queryEngine) |
protected void |
unbindWeightedTcProvider(WeightedTcProvider provider)
Unregister a provider
|
addWeightedTcProvider, getProviderList, removeWeightedTcProvider
public static final String GENERAL_PURPOSE_TC
protected QueryEngine queryEngine
public TcManager()
getInstance
method should be used.public static TcManager getInstance()
protected void activate(org.osgi.service.component.ComponentContext componentContext)
protected void deactivate(org.osgi.service.component.ComponentContext componentContext)
public Graph getGraph(UriRef name) throws NoSuchEntityException
TcProvider
Graph
by its namegetGraph
in interface TcProvider
getGraph
in class TcProviderMultiplexer
name
- the name of the GraphGraph
with the specified nameNoSuchEntityException
- if there is no Graph
with the specified namepublic LockableMGraph getMGraph(UriRef name)
TcProvider
MGraph
by its name. The instances
returned in different invocations are equals
.getMGraph
in interface TcProvider
getMGraph
in class TcProviderMultiplexer
MGraph
with the specified namepublic TripleCollection getTriples(UriRef name)
TcProvider
TripleCollection
indifferently
whether it's a Graph or an MGraph. If the name
names an
MGraph
the result is the same as when invoking
getMGraph
with that argument, analogously for
Graph
S the method returns an instance equals to what
getGraph
would return.getTriples
in interface TcProvider
getTriples
in class TcProviderMultiplexer
name
- the name of the Graph
or MGraph
Graph
or MGraph
public LockableMGraph createMGraph(UriRef name) throws UnsupportedOperationException
TcProvider
MGraph
with a specified namecreateMGraph
in interface TcProvider
createMGraph
in class TcProviderMultiplexer
name
- names the new MGraph
MGraph
UnsupportedOperationException
- if this provider doesn't support
creating MGraph
Spublic Graph createGraph(UriRef name, TripleCollection triples)
TcProvider
Graph
with a specified namecreateGraph
in interface TcProvider
createGraph
in class TcProviderMultiplexer
name
- the name of the Graph
to be createdtriples
- the triples of the new Graph
Graph
public void deleteTripleCollection(UriRef name)
TcProvider
Graph
or MGraph
of a specified name.
If name
references a Graph and the graph has other names, it
will still be available with those other names.deleteTripleCollection
in interface TcProvider
deleteTripleCollection
in class TcProviderMultiplexer
name
- the entity to be removedpublic Set<UriRef> getNames(Graph graph)
TcProvider
Graph
getNames
in interface TcProvider
getNames
in class TcProviderMultiplexer
Graph
, the set is empty if
Graph
is unknownpublic Set<UriRef> listGraphs()
TcProvider
Graph
s available through this
TcProvider
, implementations may take into account the
security context and omit Graph
s for which access is not
allowed.listGraphs
in interface TcProvider
listGraphs
in class TcProviderMultiplexer
Graph
spublic Set<UriRef> listMGraphs()
TcProvider
MGraph
s available through this
TcProvider
, implementations may take into account the
security context and omit MGraph
s for which access is not
allowed.listMGraphs
in interface TcProvider
listMGraphs
in class TcProviderMultiplexer
MGraph
spublic Set<UriRef> listTripleCollections()
TcProvider
TripleCollection
s available through this
TcProvider
indifferently whether they are Graphs or an
MGraphs, implementations may take into account the security context and
omit TripleCollection
s for which access is not allowed.listTripleCollections
in interface TcProvider
listTripleCollections
in class TcProviderMultiplexer
TripleCollection
spublic Object executeSparqlQuery(String query, TripleCollection defaultGraph) throws ParseException
query
- the sparql query to executedefaultGraph
- the default graph against which to execute the query
if no FROM clause is presentParseException
public Object executeSparqlQuery(String query, boolean forceFastlane) throws ParseException
query
- the sparql query to executeforceFastlane
- indicate whether to force fastlane usage.ParseException
public Object executeSparqlQuery(String query, UriRef defaultGraphName) throws ParseException
query
- the sparql query to executedefaultGraphName
- the graph to be used as default graph in the Sparql Graph StoreParseException
public Object executeSparqlQuery(String query, UriRef defaultGraphName, boolean forceFastlane) throws ParseException
query
- the sparql query to executedefaultGraph
- the graph to be used as default graph in the Sparql Graph StoreforceFastlane
- indicate whether to force fastlane usage.ParseException
@Deprecated public Object executeSparqlQuery(Query query, TripleCollection defaultGraph)
query
- the sparql query to executedefaultGraph
- the default graph against which to execute the query
if no FROM clause is present@Deprecated public ResultSet executeSparqlQuery(SelectQuery query, TripleCollection defaultGraph)
query
- the sparql SELECT query to executedefaultGraph
- the default graph against which to execute the query
if not FROM clause is present@Deprecated public boolean executeSparqlQuery(AskQuery query, TripleCollection defaultGraph)
query
- the sparql ASK query to executedefaultGraph
- the default graph against which to execute the query
if not FROM clause is present@Deprecated public Graph executeSparqlQuery(DescribeQuery query, TripleCollection defaultGraph)
query
- the sparql DESCRIBE query to executedefaultGraph
- the default graph against which to execute the query
if not FROM clause is present@Deprecated public Graph executeSparqlQuery(ConstructQuery query, TripleCollection defaultGraph)
query
- the sparql CONSTRUCT query to executedefaultGraph
- the default graph against which to execute the query
if not FROM clause is presentpublic TcAccessController getTcAccessController()
protected void bindWeightedTcProvider(WeightedTcProvider provider)
provider
- the provider to be registeredprotected void unbindWeightedTcProvider(WeightedTcProvider provider)
provider
- the provider to be deregisteredprotected void bindGpWeightedTcProvider(WeightedTcProvider provider)
provider
- the provider to be registeredprotected void unbindGpWeightedTcProvider(WeightedTcProvider provider)
provider
- the provider to be deregisteredprotected void bindQueryEngine(QueryEngine queryEngine)
protected void unbindQueryEngine(QueryEngine queryEngine)
protected void mGraphAppears(UriRef name)
TcProviderMultiplexer
mGraphAppears
in class TcProviderMultiplexer
protected void graphAppears(UriRef name)
TcProviderMultiplexer
graphAppears
in class TcProviderMultiplexer
protected void tcDisappears(UriRef name)
TcProviderMultiplexer
tcDisappears
in class TcProviderMultiplexer
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.