Class CachingRDFServiceExecutor<T>
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.visualization.utilities.CachingRDFServiceExecutor<T>
-
- Type Parameters:
T-
public class CachingRDFServiceExecutor<T> extends Object
Utility class that populates and returns a cache. Once the cache is populated, it can return the cached results whilst refreshing in the background.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCachingRDFServiceExecutor.AffinityAffinity class that serializes background processing for tasks given the same affinitystatic classCachingRDFServiceExecutor.RDFServiceCallable<T>Class to be implemented by user to provide the means of generating the results
-
Constructor Summary
Constructors Constructor Description CachingRDFServiceExecutor(CachingRDFServiceExecutor.RDFServiceCallable<T> resultBuilder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuild(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)(Re)build the current cacheDatecachedWhen()Tget(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)Return the cached results if present, or start the task.Tget(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService, boolean allowWaits)Return the cached results if present, or start the task.Tget(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService, boolean allowWaits, boolean force)TgetNoWait(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)Return the cached results if present, or start the task.booleanisCached()static voidsetBackgroundRDFService(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)Set the RDF service to be used for background threads (called from a startup servlet)
-
-
-
Constructor Detail
-
CachingRDFServiceExecutor
public CachingRDFServiceExecutor(CachingRDFServiceExecutor.RDFServiceCallable<T> resultBuilder)
-
-
Method Detail
-
isCached
public boolean isCached()
-
cachedWhen
public Date cachedWhen()
-
get
public T get(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)
Return the cached results if present, or start the task. Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background.- Parameters:
rdfService- an RDF service to use, in foreground mode, if the background service is missing
-
getNoWait
public T getNoWait(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)
Return the cached results if present, or start the task. Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background.- Parameters:
rdfService- an RDF service to use, in foreground mode, if the background service is missing
-
get
public T get(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService, boolean allowWaits)
Return the cached results if present, or start the task. Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background.- Parameters:
rdfService- an RDF service to use, in foreground mode, if the background service is missing
-
get
public T get(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService, boolean allowWaits, boolean force)
-
build
public void build(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)
(Re)build the current cache- Parameters:
rdfService- an RDF service to use, if the background RDF service is not set
-
setBackgroundRDFService
public static void setBackgroundRDFService(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService)
Set the RDF service to be used for background threads (called from a startup servlet)- Parameters:
rdfService- An RDFService
-
-