SK.gnome.dwarf.main.cmd
Class ExecCmd

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.thread.ThreadService
          extended bySK.gnome.dwarf.main.Command
              extended bySK.gnome.dwarf.main.cmd.ExecCmd
All Implemented Interfaces:
java.lang.Runnable, Service

public class ExecCmd
extends Command

Executes a batch command script.

This command executes other console commands read from the given file. Each single command must be on a separate line, empty lines and lines starting with '#' (comments) are ignored.

Enclose the filename argument in double quotes if it contains white spaces.

This command may be added only to Console instances.


Field Summary
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadService
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
ExecCmd(java.lang.String name)
          Creates a new ExecCmd.
 
Method Summary
protected  void execute(javax.security.auth.Subject subject, Service service, java.lang.String[] args, java.io.Writer out)
          Executes the command.
 java.lang.String getDescription()
          Returns the command description.
 void init(Server parent)
          Initializes the service.
 void printHelp(java.io.PrintWriter out)
          Prints the command help.
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadService
enableThread, finish, loop, run, setDaemon, shutdown, start, stop
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExecCmd

public ExecCmd(java.lang.String name)
Creates a new ExecCmd.

Method Detail

getDescription

public java.lang.String getDescription()
Description copied from class: Command
Returns the command description.

It should return a short one-line command description.

Specified by:
getDescription in class Command
Returns:
the command description

printHelp

public void printHelp(java.io.PrintWriter out)
Description copied from class: Command
Prints the command help.

By default it prints the string returned from the Command.getDescription() method. It may be overriden to provide more detailed help on the command usage.

Overrides:
printHelp in class Command
Parameters:
out - the output Writer

init

public void init(Server parent)
          throws ServiceException
Description copied from interface: Service
Initializes the service.

This method changes the service state to Service.INITIALIZED.

If the parent argument is not null, it means that the service is becomig a part of the server which the parent argument points to.

After a successful initialization the service can be started by invoking the Service.start() method, or it can be shut down by invoking the Service.shutdown() method.

Specified by:
init in interface Service
Overrides:
init in class GenericService
Throws:
ServiceException

execute

protected void execute(javax.security.auth.Subject subject,
                       Service service,
                       java.lang.String[] args,
                       java.io.Writer out)
                throws CommandException
Description copied from class: Command
Executes the command.

Executes the command action. This method is called by the console's Console.execute(Subject, String, Writer) method. The service parameter contains a reference to the current working service of the subject executing the command. Command arguments are passed in via the string array args and the command output is redirected to the out stream. The command should throw a CommandException in the case of an error.

Specified by:
execute in class Command
Parameters:
subject - the subject executing the command
service - the current working service
args - the command arguments
out - the output stream
Throws:
CommandException - if the command fails for any reason


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.