public class SPINThreadFunctionRegistry
extends org.apache.jena.sparql.function.FunctionRegistry
Note that this concept only works if ARQ has been set to single threading, which is done by the static block below.
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 SPINThreadFunctions object that was registered before. So a typical block would be:
Model model = ... a Model with extra SPIN functions
SPINThreadFunctions old = SPINThreadFunctionRegistry.register(model);
try {
// run SPARQL queries here
}
finally {
SPINThreadFunctionRegistry.unregister(old);
}
In preparation of the above, the application should start up with code such as
FunctionRegistry oldFR = FunctionRegistry.get();
SPINThreadFunctionRegistry threadFR = new SPINThreadFunctionRegistry(oldFR);
FunctionRegistry.set(ARQ.getContext(), threadFR);
and do the same for the SPINThreadPropertyFunctionRegistry.
| Constructor and Description |
|---|
SPINThreadFunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry base) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.jena.sparql.function.FunctionFactory |
get(String uri) |
static SPINThreadFunctions |
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 SPINThreadFunctions |
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(SPINThreadFunctions old)
Unregisters the current Model for the current Thread.
|
public SPINThreadFunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry base)
public static SPINThreadFunctions register(org.apache.jena.rdf.model.Model model)
model - the Model containing the SPIN functionspublic static void unregister(SPINThreadFunctions old)
old - the old functions that shall be restored or nullpublic static SPINThreadFunctions 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 © 2017 TopQuadrant, Inc.. All rights reserved.