ActiveX to enterprise bean bridge classes
This topic provides reference information about the object classes of the ActiveX to enterprise bean bridge:
XJB.JClassFactory
JClassFactory is the object used to access the majority of JVM features. It handles JVM initialization, accessing classes and creating class instances (objects). The majority of tasks for accessing your Java classes and objects are handled with the JClassProxy and JObjectProxy objects.These are the methods in the JClassFactory class:
XJBInit(String astrJavaParameterArray())
Initializes the JVM environment using an array of strings that represent the command line parameters you would normally send to the java.exe file.For example:
Dim astrJavaProps(4) ' Get properties from the environment astrJavaProps(0) = oEnv("XJBJRE_CLASSPATH") astrJavaProps(1) = oEnv("XJBWAS_CLASSPATH") ' Set the initial context factory. astrJavaProps(2) = "-Djava.naming.factory.initial=" & strNAMING_FACTORY ' If you are talking to a secured server, you can setup the client SAS properties ' NOTE: For ASP, ALWAYS use the com.ibm.CORBA.loginSource parameter in the ' [WAS_HOME]\AppClient\properties\sas.client.props\ to one of the following: ' properties, keyfile or none astrJavaProps(3) = "-Dcom.ibm.CORBA.ConfigURL=file:/" & strWAS_HOME & "/properties/sas.client.props" astrJavaProps(4) = "-Xbootclasspath/p:" & oEnv("WAS_BOOTCLASSPATH")If you have invalid parameters in the XJBInit() string array, the following error results:
Error: 0x6002 "XJBJNI::Init() Failed to create VM" when calling XJBInit()If you have C++ logging enabled, the activity log displays the invalid parameter.
JClassProxy FindClass(String strClassName)
Uses the current thread class loader to load the specified fully qualified class name and returns a JClassProxy object representing the Java Class object.JObjectProxy NewInstance()
Creates a Class instance for the specified JClassProxy object using the parameters supplied to call the Class Constructor:JObjectProxy NewInstance(JClassFactory obj, Variant vArg1, Variant vArg2, Variant vArg3, ...) JObjectProxy NewInstance(JClassFactory obj, JMethodArgs args)For more information about using JMethodArgs, see Calling Java methods.
JMethodArgs GetArgsContainer()
Returns a JMethodArgs object (Class instance).
XJB.JClassProxy
You can create a JClassProxy object from the JClassFactory.FindClass() method and also from any Java method call that would normally return a Java class object. 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 methods from the user class take precedence.For example, the following class definition contains a static method called getName(). The java.lang.Class object also has a method called getName():
In Java:
class foo { foo() { } public static String getName() { return "abcdef"; } public static String getName2() { return "ghijkl"; } public String toString2() { return "xyz"; } }In Visual Basic:
... 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 instanceXJB.JObjectProxy
You can create a JObjectProxy object from the JClassFactory.NewInstance() method, and from any Java method call that would normally return a Class instance object. 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 the object instance methods and fields are accessible (including those accessible through inheritance).XJB.JMethodArgs
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 to a constructor that normally takes a java.lang.Object type).There are two groups of methods to add arguments to the collection: Add and Set. 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 example:
... 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 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)These are the methods in the JMethodArgs class:
AddObject (String strObjectTypeName, Object oArg)
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)AddByte (Byte byteArg)
Adds a primitive byte value to the argument container in the next available position.AddBoolean (Boolean bArg)
Adds a primitive boolean value to the argument container in the next available position.AddShort (Integer iArg)
Adds a primitive short value to the argument container in the next available position.AddInt (Long lArg)
Adds a primitive int value to the argument container in the next available position.AddLong (Currency cyArg)
Adds a primitive long value to the argument container in the next available position.AddFloat (Single fArg)
Adds a primitive float value to the argument container in the next available position.AddDouble (Double dArg)
Adds a primitive double value to the argument container in the next available position.AddChar (String strArg)
Adds a primitive char value to the argument container in the next available position.AddString (String strArg)
Adds the argument in string form to the argument container in the next available position.SetObject (Integer iArgPosition, String strObjectTypeName, Object oArg)
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)SetByte (Integer iArgPosition, Byte byteArg)
Sets a primitive byte value to the argument container in the position specified.SetBoolean (Integer iArgPosition, Boolean bArg)
Sets a primitive boolean value to the argument container in the position specified.SetShort (Integer iArgPosition, Integer iArg)
Sets a primitive short value to the argument container in the position specified.SetInt (Integer iArgPosition, Long lArg)
Sets a primitive int value to the argument container in the position specified.SetLong (Integer iArgPosition, Currency cyArg)
Sets a primitive long value to the argument container in the position specified.SetFloat (Integer iArgPosition, Single fArg)
Sets a primitive float value to the argument container in the position specified.SetDouble (Integer iArgPosition, Double dArg)
Sets a primitive double value to the argument container in the position specified.SetChar (Integer iArgPosition, String strArg)
Sets a primitive char value to the argument container in the position specified.SetString (Integer iArgPosition, String strArg)
Sets a java.lang.String value to the argument container in the position specified.Object Item(Integer iArgPosition)
Returns the value of an argument at a specific argument position.Clear()
Removes all arguments from the container and resets the next available position to one.Long Count()
Returns the number of arguments in the container.