org.openide.execution
Class ProcessExecutor

java.lang.Object
  |
  +--org.openide.ServiceType
        |
        +--org.openide.execution.Executor
              |
              +--org.openide.execution.ProcessExecutor
All Implemented Interfaces:
Serializable

public class ProcessExecutor
extends Executor

Executes a class externally (in a separate process). Provides basic implementation that allows to specify the process to execute, its parameters and also to substitute the content of repositorypath, classpath, bootclasspath and librarypath. This is done by inner class Format.

The behaviour described here can be overriden by subclasses to use different format (extend the set of recognized tags), execute the process with additional environment properties, etc.

See Also:
Serialized Form

Inner Class Summary
static class ProcessExecutor.Format
          Default format that can format tags related to execution.
 
Inner classes inherited from class org.openide.ServiceType
ServiceType.Handle, ServiceType.Registry
 
Field Summary
protected  NbProcessDescriptor externalExecutor
          external process - like java.exe - property
 
Fields inherited from class org.openide.ServiceType
PROP_NAME
 
Constructor Summary
ProcessExecutor()
          Create a new executor.
 
Method Summary
protected  Process createProcess(DataObject obj)
          Called to create the java.lang.Process for given data object.
protected  Process createProcess(ExecInfo info)
          Called to create the java.lang.Process for given exec info.
 ExecutorTask execute(DataObject obj)
          Executes given dataobject by creating new process in underlying operating system.
 ExecutorTask execute(ExecInfo info)
          Execute a class given by name with some arguments in this executor.
 boolean getAppendEnvironmentVariables()
          Check if environment variables will be appended or replaced.
 NbClassPath getBootClassPath()
          Getter for boot class path associated with this executor.
 NbClassPath getClassPath()
          Getter for class path associated with this executor.
 String[] getEnvironmentVariables()
          Get environment variables.
 NbProcessDescriptor getExternalExecutor()
          Get the current external execution command.
 HelpCtx getHelpCtx()
          Get context help for this service type.
 NbClassPath getLibraryPath()
          Getter for repository path.
 NbClassPath getRepositoryPath()
          Getter for repository path.
 File getWorkingDirectory()
          Get the working directory.
 void setAppendEnvironmentVariables(boolean nue)
          Set whether environment variables should be appended and replaced.
 void setBootClassPath(NbClassPath path)
          Setter for boot class path for this executor.
 void setClassPath(NbClassPath path)
          Setter for class path for this executor.
 void setEnvironmentVariables(String[] nue)
          Set environment variables.
 void setExternalExecutor(NbProcessDescriptor desc)
          Set a new external execution command.
 void setWorkingDirectory(File nue)
          Set the working directory.
 
Methods inherited from class org.openide.execution.Executor
executors, find, find, getDefault, needsIO
 
Methods inherited from class org.openide.ServiceType
addPropertyChangeListener, clone, createClone, displayName, firePropertyChange, getName, removePropertyChangeListener, setName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

externalExecutor

protected NbProcessDescriptor externalExecutor
external process - like java.exe - property
Constructor Detail

ProcessExecutor

public ProcessExecutor()
Create a new executor.
Method Detail

setExternalExecutor

public void setExternalExecutor(NbProcessDescriptor desc)
Set a new external execution command.
Parameters:
desc - the settings for the new external executor

getHelpCtx

public HelpCtx getHelpCtx()
Description copied from class: ServiceType
Get context help for this service type.
Overrides:
getHelpCtx in class Executor
Following copied from class: org.openide.ServiceType
Returns:
context help

getExternalExecutor

public NbProcessDescriptor getExternalExecutor()
Get the current external execution command. The default Java launcher associated with this VM's installation will be used, and the user repository entries will be used for the class path if customized command is not set.
Returns:
the settings for the current external executor

getClassPath

public NbClassPath getClassPath()
Getter for class path associated with this executor.

setClassPath

public void setClassPath(NbClassPath path)
Setter for class path for this executor.

getBootClassPath

public NbClassPath getBootClassPath()
Getter for boot class path associated with this executor.

setBootClassPath

public void setBootClassPath(NbClassPath path)
Setter for boot class path for this executor.

getRepositoryPath

public NbClassPath getRepositoryPath()
Getter for repository path. It is immutable reflecting NbClassPath.createRepositoryPath (). Is here only to be displayed in property sheet.

getLibraryPath

public NbClassPath getLibraryPath()
Getter for repository path. It is immutable reflecting NbClassPath.createLibraryPath (). Is here only to be displayed in property sheet.

getEnvironmentVariables

public String[] getEnvironmentVariables()
Get environment variables.
Returns:
the NAME=VALUE pairs, or null (typically, inherit that of parent)

setEnvironmentVariables

public void setEnvironmentVariables(String[] nue)
Set environment variables.
Parameters:
nue - the new variables
See Also:
getEnvironmentVariables()

getAppendEnvironmentVariables

public boolean getAppendEnvironmentVariables()
Check if environment variables will be appended or replaced. If false (the default), when environment variables are specified, these are taken as is for the process' environment, matching the standard Java platform behavior. If true, any specified environment variables append to or replace those found in the IDE's own environment, permitting incremental changes.
Returns:
true if variables should be incremental
Since:
1.15

setAppendEnvironmentVariables

public void setAppendEnvironmentVariables(boolean nue)
Set whether environment variables should be appended and replaced.
Parameters:
nue - true if so
Since:
1.15
See Also:
getAppendEnvironmentVariables()

getWorkingDirectory

public File getWorkingDirectory()
Get the working directory. Note that using a nondefault working directory will only work on JDK 1.3.
Returns:
the working directory to use, or null (use that of parent)

setWorkingDirectory

public void setWorkingDirectory(File nue)
Set the working directory.
Parameters:
nue - the new directory
See Also:
getWorkingDirectory()

createProcess

protected Process createProcess(ExecInfo info)
                         throws IOException
Called to create the java.lang.Process for given exec info. Current implementation scans creates new Format with provided exec info and asks the current executor to start with that format.

Subclasses can override this to achieve the right behaviour, add system properties, own format, etc.

Parameters:
info - exec info
Returns:
the executed process
Throws:
IOException - if the action fails

createProcess

protected Process createProcess(DataObject obj)
                         throws IOException
Called to create the java.lang.Process for given data object. Current implementation simply extracts the exec info information from the data object and calls createProcess (ExecInfo) method.

Subclasses can override this to achive the right behaviour, add system properties, own format, etc.

Parameters:
obj - data object to execute
Returns:
the executed process
Throws:
IOException - if the action fails

execute

public ExecutorTask execute(ExecInfo info)
                     throws IOException
Description copied from class: Executor
Execute a class given by name with some arguments in this executor.
Overrides:
execute in class Executor
Following copied from class: org.openide.execution.Executor
Parameters:
info - information describing what to execute
Returns:
a task object that can be used to control the running process
Throws:
IOException - if the execution cannot be started (class is missing, etc.)

execute

public ExecutorTask execute(DataObject obj)
                     throws IOException
Executes given dataobject by creating new process in underlying operating system. This method in turn calls the createProcess (DataObject) method.
Overrides:
execute in class Executor
Parameters:
obj - object to execute
Returns:
the executed process
Throws:
IOException - if the action fails


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.