public class TcManager extends TcProviderMultiplexer implements GraphStore
TcProviderMultiplexer
, delegating the actual provision and creation of
Graphs or MGraphs to registered WeightedTcProvider
s. The class attempts to satisfy the
request using the registered 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
Graph
s a subtype of
Graph
that allows read/write locks.
This class also registers all Graphs as services with the property
'name' indicating there name.
Security checks are done when a Graph is retrieved. The returned
Graph will do no further security checks. Because of this it
should not be passed to a context where different access control applies. If
an Graph is retrieved without having write permission the returned graph
will be read-only.
If a Graphs 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 |
static String |
Graph_SERVICES_ENABLED |
static String |
MGRAPH_CACHE_ENABLED |
protected QueryEngine |
queryEngine |
protected SortedSet<WeightedTcProvider> |
tempProviderList |
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(IRI name)
Creates an initially empty
Graph with a specified name |
ImmutableGraph |
createImmutableGraph(IRI name,
Graph triples)
Creates a
ImmutableGraph with a specified name |
protected void |
deactivate(org.osgi.service.component.ComponentContext componentContext) |
void |
deleteGraph(IRI name)
Deletes the
ImmutableGraph or Graph of a specified name. |
boolean |
executeSparqlQuery(AskQuery query,
Graph defaultGraph)
Deprecated.
Query is discontinued
|
ImmutableGraph |
executeSparqlQuery(ConstructQuery query,
Graph defaultGraph)
Deprecated.
Query is discontinued
|
ImmutableGraph |
executeSparqlQuery(DescribeQuery query,
Graph defaultGraph)
Deprecated.
Query is discontinued
|
Object |
executeSparqlQuery(Query query,
Graph defaultGraph)
Deprecated.
Query is discontinued
|
ResultSet |
executeSparqlQuery(SelectQuery query,
Graph defaultGraph)
Deprecated.
Query is discontinued
|
Object |
executeSparqlQuery(String query,
boolean forceFastlane)
Executes any sparql query.
|
Object |
executeSparqlQuery(String query,
Graph defaultGraph)
Executes any sparql query.
|
Object |
executeSparqlQuery(String query,
IRI defaultGraphName)
Executes any sparql query.
|
Object |
executeSparqlQuery(String query,
IRI defaultGraphName,
boolean forceFastlane)
Executes any sparql query.
|
Graph |
getGraph(IRI name)
This method is used to get a
Graph indifferently
whether it's a ImmutableGraph or not. |
ImmutableGraph |
getImmutableGraph(IRI name)
Get a
ImmutableGraph by its name |
static TcManager |
getInstance()
This returns the singleton instance.
|
Graph |
getMGraph(IRI name)
Get an
Graph taht is not ImmutableGrah . |
Set<IRI> |
getNames(ImmutableGraph ImmutableGraph)
get a set of the names of a
ImmutableGraph |
TcAccessController |
getTcAccessController() |
protected void |
graphAppears(IRI name)
subclasses overwrite this method to be notified when a new
ImmutableGraph is available (either because it has been created or being
provided by a newly added WeightedTcProvider).
|
boolean |
isTcServicesEnabled() |
Set<IRI> |
listGraphs()
Lists the name of the
Graph s available through this
TcProvider indifferently whether they are mutables or
immutables, implementations may take into account the security context and
omit Graph s for which access is not allowed. |
Set<IRI> |
listImmutableGraphs()
Lists the name of the
ImmutableGraph s available through this
TcProvider , implementations may take into account the
security context and omit ImmutableGraph s for which access is not
allowed. |
Set<IRI> |
listMGraphs()
Lists the name of the
Graph s available through this
TcProvider that are not ImmutableGraph , implementations may take into account the
security context and omit Graph s for which access is not
allowed. |
Set<IRI> |
listNamedGraphs()
Lists the name of the named
Graph s available through this GraphStore . |
protected void |
mGraphAppears(IRI 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).
|
protected void |
tcDisappears(IRI name)
subclasses overwrite this method to be notified whenGraph 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, isCachingEnabled, removeWeightedTcProvider, setCachingEnabled
public static final String GENERAL_PURPOSE_TC
public static final String Graph_SERVICES_ENABLED
public static final String MGRAPH_CACHE_ENABLED
protected QueryEngine queryEngine
protected SortedSet<WeightedTcProvider> tempProviderList
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 ImmutableGraph getImmutableGraph(IRI name) throws NoSuchEntityException
TcProvider
ImmutableGraph
by its namegetImmutableGraph
in interface TcProvider
getImmutableGraph
in class TcProviderMultiplexer
name
- the name of the ImmutableGraphImmutableGraph
with the specified nameNoSuchEntityException
- if there is no ImmutableGraph
with the specified namepublic Graph getMGraph(IRI name)
TcProvider
Graph
taht is not ImmutableGrah
. The instances
returned in different invocations are equals
.getMGraph
in interface TcProvider
getMGraph
in class TcProviderMultiplexer
name
- the name of the Graph
Graph
with the specified namepublic Graph getGraph(IRI name)
TcProvider
Graph
indifferently
whether it's a ImmutableGraph or not. If the name
names an
Graph
the result is the same as when invoking
getMGraph
with that argument, analogously for
ImmutableGraph
S the method returns an instance equals to what
getImmutableGraph
would return.getGraph
in interface TcProvider
getGraph
in class TcProviderMultiplexer
name
- the name of the ImmutableGraph
or Graph
ImmutableGraph
or Graph
public Graph createGraph(IRI name) throws UnsupportedOperationException
TcProvider
Graph
with a specified namecreateGraph
in interface TcProvider
createGraph
in class TcProviderMultiplexer
name
- names the new Graph
Graph
UnsupportedOperationException
- if this provider doesn't support
creating Graph
Spublic ImmutableGraph createImmutableGraph(IRI name, Graph triples)
TcProvider
ImmutableGraph
with a specified namecreateImmutableGraph
in interface TcProvider
createImmutableGraph
in class TcProviderMultiplexer
name
- the name of the ImmutableGraph
to be createdtriples
- the triples of the new ImmutableGraph
ImmutableGraph
public void deleteGraph(IRI name)
TcProvider
ImmutableGraph
or Graph
of a specified name.
If name
references a ImmutableGraph and the ImmutableGraph has other names, it
will still be available with those other names.deleteGraph
in interface TcProvider
deleteGraph
in class TcProviderMultiplexer
name
- the entity to be removedpublic Set<IRI> getNames(ImmutableGraph ImmutableGraph)
TcProvider
ImmutableGraph
getNames
in interface TcProvider
getNames
in class TcProviderMultiplexer
ImmutableGraph
, the set is empty if
ImmutableGraph
is unknownpublic Set<IRI> listNamedGraphs()
GraphStore
Graph
s available through this GraphStore
.listNamedGraphs
in interface GraphStore
Graph
spublic Set<IRI> listGraphs()
TcProvider
Graph
s available through this
TcProvider
indifferently whether they are mutables or
immutables, implementations may take into account the security context and
omit Graph
s for which access is not allowed.listGraphs
in interface TcProvider
listGraphs
in interface GraphStore
listGraphs
in class TcProviderMultiplexer
Graph
spublic Set<IRI> listMGraphs()
TcProvider
Graph
s available through this
TcProvider
that are not ImmutableGraph
, implementations may take into account the
security context and omit Graph
s for which access is not
allowed.listMGraphs
in interface TcProvider
listMGraphs
in class TcProviderMultiplexer
Graph
spublic Set<IRI> listImmutableGraphs()
TcProvider
ImmutableGraph
s available through this
TcProvider
, implementations may take into account the
security context and omit ImmutableGraph
s for which access is not
allowed.listImmutableGraphs
in interface TcProvider
listImmutableGraphs
in class TcProviderMultiplexer
ImmutableGraph
spublic Object executeSparqlQuery(String query, Graph defaultGraph) throws ParseException
query
- the sparql query to executedefaultGraph
- the default ImmutableGraph 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, IRI defaultGraphName) throws ParseException
query
- the sparql query to executedefaultGraphName
- the ImmutableGraph to be used as default ImmutableGraph in the Sparql ImmutableGraph StoreParseException
public Object executeSparqlQuery(String query, IRI defaultGraphName, boolean forceFastlane) throws ParseException
query
- the sparql query to executedefaultGraphName
- the ImmutableGraph to be used as default ImmutableGraph in the Sparql ImmutableGraph StoreforceFastlane
- indicate whether to force fastlane usage.ParseException
@Deprecated public Object executeSparqlQuery(Query query, Graph defaultGraph)
query
- the sparql query to executedefaultGraph
- the default ImmutableGraph against which to execute the query
if no FROM clause is present@Deprecated public ResultSet executeSparqlQuery(SelectQuery query, Graph defaultGraph)
query
- the sparql SELECT query to executedefaultGraph
- the default ImmutableGraph against which to execute the query
if not FROM clause is present@Deprecated public boolean executeSparqlQuery(AskQuery query, Graph defaultGraph)
query
- the sparql ASK query to executedefaultGraph
- the default ImmutableGraph against which to execute the query
if not FROM clause is present@Deprecated public ImmutableGraph executeSparqlQuery(DescribeQuery query, Graph defaultGraph)
query
- the sparql DESCRIBE query to executedefaultGraph
- the default ImmutableGraph against which to execute the query
if not FROM clause is present@Deprecated public ImmutableGraph executeSparqlQuery(ConstructQuery query, Graph defaultGraph)
query
- the sparql CONSTRUCT query to executedefaultGraph
- the default ImmutableGraph 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(IRI name)
TcProviderMultiplexer
mGraphAppears
in class TcProviderMultiplexer
protected void graphAppears(IRI name)
TcProviderMultiplexer
graphAppears
in class TcProviderMultiplexer
protected void tcDisappears(IRI name)
TcProviderMultiplexer
tcDisappears
in class TcProviderMultiplexer
public boolean isTcServicesEnabled()
Copyright © 2015–2022 The Apache Software Foundation. All rights reserved.