Package org.topbraid.jenax.functions
Class CurrentThreadFunctionRegistry
java.lang.Object
org.apache.jena.sparql.function.FunctionRegistry
org.topbraid.jenax.functions.CurrentThreadFunctionRegistry
public class CurrentThreadFunctionRegistry
extends org.apache.jena.sparql.function.FunctionRegistry
An ARQ FunctionRegistry that can be used to associate functions
with Threads, so that additional functions from a given Model can
be made visible depending on the SPARQL query thread.
The contract of this class is very strict to prevent memory leaks: Users always need to make sure that unregister is called as soon as a query (block) ends, and to restore any old CurrentThreadFunctions object that was registered before. So a typical block would be:
Model model = ... a Model with extra SHACL/SPIN functions
CurrentThreadFunctions old = CurrentThreadFunctionRegistry.register(model);
try {
// run SPARQL queries here
}
finally {
CurrentThreadFunctionRegistry.unregister(old);
}
In preparation of the above, the application should start up with code such as
FunctionRegistry oldFR = FunctionRegistry.get();
CurrentThreadFunctionRegistry threadFR = new CurrentThreadFunctionRegistry(oldFR);
FunctionRegistry.set(ARQ.getContext(), threadFR);
and (for SPIN) do the same for the SPINThreadPropertyFunctionRegistry.
- Author:
- Holger Knublauch
-
Method Summary
Modifier and TypeMethodDescriptionget()org.apache.jena.sparql.function.FunctionFactorystatic CurrentThreadFunctionsbooleanisRegistered(String uri) keys()voidvoidstatic Runnableregister(org.apache.jena.rdf.model.Model model) Registers a set of extra SPIN functions from a given Model for the current Thread.org.apache.jena.sparql.function.FunctionFactoryMethods inherited from class org.apache.jena.sparql.function.FunctionRegistry
createFrom, get, init, set, standardRegistry
-
Method Details
-
get
-
register
Registers a set of extra SPIN functions from a given Model for the current Thread.- Parameters:
model- the Model containing the SPIN functions- Returns:
- a Runnable that must be called (in a finally block) when done to restore the previous state
-
getFunctions
-
get
- Overrides:
getin classorg.apache.jena.sparql.function.FunctionRegistry
-
isRegistered
- Overrides:
isRegisteredin classorg.apache.jena.sparql.function.FunctionRegistry
-
keys
- Overrides:
keysin classorg.apache.jena.sparql.function.FunctionRegistry
-
put
- Overrides:
putin classorg.apache.jena.sparql.function.FunctionRegistry
-
put
- Overrides:
putin classorg.apache.jena.sparql.function.FunctionRegistry
-
remove
- Overrides:
removein classorg.apache.jena.sparql.function.FunctionRegistry
-