tweed.invocation
Class Command

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--tweed.invocation.Command
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled

public abstract class Command
extends org.apache.avalon.framework.logger.AbstractLogEnabled

The base class for implementing Command objects, which represent a server-side processing.

This is the typical lifecycle of a Command object:

  1. Instantiation is done client-side giving only a Context as input parameter. The Context object must be available in the application.
       MyConcreteCommand command = new MyConcreteCommand( context ) ;
         
    All fields are set to default values.
  2. Then, client code fills up input parameters, using setters defined in the concrete Command class. "Input" and "output" parameters mean from the server's point of view.
       command.setCustomerId( theId ) ;
         
  3. Once parameters in have been set, the client asks the method to execute:
       command.execute() ;
         
    The command "magically" appears on the server, with input (and in-out) parameters set to the same values as client-side. Output-only parameters have been cleaned up (reset to their default value). The command executes the body of its execute() method. This may set the value of output parameters.
  4. The updated fields are (output and in-out parameters) "magically" set in the invoked command, as we're back on the client-side. They can now be accessed using the getters. Input-only parameters are left same as before command execution.
       Customer result = command.getCustomer() ;
         
A Command object may be reused as many times as needed, but special care should be taken to not pollute one call with input parameter values remaining from a previous call.

Tagging fields used as input or output parameters:

Fields which do not respect constraints above won't be treated as parameters, they won't travel between client and server.

Serialization
A concrete Command does not need to be serializable, since fields will be extracted in another object for travelling between client and server. All fields used as input/output parameters MUST be serializable.

Use of Command as Model:
"Model" is used in the bindings. A concrete Command may be used as a Model.

Declaring a Command as nested class:
This is strictly forbidden.

Version:
$Id$
Author:
Laurent Caillette

Field Summary
static java.lang.String PARAM_IN_PREFIX
          "in_" is the prefix for tagging input parameters.
static java.lang.String PARAM_INOUT_PREFIX
          "in_out_" is the prefix for tagging input parameters.
static java.lang.String PARAM_OUT_PREFIX
          "out_" is the prefix for tagging output parameters.
static java.lang.String SERVERSIDE_CLASSNAME_PREFIX
           
 
Constructor Summary
protected Command(Context context)
           
 
Method Summary
protected  void doExecute()
          Override this method for the processings which should occur server-side.
 void execute()
           
 Context getContext()
           
 java.lang.Exception getFunctionalException()
           
 java.lang.String getServerSideClassName()
           
 boolean wasSuccess()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVERSIDE_CLASSNAME_PREFIX

public static final java.lang.String SERVERSIDE_CLASSNAME_PREFIX
See Also:
Constant Field Values

PARAM_IN_PREFIX

public static final java.lang.String PARAM_IN_PREFIX
"in_" is the prefix for tagging input parameters.

See Also:
Constant Field Values

PARAM_OUT_PREFIX

public static final java.lang.String PARAM_OUT_PREFIX
"out_" is the prefix for tagging output parameters.

See Also:
Constant Field Values

PARAM_INOUT_PREFIX

public static final java.lang.String PARAM_INOUT_PREFIX
"in_out_" is the prefix for tagging input parameters.

See Also:
Constant Field Values
Constructor Detail

Command

protected Command(Context context)
Method Detail

getContext

public final Context getContext()

getServerSideClassName

public java.lang.String getServerSideClassName()

doExecute

protected void doExecute()
                  throws FunctionalException
Override this method for the processings which should occur server-side.

FunctionalException

getFunctionalException

public final java.lang.Exception getFunctionalException()

wasSuccess

public final boolean wasSuccess()

execute

public final void execute()
                   throws FunctionalException
FunctionalException


Copyright © 2003 Laurent Caillette. All Rights Reserved.