com.novell.ecb
Interface Command
- All Superinterfaces:
- java.io.Serializable
- All Known Implementing Classes:
- SecretBean, SecretStoreBean
- public interface Command
- extends java.io.Serializable
A command encapsulates a business logic task.
This Command interface provides the client interface for the
most generic form of command, which is the contract between the command
client and the command implementation.
Commands provide the following advantages over conventional
client-server interaction:
- They provide a simple uniform way to call business logic,
regardless of the programming style used for the business logic
(eg, EJB, JDBC, stored procedures, connectors, file access).
- They reduce the number of messages when a client interacts
with a remote server, often replacing several messages that
do small pieces of work with a single message that does all
of them.
- They provide local-remote transparency (ie, the command client
code is independent of whether the command is executed in the
client's JVM or a remote JVM).
A Command has the following states during its lifecycle:
- New: Just after the command has been created (via a new,
a factory create, Beans.instantiate, etc.).
In this state the isReady method should return false
and the get methods should not be called.
- Initialized: Just after all required input properties have
been set.
In this state the isReady method should return true
and the get methods should not be called.
- Executed: Just after the execute method has been called.
In this state the isReady method should return true
and the get methods should work.
The only enforcement of these states is that the
Command's implementation of the execute method calls
the command's isReady method prior to executing the command.
In this case, if isReady returns false then an
NotReadyException is thrown.
Any other enforcement of these states is up to the command writer.
|
Method Summary |
void |
execute()
Performs the task encapsulated by this command. |
boolean |
isReady()
Allows the command client and the command runtime to ask
the command whether all required input properties have been set. |
void |
reset()
Resets the output properties. |
isReady
public boolean isReady()
- Allows the command client and the command runtime to ask
the command whether all required input properties have been set.
It is called in the client JVM prior to execution being given
to the CommandTarget for execution.
- Returns:
- true, if the command is in the initialized or
executed state; false, otherwise.
execute
public void execute()
throws CommandException
- Performs the task encapsulated by this command.
This moves the command from the initialized to the executed state.
If the isReady method returns false,
this throws a NotReadyException.
- Throws:
CommandException - The superclass for all command
exceptions.
reset
public void reset()
- Resets the output properties.
After the call, get methods return the default values they had
prior to calling the execute method.
It provides a convenient and efficient way to reuse the same
command instance with changes in some input properties or in
the CommandTarget.
Copyright © 2001-2003 Novell, Inc. All Rights Reserved.