JavaVM:
CreateJavaInstance method
Description
Creates an instance of a Java object from a proxy name.
Syntax
|
1 |
<span>javavm</span>.CreateJavaInstance (powerobject <span>proxyobject</span>, string <span>proxyname</span> ) |
|
Argument |
Description |
|---|---|
|
javavm |
An instance of the JavaVM class. |
|
proxyobject |
PowerObject into which the function places |
|
proxyname |
The name of the proxy object for the |
Return Values
Long. Returns 0 for success and one of
the following values for failure:
-
-1
Failed to create Java class.
-
-2
Invalid proxy name.
-
-3
Failed to create proxy object.
Examples
In this example, the create method
accepts a Java Integer class argument. PowerBuilder
creates a proxy called java_integer (the
prefix java_ is required to prevent
a conflict with the PowerBuilder integer type).
The call to CreateJavaInstance sets the value
of that variable so you can call the EJB create method:
|
1 |
CustomerRemoteHome homeobj<br>CustomerRemote beanobj<br>java_integer jint_a<br> <br>try<br>  homeobj = conn.lookup("CustomerRemoteHome", &<br>    "custpkg/Customer", "custpkg.CustomerRemoteHome" )<br>catch (Exception e)<br>   MessageBox( "Exception in Lookup", e.getMessage() )<br>   return<br>end try<br> <br>try<br>   g_jvm.<span>createJavaInstance</span>(jint_a, "java_integer")<br>   jint_a.java_integer("8")<br>   beanobj = homeobj.create( jint_a, sle_name.text )<br>catch (RemoteException re)<br>   MessageBox( "Remote Exception", re.getMessage() )<br>   return |
|
1 |
catch (CreateException ce)<br>   MessageBox( "Create Exception", ce.getMessage() )<br>   return<br>catch (Throwable t)<br>   MessageBox(" Other Exception", t.getMessage())<br>end try<br> <br>MessageBox( "Info", &<br>   "This record has been successfully saved " &<br>   + "~r~ninto the database" ) |
Usage
Use this method when an EJB method accepts a Java class as
an argument. For example, if the primary key class argument to the findByPrimaryKey method
is a Java class, use the CreateJavaInstance method
to create the primary key class. You then use a PowerBuilder proxy
to communicate with the Java class.