VMware Cloud Community
JackBS
Enthusiast
Enthusiast

Java Collection Classes in vCO

From the documentation I see by default classes from java.util.* available for vCO Java Script Engine.

I am using vCO 5.1 appliance version.

Can any one post an example on how to use HashMap or ArrayList directly from vCO java script.

I tried this kind of pattern. But no use.

     var aList = new ArrayList();    

     aList.add('Hello');

Appreciate any help.

0 Kudos
5 Replies
igaydajiev
VMware Employee
VMware Employee

var aList = new Array();   

aList.push('Hello');

for (var idx in aList ) {

  var item =  aList[idx];

  System.log(" " +  idx + " is " +item);

}

0 Kudos
JackBS
Enthusiast
Enthusiast

Yes, I am aware of Array() Class.

But I am trying to see if I can directly use any class from java.util.* package. From the documentation that seems to be possible. But there is no sign of any simple example.

0 Kudos
igaydajiev
VMware Employee
VMware Employee

You can check following post https://communities.vmware.com/message/1808053

Rhino engine was updated in the vCO 5.5 but i believe it is still valid.

You can check here http://stackoverflow.com/questions/17592274/java-object-as-prototype-in-rhino

unfortunately I am not able to test it now...

JackBS
Enthusiast
Enthusiast

Thanks,  that does help.

Is there any limitation on the classes which we can use (or) we can use any class which is available in java.util.*

0 Kudos
igaydajiev
VMware Employee
VMware Employee

Beside limitations introduced by Rhino engine itself there is specific configuration file controlling access to Java classes..You can find more details here vSphere Documentation Center


....By default, Orchestrator restricts JavaScript access to a limited set of Java classes. If you require JavaScript access to a wider range of Java classes, you must set an Orchestrator system property to allow this access.

0 Kudos