org.dspace.curate
Class TaskResolver

java.lang.Object
  extended by org.dspace.curate.TaskResolver

public class TaskResolver
extends Object

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 PluginManager. (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: || 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 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= somewhere on a comment line. for example: # My descriptor $td=ruby|rubytask.rb|LinkChecker.new For portability, the 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

Constructor Summary
TaskResolver()
           
 
Method Summary
 void addDescriptor(String taskName, String descriptor)
          Adds a task descriptor property and flushes catalog to disk.
 boolean installScript(String taskName, String fileName)
          Installs a task script.
 ResolvedTask resolveTask(String taskName)
          Returns a task implementation for a given task name, or null if no implementation could be obtained.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskResolver

public TaskResolver()
Method Detail

installScript

public boolean installScript(String taskName,
                             String fileName)
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 invoking addDescriptor.

Parameters:
taskName - logical name of task to associate with script
fileName - name of file containing task script
Returns:
true if script installed, false if installation failed

addDescriptor

public void addDescriptor(String taskName,
                          String descriptor)
Adds a task descriptor property and flushes catalog to disk.

Parameters:
taskName - logical task name
descriptor - descriptor for task

resolveTask

public ResolvedTask resolveTask(String taskName)
Returns a task implementation for a given task name, or null if no implementation could be obtained.

Parameters:
taskName - logical task name
Returns:
task an object that implements the CurationTask interface


Copyright © 2012 DuraSpace. All Rights Reserved.