org.openide.loaders
Class ExecSupport

java.lang.Object
  |
  +--org.openide.loaders.ExecSupport
All Implemented Interfaces:
ArgumentsCookie, DebuggerCookie, ExecCookie, Node.Cookie

public class ExecSupport
extends Object
implements ExecCookie, ArgumentsCookie, DebuggerCookie

Support for execution of a class file. Looks for the class with the same base name as the primary file, locates a main method in it, and starts it.


Field Summary
protected  MultiDataObject.Entry entry
          entry to be associated with
static String PROP_DEBUGGER_TYPE
          Name of property providing a custom DebuggerType for a file.
static String PROP_EXECUTION
          Name of property providing a custom Executor for a file.
static String PROP_FILE_PARAMS
          Name of property providing argument parameter list.
 
Constructor Summary
ExecSupport(MultiDataObject.Entry entry)
          Create new support for given entry.
 
Method Summary
 void addProperties(Sheet.Set set)
          Helper method that creates default properties for execution of a given support.
protected  boolean checkCompiled()
          Deprecated. The check should be done in an action - ExecAction, ...
 void debug(boolean stopOnMain)
          Start debugging of associated object.
protected  boolean debugFailed(DebuggerException ex)
          Called when invocation of the debugger fails.
protected  DebuggerType defaultDebuggerType()
          This method allows subclasses to override the default debugger type they want to use for debugging.
protected  Executor defaultExecutor()
          This method allows subclasses to override the default executor they want to use for debugging.
 String[] getArguments()
          Get the arguments.
static String[] getArguments(MultiDataObject.Entry entry)
          Get the arguments associated with a given entry.
static DebuggerType getDebuggerType(MultiDataObject.Entry entry)
          Retrieves the debugger type for this entry.
static Executor getExecutor(MultiDataObject.Entry entry)
          Get the executor for a given file object.
static void setArguments(MultiDataObject.Entry entry, String[] args)
          Set execution arguments for a given entry.
 void setArguments(String[] args)
          Set the arguments.
static void setDebuggerType(MultiDataObject.Entry entry, DebuggerType type)
          Assignes a debugger type to an entry.
static void setExecutor(MultiDataObject.Entry entry, Executor exec)
          Set the executor for a given file object.
 void start()
          Start execution.
protected  boolean startFailed(IOException ex)
          Called when invocation of the executor fails.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_FILE_PARAMS

public static final String PROP_FILE_PARAMS
Name of property providing argument parameter list.

PROP_EXECUTION

public static final String PROP_EXECUTION
Name of property providing a custom Executor for a file.

PROP_DEBUGGER_TYPE

public static final String PROP_DEBUGGER_TYPE
Name of property providing a custom DebuggerType for a file.

entry

protected MultiDataObject.Entry entry
entry to be associated with
Constructor Detail

ExecSupport

public ExecSupport(MultiDataObject.Entry entry)
Create new support for given entry. The file is taken from the entry and is updated if the entry moves or renames itself.
Parameters:
entry - entry to create instance from
Method Detail

start

public void start()
Description copied from interface: ExecCookie
Start execution.
Specified by:
start in interface ExecCookie

debug

public void debug(boolean stopOnMain)
           throws DebuggerException
Description copied from interface: DebuggerCookie
Start debugging of associated object.
Specified by:
debug in interface DebuggerCookie
Following copied from interface: org.openide.cookies.DebuggerCookie
Parameters:
stopOnMain - if true, debugger stops on the first line of debugged code
Throws:
DebuggerException - if the session cannot be started

startFailed

protected boolean startFailed(IOException ex)
Called when invocation of the executor fails. Allows to do some modifications to the type of execution and try it again.
Parameters:
ex - exeception that occured during execution
Returns:
true if the execution should be restarted

debugFailed

protected boolean debugFailed(DebuggerException ex)
Called when invocation of the debugger fails. Allows to do some modifications to the type of debugging and try it again.
Parameters:
ex - exeception that occured during execution
Returns:
true if the debugging should be started again

checkCompiled

protected boolean checkCompiled()
Deprecated. The check should be done in an action - ExecAction, ...

Check if this object is up to date or in need of compilation. Should compile it if necessary.

The default implementation checks whether CompilerCookie is provided and if so, creates a job and compiles the object. This behavior may be overridden by subclasses.

Returns:
true if the object was successfully brought up to date, false if the attempt failed (and it may be still be out of date)

defaultDebuggerType

protected DebuggerType defaultDebuggerType()
This method allows subclasses to override the default debugger type they want to use for debugging.
Returns:
current implementation returns DebuggerType.getDefault ()

defaultExecutor

protected Executor defaultExecutor()
This method allows subclasses to override the default executor they want to use for debugging.
Returns:
current implementation returns Executor.getDefault ()

setExecutor

public static void setExecutor(MultiDataObject.Entry entry,
                               Executor exec)
                        throws IOException
Set the executor for a given file object. Uses file attributes to store this information.
Parameters:
entry - entry to set the executor for
exec - executor to use
Throws:
IOException - if executor cannot be set

getExecutor

public static Executor getExecutor(MultiDataObject.Entry entry)
Get the executor for a given file object.
Parameters:
entry - entry to obtain the executor for
Returns:
executor associated with the file, or null if the default should be used

setArguments

public void setArguments(String[] args)
                  throws IOException
Description copied from interface: ArgumentsCookie
Set the arguments.
Specified by:
setArguments in interface ArgumentsCookie
Following copied from interface: org.openide.cookies.ArgumentsCookie
Parameters:
args - the arguments. May be empty but not null.
Throws:
IOException - if the arguments could not be set

setArguments

public static void setArguments(MultiDataObject.Entry entry,
                                String[] args)
                         throws IOException
Set execution arguments for a given entry.
Parameters:
entry - the entry
args - array of arguments
Throws:
IOException - if arguments cannot be set

getArguments

public String[] getArguments()
Description copied from interface: ArgumentsCookie
Get the arguments.
Specified by:
getArguments in interface ArgumentsCookie
Following copied from interface: org.openide.cookies.ArgumentsCookie
Returns:
the arguments. May be empty but not null.

getArguments

public static String[] getArguments(MultiDataObject.Entry entry)
Get the arguments associated with a given entry.
Parameters:
entry - the entry
Returns:
the arguments, or an empty array if no arguments are specified

setDebuggerType

public static void setDebuggerType(MultiDataObject.Entry entry,
                                   DebuggerType type)
                            throws IOException
Assignes a debugger type to an entry.
Parameters:
entry - the object's entry
type - the debugger type for this entry
Throws:
IOException - if arguments cannot be set

getDebuggerType

public static DebuggerType getDebuggerType(MultiDataObject.Entry entry)
Retrieves the debugger type for this entry.
Parameters:
entry - the entry
Returns:
the debugger type or null if no type assigned

addProperties

public void addProperties(Sheet.Set set)
Helper method that creates default properties for execution of a given support. Includes properties to set the executor; debugger; and arguments.
Parameters:
set - sheet set to add properties to


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