Search My Blog

Thursday, October 8, 2015

STD Foundation Classes - PowerBuilder to Java Interop!

** New Feature **

STD Integrated Framework

PowerBuilder to Java Interop!

    With the release of the new STD Integrated Framework for PowerBuilder and Appeon (version 2015.4.0.43 and higher), the framework was enhanced to deliver a new feature -  PowerBuilder to Java Interoperability. Now the ability of a PowerBuilder Classic based application to "consume" a Java class and call its methods is even easier than before and now encapsulated into the STD Integrated Framework for the PB developer!

    The PowerBuilder IDE since early 2000 has had the ability to call EJB (Enterprise Java Beans) due to the introduction of the Java based Application Server by Sybase named EAServer. With EAS came the ability to call a remote EJB in any J2EE based application server by using RMI (remote method invocation) that was exposed as the "Home" interface. The EJB Home Interface though can be either local or remote in nature. Thus when dealing with a native MS-Windows PB application that has Java classes deployed along side of it, we can use the local Home interface to interact with it from a PB application. This is, as long was we expose the Java application as an EJB (that is .. follow the EJB construction rules).

   When the Java developer creates a Java class, he/she can also create a Home interface or what PowerBuilder would refer to as an EJB "proxy". A Proxy is a Class/Method signature that allows PB to treat the Java application as a "bean". According to the generally accepted definition of a Java proxy is as follows: "A proxy class is a class that implements a list of interfaces". Since CORBA (Common Request Object Broker Architecture) support was added to PowerBuilder a long time ago - PB understands "proxies" very well. So if we can get your PB application a list of proxy classes it needs to deal with an EJB, it can then communicate with it. First of all, we can build a Java Class and then build a HOME interface for that using your standard development environment - even "notepad" for us poorer folk. Once completed, you can just compile the EJB class and its Home class using the JAVAC compiler, as follows:

  Now that we have an EJB and a Home class to serve as a "proxy" road-map for PowerBuilder, we can use the Classic IDE to build the necessary interfaces for us in a PowerBuilder Library (PBL) to use in our application. To perform this step, we need to call on the IDE's Project Painter to help us with this task. When creating a new project, we can then select EJB Client Proxy option. This will build a a PB Project object that can build all the necessary proxy interfaces for you. All we need to do is specify the Java Bean  class and its HOME (interface) class to the proxy painter. for example:

  Once the EJB Client Proxy project is properly configured, the next step will be to run the project, as follows:

    Now that we have the "proxies" required for the Java interface (Home) class, we can now instantiate the EJB by using its proxy in your PB Application. The only challenge beforehand, is loading the Java Virtual Machine (JVM) and activating its JNI (Java Native Interface) JDK to inter-operate with your Java EJB. Luckily, this is where the STD Integrated Framework steps in to help you. All you need to do is call a new "of_create_instance" method in the Application Controller supplied by the framework and it will perform all of the JVM the house keeping for you including: loading, reusing, unloading, garbage collection, etc of the PB to JVM infrastructure! So now the PB Developer can just concentrate on using the EJB's methods & processes, for example:
 
  To make this easier to follow, STD have created a working example of this PB to Java mechanism for you to examine, learn and move forward with your organizations Java interoperability within your PowerBuilder project. You can download the PB2Java example built from the STD Integrated Framework by clicking here!

  Coming soon ... Consume the same EJB methods in your PowerBuilder built Web Services using the STD WebService Framework and then extend your EBJ interoperability to both Appeon Web and Appeon Mobile applications as well!



Enjoy!
Regards ... Chris

   

No comments:

Post a Comment