Package org.dspace.curate
Class TaskResolver
java.lang.Object
org.dspace.curate.TaskResolver
TaskResolver takes a logical name of a curation task and attempts to deliver
a suitable implementation object. Supported implementation types include:
(1) Classpath-local Java classes configured and loaded via PluginService.
(2) Local script-based tasks, viz. coded in any scripting language whose
runtimes are accessible via the JSR-223 scripting API. This really amounts
to the family of dynamic JVM languages: JRuby, Jython, Groovy, Javascript, etc
Note that the requisite jars and other resources for these languages must be
installed in the DSpace instance for them to be used here.
Further work may involve remote URL-loadable code, etc.
Scripted tasks are managed in a directory configured with the
dspace/config/modules/curate.cfg property "script.dir". A catalog of
scripted tasks named 'task.catalog" is kept in this directory.
Each task has a 'descriptor' property with value syntax:
<engine>|<relFilePath>|<implClassCtor>
An example property:
linkchecker = ruby|rubytask.rb|LinkChecker.new
This descriptor means that a 'ruby' script engine will be created,
a script file named 'rubytask.rb' in the directory <script.dir> will be
loaded and the resolver will expect an evaluation of 'LinkChecker.new' will
provide a correct implementation object.
Script files may embed their descriptors to facilitate deployment.
To accomplish this, a script must include the descriptor string with syntax:
$td=<descriptor> somewhere on a comment line. for example:
My descriptor $td=ruby|rubytask.rb|LinkChecker.new
For portability, the <relFilePath> component may be omitted in this context.
Thus, $td=ruby||LinkChecker.new will be expanded to a descriptor
with the name of the embedding file.- Author:
- richardrodgers
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDescriptor(String taskName, String descriptor) Adds a task descriptor property and flushes catalog to disk.booleaninstallScript(String taskName, String fileName) Installs a task script.protected voidLoads catalog of descriptors for tasks if not already loadedresolveTask(String taskName) Returns a task implementation for a given task name, ornullif no implementation could be obtained.
-
Field Details
-
CATALOG
- See Also:
-
scriptDir
-
catalog
-
-
Constructor Details
-
TaskResolver
public TaskResolver()
-
-
Method Details
-
installScript
Installs a task script. Succeeds only if script: (1) exists in the configured script directory and (2) contains a recognizable descriptor in a comment line. If script lacks a descriptor, it may still be installed by manually invokingaddDescriptor.- Parameters:
taskName- logical name of task to associate with scriptfileName- name of file containing task script- Returns:
- true if script installed, false if installation failed
-
addDescriptor
Adds a task descriptor property and flushes catalog to disk.- Parameters:
taskName- logical task namedescriptor- descriptor for task
-
resolveTask
Returns a task implementation for a given task name, ornullif no implementation could be obtained.- Parameters:
taskName- logical task name- Returns:
- task an object that implements the CurationTask interface
-
loadCatalog
protected void loadCatalog()Loads catalog of descriptors for tasks if not already loaded
-