Class Command

  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.thread.ThreadService
          extended bySK.gnome.dwarf.main.Command
All Implemented Interfaces:
java.lang.Runnable, Service
Direct Known Subclasses:
AuthCmd, CSCmd, DebugCmd, DumpCmd, ExecCmd, HelpCmd, LSCmd, NSLookupCmd, ParamCmd, PasswdCmd, PolicyCmd, PropertiesCmd, ReportCmd, RestartCmd, ShutdownCmd, ThreadsCmd, TraceCmd

public abstract class Command
extends ThreadService

Defines abstract console command.

Command services may be added (plugged-in) to any Server implementation. The Console service then makes them accessible to the end-user through one of the input channels (e.g. an interactive command prompt, a remote network connection, etc.), or they can be executed directly by an other service.

The abstract getDescription() and execute(Subject, Service, String[], Writer) methods must be implemented by the subclasses.

The printHelp(PrintWriter) method may be overriden to provide a detailed instructions on the command usage.

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
Constructor Summary
Command(java.lang.String name)
          Creates a new Command.
Method Summary
protected abstract  void execute( subject, Service service, java.lang.String[] args, out)
          Executes the command.
abstract  java.lang.String getDescription()
          Returns the command description.
 void printHelp( 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, init, 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


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

The name of the command is typically a name by which the command will be invoked.

Method Detail


public abstract java.lang.String getDescription()
Returns the command description.

It should return a short one-line command description.

the command description


public void printHelp( out)
Prints the command help.

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

out - the output Writer


protected abstract void execute( subject,
                                Service service,
                                java.lang.String[] args,
                         throws CommandException
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.

subject - the subject executing the command
service - the current working service
args - the command arguments
out - the output stream
CommandException - if the command fails for any reason

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