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:

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 instance

XJB.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: