Sun Java System Identity Manager - Calling Java Method on an Object?
It is quite clear how to call a method that passes an argument in Express i.e.
<invoke name='methodName' class='com.waveset.ui.ClassName'>
<ref>argument</ref>
</invoke>
Essentially this is the same as calling
methodName( argument );
How is is possible to call a method in a class that operates on the object i.e.
object.methodName( );
i.e.
com.waveset.object.GenericObject has a method called toMap( ) which returns the GenericObject back as a Map.
A User View is a GenericObject so how do you call a method on the User object i.e.
<ref>user</ref>.someMethod( ); or user.toMap( ); rather than
<invoke name='toMap' class='com.waveset.object.GenericObject'>
<ref>user</ref>
</invoke>
This will not work because there is no method called toMap that takes a GenericObject as a argument.
I can't find any documentation that addresses this issue.
# 1
The invoke tag is handled differently depending on its arguments.
<invoke name='methodName' class='com.something'><ref>someVariable</ref>
</invoke>
is calling static method methodName on class com.something and passes someVariable as an argument
If you leave the class name out of the invoke, it calls the method on the first variable within the tag (the object). The remaining variables act as arguments to the method.
Here's a trivial example. It creates a HashMap and then performs a 'get' on one of its keys (name)
<invoke name='get'><new class='java.util.HashMap'>
<map>
<s>name</s>
<s>Darth Vader</s>
<s>type</s>
<s>villain</s>
</map>
</new>
<s>name</s>
</invoke>
Here's a more complex example:
<new class='com.waveset.object.Resource'><invoke name='toXml'>
<invoke name='getObject' class='com.waveset.ui.FormUtil'>
<ref>:display.session</ref>
<s>Resource</s>
<s>Active Directory Resource Adapter</s>
</invoke>
</invoke>
</new>
This calls the static getObject method returns a com.waveset.object.PersistentObject, which in turn has toXML invoked on it (returning a java.lang.String serialized version of the object) which is then used as the argument for constructing a com.waveset.object.Resource object.
Jason