public class CurrentThreadFunctionRegistry
extends org.apache.jena.sparql.function.FunctionRegistry
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.
| Constructor and Description |
|---|
CurrentThreadFunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry base) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.jena.sparql.function.FunctionFactory |
get(String uri) |
static CurrentThreadFunctions |
getFunctions() |
boolean |
isRegistered(String uri) |
Iterator<String> |
keys() |
void |
put(String uri,
Class<?> funcClass) |
void |
put(String uri,
org.apache.jena.sparql.function.FunctionFactory f) |
static CurrentThreadFunctions |
register(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.FunctionFactory |
remove(String uri) |
static void |
unregister(CurrentThreadFunctions old)
Unregisters the current Model for the current Thread.
|
public CurrentThreadFunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry base)
public static CurrentThreadFunctions register(org.apache.jena.rdf.model.Model model)
model - the Model containing the SPIN functionspublic static void unregister(CurrentThreadFunctions old)
old - the old functions that shall be restored or nullpublic static CurrentThreadFunctions getFunctions()
public org.apache.jena.sparql.function.FunctionFactory get(String uri)
get in class org.apache.jena.sparql.function.FunctionRegistrypublic boolean isRegistered(String uri)
isRegistered in class org.apache.jena.sparql.function.FunctionRegistrypublic Iterator<String> keys()
keys in class org.apache.jena.sparql.function.FunctionRegistrypublic void put(String uri, Class<?> funcClass)
put in class org.apache.jena.sparql.function.FunctionRegistrypublic void put(String uri, org.apache.jena.sparql.function.FunctionFactory f)
put in class org.apache.jena.sparql.function.FunctionRegistrypublic org.apache.jena.sparql.function.FunctionFactory remove(String uri)
remove in class org.apache.jena.sparql.function.FunctionRegistryCopyright © 2019 TopQuadrant, Inc.. All rights reserved.