The only channel of communication between the server and the client is between the WizardTreeManager and the root WizardState objects. This communication link enables client objects (panels, nodes, the WizardTreeManager) to call server object methods. The use of the Mediator design pattern on both the client and the server eliminates the requirement of multiple object references between the client and the server. As we will see in Remote Wizards, this is a vital property of client-server communication that makes a remote client possible.
The WizardTreeManager maintains a reference to a WizardState object. This object reference points to the root WizardState and can be used directly by the WizardTreeManager. Other objects within the client have access to the WizardState object and its methods through calls to the WizardTreeManager.callServerObjectMethod method. This method uses reflection to invoke the specified method.
Similarly, the WizardState object maintains a reference to the WizardTreeManager. The server has a method, WizardState.callClientObjectMethod, that is able to call object methods in the client.
Reflection is a scheme in which an object method may be invoked at runtime by knowing the method name and argument list. Ordinarily, the calling object is compiled against the target object, and any error in the method use is caught at compile time. Reflection defers linking and error checking until runtime, allowing a loose binding between the calling object and the target object.
The Java reflection API requires a reference to the target object, which presents a problem with the wizard architecture. It is not possible for a client panel to retrieve a reference to a server-side object. This is to avoid multiple points of contact between the server and client. To get the message to the correct object, a routing object is used.
The Route is an object that contains information that directs messages to the correct object. Each panel in the client panel tree has its own Route object. Each WizardState in the server WizardState tree has its own route. Each panel's Route object routes server messages to the correct WizardState object. Server objects do not call client objects unless the client object being called sends its Route object to the server.
Through the routing mechanism and calls to callServerObjectMethod, the client panels can call virtually any WizardState method without violating the client/server model. The client objects must not call any method or use any object that could not be used within a web browser. If that rule is broken, the wizard will only be able to work locally.
Last modified: Fri Nov 25 16:48 PDT