I am building an xml scripting framework so that two devices can execute
commands on each others platforms. Below is the basic structure of the
framework. An Application can have components that in turn have Behaviors
and Controls. The behaviors and controls can expose listeners such that the
one can respond to conditions of the other.
My problem is that declaring a listener in xml causes the Unmarshaller to
create two instances of the listening class, it does not know that the
listener is actually just a reference to another object in the framework.
The xml below would be one situation where a behavior "myBehavior" is
listening for value changes on myControl. When unmarshaled two instances of
myBehavior will be created.
<application>
<component>
<behavior name="myBehavior">
<control name="myControl" value...>
<server-event name="onValueChange">
<listener name="myBehavior"
xsi:type="org.xoscript.server.Behavior">
</server-event>
</control>
</component>
</application>
I have been playing with an idea that a listener could have a collection of
command elements. These command elements would have data about the
returnType, Object, MethodName and arguments needed to execute one command
in a chain of commands.
If I created an object that could store instances of itself in a chain of
objects, each object would be responsible for executing one command in the
chain. Lets say that when the event is fired on the listener in any normal
code the notify method of that listener would be passed an instance of the
class that caused the event.
Ok, if each command object mentioned above were to have data about four
things.
CommandObject co = new CommandObject();
co.setReturnType("org.xoscript.server.Component");
co.setObjectToCall("theObjectInstanceCreatingThisCommand");
co.setMethodToCall("getComponentContext");
co.setArgsForMethod("");
and so on... and so on......
calling co.setCommand(co) would return a new instance of CommandObject with
the previous one stored as an attribute of CommandObject thus creating a
chain. The xml would look something like this.
<application>
<component>
<behavior name="myBehavior">
<control name="myControl" value...>
<server-event name="onValueChange">
<listener name="myBehavior"
xsi:type="org.xoscript.server.Behavior">
<command-object return="" object="" method="" args="">
<command-object return="" object="" method="" args="">
</listener>
</server-event>
</control>
</component>
</application>
When the parser created an instance of commandObject it could be called by
the event object such that it would return the original listener.
Any ideas are welcomed.
Bryan LaPlante
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user