|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 2
A step is rendered in this general form:
<step
type=[type name]>
[parameter]
.
.
.
</step>
A step's type indicates what action the agent completes. A step can have zero or more parameters that exchange data with the step. Parameters come in three flavors:
This arrangement should look familiar if you've used CORBA before.
Consider the following step:
<step type="license"> <in> This software is Copyright (c) 2000, Todd Sundsted. Use of this software implies agreement with the terms of this license. Yada, yada, yada... </in> <out name="license_choice"/> </step>
This step is named "accept_license" and has two parameters. The first, an in parameter, contains the text of the license agreement. The second, an out parameter,
contains the user's response to the license agreement. A variable called "license_choice" stores this parameter. Other steps can access this variable.
When an instance of the LocalDirector class is used as a director, the parameters are placed in an array, and the array is passed from the director to the agent.
The agent implements and modifies the array's contents. When the method call returns, the director will have access to the
changes made by the agent.
When an instance of the RemoteDirector class is used as a director, the parameters are put in an array that is serialized and passed across the RMI connection.
This serialization affects a pass-by copy of the entire array. The agent can still implement and modify the array's contents,
but the director cannot see the changes without some extra work.
Here is some typical agent code:
public
void
performAction(String stringName, Object [] rgobjectParameters) {
.
.
rgobjectParameters[0] = "...";
.
}
The modification of the array's contents will not work when RMI is involved. I introduced the nonpublic AgentProxy class, which works behind the scenes to overcome this problem. Its performAction() method wraps the call to an agent's performAction() method and returns the modified array of objects. It looks like this:
public Object []
performAction(String stringName, Object [] rgobjectParameters) {
.
.
agent.performAction(stringName, rgobjectParameters);
.
.
return rgobjectParameters;
}
The RemoteDirector instance reads the modified values from the returned array, rather than the parameter array. The client never notices a difference.
Read more about Tools & Methods in JavaWorld's Tools & Methods section.