This topic provides reference information about the object classes of the ActiveX to Enterprise Java Beans (EJB) bridge.
JClassFactory is the object used to access the majority of Java Virtual Machine (JVM) features. This object handles JVM initialization, accesses classes and creates class instances (objects). The majority of tasks for accessing your Java classes and objects are handled with the JClassProxy and JObjectProxy objects:
Initializes the JVM environment using an array of strings that represent the command line parameters you normally send to the java.exe file.
If you have invalid parameters in the XJBInit() string array, the following error is displayed:
Error: 0x6002 "XJBJNI::Init() Failed to create VM" when calling XJBInit()If you have C++ logging enabled, the activity log displays the invalid parameter.
Uses the current thread class loader to load the specified fully qualified class name and returns a JClassProxy object representing the Java Class object.
Creates a Class instance for the specified JClassProxy object using the parameters supplied to call the Class constructor. For more information about using the JMethodArgs method, see ActiveX to EJB bridge, calling Java methods.
JObjectProxy NewInstance(JClassFactory obj, Variant vArg1, Variant vArg2, Variant vArg3, ...) JObjectProxy NewInstance(JClassFactory obj, JMethodArgs args)
Returns a JMethodArgs object (Class instance).
You can create a JClassProxy object from the JClassFactory.FindClass() method and from any Java method call that normally return a Java Class object. You can use this object as if you had direct access to the Java Class object. All of the class static methods and fields are accessible as are the java.lang.Class methods. In case of a clash between static method names of the reflected user class and those of the java.lang.Class (for example, getName()), the reflected static methods would execute first.
For example, the following is a static method called getName(). The java.lang.Class object also has a method called getName():
class foo{ foo(){}; public static String getName(){return "abcdef";} public static String getName2(){return "ghijkl";} public String toString2(){return "xyz";} }
... Dim clsFoo as Object set clsFoo = oXJB.FindClass("foo") clsFoo.getName() ' Returns "abcdef" from the static foo class clsFoo.getName2() ' Returns "ghijkl" from the static foo class clsFoo.toString() ' Returns "class foo" from the java.lang.Class object. oFoo = oXJB.NewInstance(clsFoo) oFoo.toString() ' Returns some text from the java.lang.Object's ' toString() method which foo inherits from. oFoo.toString2() ' Returns "xyz" from the foo class instance
You can create a JObjectProxy object from the JClassFactory.NewInstance() method, and can be created from any Java method call that normally returns a Class instance object. You can use this object as if you had direct access to the Java object and can access all the static methods and fields of the object. All of object instance methods and fields are accessible (including those accessible through inheritance).
The JMethodArgs object is created from the JClassFactory.GetArgsContainer() method. Use this object as a container for method and constructor arguments. You must use this object when overriding the object type when calling a method (for example, when sending a java.lang.String JProxyObject type to a constructor that normally takes a java.lang.Object type).
You can use two groups of methods to add arguments to the collection: Add and
Set. You can use Add to add arguments in the order that they are declared. Alternatively, you can use Set to set an argument based on its position in the argument list (where the first argument is in position 1).
For example, if you had a Java Object Foo that took a constructor of Foo (int, String, Object), you could use a JMethodArgs object as shown in the following code extract:
... Dim oArgs as Object set oArgs = oXJB.GetArgsContainer() oArgs.AddInt(CLng(12345)) oArgs.AddString("Apples") oArgs.AddObject("java.lang.Object", oSomeJObjectProxy) Dim clsFoo as Object Dim oFoo as Object set clsFoo = oXJB.FindClass("com.mypackage.foo") set oFoo = oXJB.NewInstance(clsFoo, oArgs) ' To reuse the oArgs object, just clear it and use the add method ' again, or alternatively, use the Set method to reset the parameters ' Here, we will use Set oArgs.SetInt(1, CLng(22222)) oArgs.SetString(2, "Bananas") oArgs.SetObject(3, "java.lang.Object", oSomeOtherJObjectProxy) Dim oFoo2 as Object set oFoo2 = oXJB.NewInstance(clsFoo, oArgs)
Adds an arbitrary object to the argument container in the next available position, casting the object to the class name specified in the first parameter. Arrays are specified using the traditional [] syntax; for example:
AddObject("java.lang.Object[][]", oMy2DArrayOfFooObjects)or
AddObject("int[]", oMyArrayOfInts)
Adds a primitive byte value to the argument container in the next available position.
Adds a primitive boolean value to the argument container in the next available position.
Adds a primitive short value to the argument container in the next available position.
Adds a primitive int value to the argument container in the next available position.
Adds a primitive long value to the argument container in the next available position.
Adds a primitive float value to the argument container in the next available position.
Adds a primitive double value to the argument container in the next available position.
Adds a primitive char value to the argument container in the next available position.
Adds the argument in string form to the argument container in the next available position.
Adds an arbitrary object to the argument container in the specified position casting it to the class name or primitive type name specified in the second parameter. Arrays are specified using the traditional [] syntax; for example:
SetObject(1, "java.lang.Object[][]", oMy2DArrayOfFooObjects)or
SetObject(2, "int[]", MyArrayOfInts)
Sets a primitive byte value to the argument container in the position specified.
Sets a primitive boolean value to the argument container in the position specified.
Sets a primitive short value to the argument container in the position specified.
Sets a primitive int value to the argument container in the position specified.
Sets a primitive long value to the argument container in the position specified.
Sets a primitive float value to the argument container in the position specified.
Sets a primitive double value to the argument container in the position specified.
Sets a primitive char value to the argument container in the position specified.
Sets a java.lang.String value to the argument container in the position specified.
Returns the value of an argument at a specific argument position.
Removes all arguments from the container and resets the next available position to one.
Returns the number of arguments in the container.