org.gridlab.gat.resources
Class JavaSoftwareDescription

java.lang.Object
  extended by org.gridlab.gat.resources.SoftwareDescription
      extended by org.gridlab.gat.resources.JavaSoftwareDescription
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
WrapperSoftwareDescription

public class JavaSoftwareDescription
extends SoftwareDescription

An instance of this class is a description of a piece of java software (component) which is to be submitted as a job.

The JavaSoftwareDescription is tailored to Java jobs. Although, it is possible to submit a java job with the regular SoftwareDescription, the JavaSoftwareDescription is a convenience object that makes it easier and more straight forward to describe a java job. Besides the JavaSoftwareDescription being a convenience object, some JavaGAT adaptors may only accept SoftwareDescriptions of the type JavaSoftwareDescription.

The following example shows the relation between the SoftwareDescription and the JavaSoftwareDescription. Consider the command line:

/path/to/java -classpath a:b:c/d -Xoption1 -Dmykey=myvalue my.package.Main arg1 arg2

The SoftwareDescription needs this invocations to construct this command line:

setExecutable("/path/to/java");
setArguments(new String[]{"-classpath", "a:b:c/d", "-Xoption1", "-Dmykey=myvalue", "my.package.Main", "arg1", "arg2"});

The JavaSoftwareDescription needs the following invocations for the same command line:

setExecutable("/path/to/java");
setJavaClassPath("a:b:c/d");
setJavaOptions(new String[]{"-Xoption1});
Map systemProperties = new HashMap();
systemProperties.put("mykey", "myvalue");
setJavaSystemProperties(systemProperties);
setJavaMain("my.package.Main");
setJavaArguments(new String[]{"arg1", "arg2"});

Author:
roelof
See Also:
Serialized Form

Field Summary
static String JAVA_ARGUMENTS
          Attribute name: indicates the java arguments for the main class of the java application.
static String JAVA_MAIN
          Attribute name: indicates the main class that should be executed.
static String JAVA_OPTIONS
          Attribute name: indicates the jvm options for this java application.
static String JAVA_SYSTEM_PROPERTIES
          Attribute name: indicates the java system properties.
 
Fields inherited from class org.gridlab.gat.resources.SoftwareDescription
CPUTIME_MAX, DIRECTORY, DRY_RUN, HOST_COUNT, JOB_QUEUE, JOB_TYPE, MEMORY_MAX, MEMORY_MIN, PROJECT, RESTART, SANDBOX_DELETE, SANDBOX_POSTSTAGE_STDERR, SANDBOX_POSTSTAGE_STDOUT, SANDBOX_PRESTAGE_STDIN, SANDBOX_ROOT, SANDBOX_USEROOT, SAVE_STATE, STOP_ON_EXIT, TIME_MAX, WALLTIME_MAX
 
Constructor Summary
JavaSoftwareDescription()
          Create a JavaSoftwareDescription, which describes the java application.
JavaSoftwareDescription(Map<String,Object> attributes)
          Create a JavaSoftwareDescription with the provided attributes, which describes the java application.
 
Method Summary
 void addJavaSystemProperty(String key, String value)
          Adds a system property to the current set of system properties.
 String[] getArguments()
          Constructs the command line arguments from the class path, the jvm options, the system properties, the main and the java arguments of this SoftwareDescription.
 String getExecutable()
          Returns the executable.
 String[] getJavaArguments()
          Returns the arguments for the main class.
 String getJavaClassPath()
          Returns the java class path.
 String getJavaMain()
          Returns the main class of the java application.
 String[] getJavaOptions()
          Returns the jvm options.
 Map<String,String> getJavaSystemProperties()
          Returns the java system properties.
 void setArguments(String... arguments)
          This method should not be used.
 void setJavaArguments(String... javaArguments)
          Sets the arguments of the java main class.
 void setJavaClassPath(String javaClassPath)
          Sets the java class path.
 void setJavaMain(String main)
          Sets the main class.
 void setJavaOptions(String... options)
          Sets the jvm options.
 void setJavaSystemProperties(Map<String,String> systemProperties)
          Sets the system properties.
 
Methods inherited from class org.gridlab.gat.resources.SoftwareDescription
addAttribute, addDeletedFile, addPostStagedFile, addPostStagedFile, addPreStagedFile, addPreStagedFile, addWipedFile, clone, deletePostStaged, deletePreStaged, enableStreamingStderr, enableStreamingStdin, enableStreamingStdout, equals, getAttributes, getBooleanAttribute, getDeletedFiles, getEnvironment, getIntAttribute, getJSDL, getLongAttribute, getObjectAttribute, getPostStaged, getPreStaged, getStderr, getStdin, getStdout, getStringAttribute, getWipedFiles, hashCode, removeAttribute, setAttributes, setDeletePostStaged, setDeletePreStaged, setEnvironment, setExecutable, setPostStaged, setPreStaged, setStderr, setStdin, setStdout, setWipePostStaged, setWipePreStaged, streamingStderrEnabled, streamingStdinEnabled, streamingStdoutEnabled, toString, toWrapper, wipePostStaged, wipePreStaged
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

JAVA_MAIN

public static final String JAVA_MAIN
Attribute name: indicates the main class that should be executed. See JavaSoftwareDescription(Map).

See Also:
Constant Field Values

JAVA_OPTIONS

public static final String JAVA_OPTIONS
Attribute name: indicates the jvm options for this java application. See JavaSoftwareDescription(Map).

See Also:
Constant Field Values

JAVA_SYSTEM_PROPERTIES

public static final String JAVA_SYSTEM_PROPERTIES
Attribute name: indicates the java system properties. See JavaSoftwareDescription(Map).

See Also:
Constant Field Values

JAVA_ARGUMENTS

public static final String JAVA_ARGUMENTS
Attribute name: indicates the java arguments for the main class of the java application. See JavaSoftwareDescription(Map).

See Also:
Constant Field Values
Constructor Detail

JavaSoftwareDescription

public JavaSoftwareDescription()
Create a JavaSoftwareDescription, which describes the java application.


JavaSoftwareDescription

public JavaSoftwareDescription(Map<String,Object> attributes)
Create a JavaSoftwareDescription with the provided attributes, which describes the java application. See SoftwareDescription for a list of well known attributes. Besides this list the JavaSoftwareDescription knows these attributes:

supported name/value pairs of JavaSoftwareDescription
Name Type Description
java.main String the main class that should be executed
java.options String[] the jvm options for this java application
java.system.properties Map<String, String> the java system properties
java.arguments String[] the java arguments for the main class of the java application

Parameters:
attributes - the attributes belonging to this JavaSoftwareDescription.
Method Detail

getJavaOptions

public String[] getJavaOptions()
Returns the jvm options.

Returns:
the jvm options.

setJavaOptions

public void setJavaOptions(String... options)
Sets the jvm options.

Parameters:
options - the jvm options.

getJavaSystemProperties

public Map<String,String> getJavaSystemProperties()
Returns the java system properties.

Returns:
the java system properties.

setJavaSystemProperties

public void setJavaSystemProperties(Map<String,String> systemProperties)
Sets the system properties. A system property should be passed as a key value pair <"a", "b">, not as <"-Da", "b">, JavaGAT will add the -D to the property.

Parameters:
systemProperties - the system properties.

addJavaSystemProperty

public void addJavaSystemProperty(String key,
                                  String value)
Adds a system property to the current set of system properties. The key of the system property should not start with "-D".

Parameters:
key - the key of the system property to be added
value - the value belonging to the key of the system property to be added

getJavaMain

public String getJavaMain()
Returns the main class of the java application.

Returns:
the main class.

setJavaMain

public void setJavaMain(String main)
Sets the main class.

Parameters:
main - the main class.

getJavaArguments

public String[] getJavaArguments()
Returns the arguments for the main class.

Returns:
the arguments for the main class

setJavaArguments

public void setJavaArguments(String... javaArguments)
Sets the arguments of the java main class.

Parameters:
javaArguments - the arguments of the java main class.

setArguments

public void setArguments(String... arguments)
This method should not be used. This method will ignore all arguments. The methods setJavaClassPath(String), setJavaOptions(String[]), setJavaSystemProperties(Map), setJavaMain(String) and setJavaArguments(String[]) should be used to construct the command line arguments.

Overrides:
setArguments in class SoftwareDescription
Parameters:
arguments -

getArguments

public String[] getArguments()
Constructs the command line arguments from the class path, the jvm options, the system properties, the main and the java arguments of this SoftwareDescription.

Overrides:
getArguments in class SoftwareDescription
Returns:
the command line arguments

getExecutable

public String getExecutable()
Returns the executable. If no executable is set the default executable will be "java".

Overrides:
getExecutable in class SoftwareDescription
Returns:
Returns the executable.

getJavaClassPath

public String getJavaClassPath()
Returns the java class path.

Returns:
the java class path.

setJavaClassPath

public void setJavaClassPath(String javaClassPath)
Sets the java class path.

Parameters:
javaClassPath - the class path to be set.