Hi,
With VC0 4.1, I have a plugin method written in Java. I would like this method to return an object that Orchestrator (VCO) will see as a javascript properties object, directly without going through serialization or other processing...
To do so:
- What class of java object my plugin method should return?
- what do I use as return-type attribute when declaring my method in the VSO.xml file?
<method script-name="myMethod" java-name="myMethod" return-type="????">
Thanks in advance.
Arnaud
Hi Arnaud,
You're right, the object that your method returns must be Hashtable actually (I was thinking that Properties should be valid also since it extends Hashtable).
Try with:
public Hashtable<String, Object> getInfosInProperties() {
Hashtable<String, Object> retMap = new Hashtable<String, Object>();
retMap.put("key1", "valeur 1");
retMap.put("key2", new Long(2));
retMap.put("key3", true);
return retMap;
}
The vso.xml file is fine with "Properties". And you'll get a Properties scripting object from the vCO scripting API.
I hope it helps.
Sergio
Hi Arnaud,
Your Java method should return a java.util.Properties (or java.util.Hashtable) object.
And your vso.xml file declaration should look like:
<method script-name="myMethod" java-name="myMethod" return-type="Properties">
I hope it helps.
Sergio
Hi Sergio,
Thanks for your answer.I gave it a try but my method still does not seem to return a Javascript Properties.
I wrote my method so that it returns a java.util.Properties :
public Properties getInfosInProperties() {
Properties retMap = new Properties();
retMap.put("key1", "valeur 1");
retMap.put("key2", new Long(2));
retMap.put("key3", true);
return retMap;
}
And I described it in the vso.xml :
<method script-name="getInfosInProperties" java-name="getInfosInProperties" return-type="Properties">
But I do not get a Properties object when I call it from a Javascript action in VCO :
Here is a test script
[...]
var map = myServiceFromMyPluggin.getInfosInProperties();
var className = System.getObjectClassName(map);
var pluginName = System.getObjectPluginName(map);
var type = System.getObjectType(map);
System.log("class name : " + className);
System.log("plugin name : " + pluginName);
System.log("type : " + type);
Here is what I get in the log:
[2012-03-15 10:29:45.125] [I] class name : Object
[2012-03-15 10:29:45.125] [I] plugin name : Server
[2012-03-15 10:29:45.125] [I] type : null
I should have got the following log if the returned object was a javascript Properties.
[2012-03-15 10:52:47.179] [I] class name : Properties
[2012-03-15 10:52:47.179] [I] plugin name : Server
[2012-03-15 10:52:47.179] [I] type : Properties
Arnaud
Hi Arnaud,
You're right, the object that your method returns must be Hashtable actually (I was thinking that Properties should be valid also since it extends Hashtable).
Try with:
public Hashtable<String, Object> getInfosInProperties() {
Hashtable<String, Object> retMap = new Hashtable<String, Object>();
retMap.put("key1", "valeur 1");
retMap.put("key2", new Long(2));
retMap.put("key3", true);
return retMap;
}
The vso.xml file is fine with "Properties". And you'll get a Properties scripting object from the vCO scripting API.
I hope it helps.
Sergio
Hi Sergio,
It works! This is great. You saved me hours.
Thank you!
Arnaud
Hi!
Thank you both for this great thread! I think it can save other people hours of time, too
Could please a forum moderator COPY this thread to the Orchestrator Plugin section
http://communities.vmware.com/community/vmtn/developer/forums/orchestrator
THX!
Cheers,
Joerg