In the ActiveX to Enterprise Java Beans (EJB) bridge, methods are called using the native language method invocation syntax.
... Dim strHexValue as String strHexValue = clsMyString.toHexString(CLng(255))
o.Close(123) 'Incorrect... CallByName(o, "close", vbMethod, 123) 'Correct...or in VBScript, use the Eval function:
o.Close(123) 'Incorrect... Eval("o.Close(123)") 'Correct...
Set oMyObject = o.getObject iMyInt = o.getInt
Because ActiveX Automation does not natively support character types supported by Java methods, the ActiveX to EJB bridge uses strings (byte or VT_I1 do not work because characters have multiple bytes in Java code). If you try to call a method that takes a char or java.lang.Character type use the JMethodArgs argument container to pass character values to methods or constructors. For more information about how this argument container is used, see Methods with "Object" Type as Argument and Abstract Arguments.
Because of the polymorphic nature of Java programming, the ActiveX to Java bridge uses direct argument type mapping to find a method. This method works well in most cases, but sometimes methods are declared with a Parent or Abstract class as an argument type (for example, java.lang.Object). You need the ability to send an object of arbitrary type to a method. To acquire this ability, use the XJB.JMethodArgs object to coerce your parameters to match the parameters on your method. You can get a JMethodArgs instance by using the JClassFactory.GetArgsContainer() method.
The JMethodArgs object is a container for method parameters or arguments. This container enables you to add parameters to it one-by-one and then you can send the JMethodArgs object to your method call. The JClassProxy and JObjectProxy objects recognize the JMethodArgs object and attempt to find the correct method and let the Java language coerce your parameters appropriately.
For example, to add an element to a Hashtable object the method syntax is Object put(Object key, Object value). In Visual Basic, the method usage looks like the following example code:
Dim oMyHashtable as Object Set oMyHashtable = _ oXJB.NewInstance(oXJB.FindClass("java.utility.Hashtable")) ' This line will not work. The ActiveX to EJB bridge cannot find a method ' called "put" that has a short and String as a parameter: oMyHashtable.put 100, "Dogs" oMyHashtable.put 200, "Cats" ' You must use a XJB.JMethodArgs object instead: Dim oMyHashtableArgs as Object Set oMyHashtableArgs = oXJB.GetArgsContainer oMyHashtableArgs.AddObject("java.lang.Object", 100) oMyHashtableArgs.AddObject("java.lang.Object", "Dogs") oMyHashtable.put oMyHashTableArgs ' Reuse the same JMethodArgs object by clearing it. oMyHashtableArgs.Clear oMyHashtableArgs.AddObject("java.lang.Object", 200) oMyHashtableArgs.AddObject("java.lang.Object", "Cats") oMyHashtable.put oMyHashTableArgs
Related reference
Example: Developing an ActiveX application client to enterprise beans