protoj.core.internal
Class StartVmCommand

java.lang.Object
  extended by protoj.core.internal.StartVmCommand

public final class StartVmCommand
extends java.lang.Object

A convenience class for creating a command that will start a virtual machine. Use the constructors to specify the minimal and most widely anticipated configuration and the initXXX methods for the less common configuration options.

Author:
Ashley Williams

Constructor Summary
StartVmCommand()
           
 
Method Summary
 void execute()
           
 java.util.List<java.lang.String> getArgs()
           
 int getDebugPort()
           
 java.lang.String getDebugSuspend()
           
 org.apache.tools.ant.taskdefs.Java getJavaTask()
           
 java.util.List<java.lang.String> getJvmargs()
           
 java.lang.String getMainClass()
           
 java.lang.String getResult()
           
 java.lang.String getStderr()
           
 java.lang.String getStdout()
           
 void initArgs(java.util.List<java.lang.String> args)
          Invoke if any arguments to main are required.
 void initArgs(java.lang.String... args)
          Invoke if any arguments to main are required.
 void initClasspath(ArgRunnable<org.apache.tools.ant.types.Path> config)
          Invoke if the classpath should be configured.
 void initDebug(int port, boolean suspend)
          Invoke if debugging is required.
 void initFork(java.lang.String maxMemory, boolean spawn)
          Invoke this method if the virtual machine should fork.
 void initJvmargs(java.util.List<java.lang.String> jvmargs)
          Invoke if any virtual machine arguments are required.
 void initJvmargs(java.lang.String... jvmargs)
          Invoke if any virtual machine arguments are required.
 void initLocalJmx()
          Invoke if local jmx connectivity is required.
 void initLogging(java.io.File logFile, int level)
          Enables logging to the specified log file at Project.MSG_INFO level.
 void initRemoteJmx(java.lang.Integer port)
          Invoke if remote jmx connectivity is required.
 void initWeaving(java.io.File weaverJar)
          Invoke if loadtime weaving is required.
 boolean isSuccess()
          It only makes sense to call this method from a forked but non-spawned vm.
 void setMainClass(java.lang.String mainClass)
          Sets the main class on the underlying ant task.
 java.lang.String toString()
           
 void writeOutput()
          When forking a vm, all the output from the forked vm seems to get buffered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StartVmCommand

public StartVmCommand()
Method Detail

setMainClass

public void setMainClass(java.lang.String mainClass)
Sets the main class on the underlying ant task.

Parameters:
mainClass -

initLogging

public void initLogging(java.io.File logFile,
                        int level)
Enables logging to the specified log file at Project.MSG_INFO level.

Parameters:
logFile -

initFork

public void initFork(java.lang.String maxMemory,
                     boolean spawn)
Invoke this method if the virtual machine should fork.

Parameters:
maxMemory - specify the maximum memory in the format used by the javaTask tool
spawn - whether or not the process should be spawned i.e. outlive the start-vm process

initArgs

public void initArgs(java.lang.String... args)
Invoke if any arguments to main are required.

Parameters:
args -

initArgs

public void initArgs(java.util.List<java.lang.String> args)
Invoke if any arguments to main are required.

Parameters:
args -

initJvmargs

public void initJvmargs(java.lang.String... jvmargs)
Invoke if any virtual machine arguments are required.

Parameters:
jvmargs -

initJvmargs

public void initJvmargs(java.util.List<java.lang.String> jvmargs)
Invoke if any virtual machine arguments are required.

Parameters:
jvmargs -

initClasspath

public void initClasspath(ArgRunnable<org.apache.tools.ant.types.Path> config)
Invoke if the classpath should be configured. Because invoking methods don't have the ability to create the concrete Path instance, they instead supply a ClasspathConfig instance containing instructions on how to configure the path.

Parameters:
config -

initDebug

public void initDebug(int port,
                      boolean suspend)
Invoke if debugging is required.

Parameters:
port - the port that will accept a debugger connection
suspend - whether or not the virtual machine will suspend until a debugger connection is made

initWeaving

public void initWeaving(java.io.File weaverJar)
Invoke if loadtime weaving is required.

Parameters:
weaverJar - the location of the aspectj weaver library

initLocalJmx

public void initLocalJmx()
Invoke if local jmx connectivity is required.


initRemoteJmx

public void initRemoteJmx(java.lang.Integer port)
Invoke if remote jmx connectivity is required.

Parameters:
port - the port that the jmx agent will be listening for connections on

getMainClass

public java.lang.String getMainClass()

getStdout

public java.lang.String getStdout()

getStderr

public java.lang.String getStderr()

getResult

public java.lang.String getResult()

getJavaTask

public org.apache.tools.ant.taskdefs.Java getJavaTask()

getDebugSuspend

public java.lang.String getDebugSuspend()

getDebugPort

public int getDebugPort()

getArgs

public java.util.List<java.lang.String> getArgs()

getJvmargs

public java.util.List<java.lang.String> getJvmargs()

execute

public void execute()

writeOutput

public void writeOutput()
When forking a vm, all the output from the forked vm seems to get buffered. Not sure if this is down to javaTask or to the ant Java task. Either way when the forked vm has exited, the buffered output can be written using this method.


isSuccess

public boolean isSuccess()
It only makes sense to call this method from a forked but non-spawned vm. Remember that a spawned vm will outlive the calling process.

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object