drm.server
Class ScriptUtils

java.lang.Object
  |
  +--drm.server.ScriptUtils

public abstract class ScriptUtils
extends java.lang.Object

Loads jobs and runs them on a Node.


Constructor Summary
ScriptUtils()
           
 
Method Summary
static void startAllScripts(java.util.Properties p, java.lang.String keyPrefix, Node startOn)
          Starts scripts on the given node.
static void startScript(java.lang.String scriptName, Node startOn)
          Starts script on the given server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptUtils

public ScriptUtils()
Method Detail

startScript

public static void startScript(java.lang.String scriptName,
                               Node startOn)
                        throws java.lang.ClassNotFoundException,
                               java.lang.NoSuchMethodException,
                               java.lang.Exception
Starts script on the given server. The syntax of scriptName is as follows: filename[!packagename.classname] Here filename can refer to a jar file or a directory. The given class is loaded. If the optional class name is also given, then the class is loaded from that file but only if the default classpath does not contain the given classname!. Thus, take into account that first always the default classpath is tried and the jar file or directory is tried only after that. If the classes of the experiment can be found also in the default classpath, then launching will not be succesful.

The given class has to have a constructor with one Node parameter and it has to be Runnable. An instance of the class will be constructed with this constructor and then the class will be started in a thread.

The class is always loaded using a JobClassLoader. If the class name is not given, the classname Launch is tried (ie it is assumed that a class named Launch is included in the default package).

Examples: "exp.jar!exp.LaunchTest" will start class exp.LaunchTest from jar exp.jar. "expdir" will launch class Launch from directory expdir. The empty string "" will start class Launch from the current directory.

Throws:
java.lang.ClassNotFoundException - if the given script class cannot be loaded
java.lang.NoSuchMethodException - The standard constructor, that takes one Node as a parameter is missing from the given script class.
java.lang.Exception - if the class could not be instantiated or it could be loaded with the default classloader.

startAllScripts

public static void startAllScripts(java.util.Properties p,
                                   java.lang.String keyPrefix,
                                   Node startOn)
                            throws java.lang.Exception
Starts scripts on the given node. It collects every scriptname from the given Properties object. The scriptnames are values of keys that start with the given prefix. After collecting the names it starts them sequentially one by one. The order of starting is determined by the alphabetical order of the corresponding keys. Uses startScript to start the scripts.
Throws:
java.lang.Exception - if starting of any scripts resulted in an exception. The info message of the exception contains all thrown exceptions during the startup of all scripts.