This PowerBuilder 10 sample provides a client application that accesses an entity Enterprise JavaBeans (EJB) component and a stateless session EJB provided by BEA as examples on WebLogic Server version 7.0.
PB - EJB client
PowerBuilder 10
WebLogic Server (version 7 was used for this e 818b13i xample)
This example was designed for reuse as a sample application for the EJB client functionality across multiple J2EE servers. ejbshared.pbl contains a number of general purpose objects that help support the reuse.
pg_base is the ancestor of all tab pages, which are the primary user interface element in this example. Tab pages that showcase functionality of a specific EJB (such as pg_account and pb_trader in weblogic.pbl) should be implemented as custom class user objects extending pg_base.
The pg_login tab extends pg_base and contains the code (within the cb_login button) to instantiate the JavaVM and to connect to the targeted EJB server.
javavmex is an extension of the JavaVM object in ejbclient100.pbd and thus demonstrates how a PBNI object can be extended within PowerBuilder. The extensions here include functionality to split the current classpath into a string array as well as return the directory from which the Java VM (namely, jvm.dll) was loaded. These functions are used to provide the information displayed in w_jvmstatus whenever the JavaVM button on the 'status bar' of the main window is pressed.
In this example, two custom visual user objects (pg_account and pg_trader) implement the remaining tab pages, and each represents a different EJB. Each tab page declares the JNDI and home interface class name as instance constants and the home interface proxy as an instance variable. The EJB home interface is returned as part of the ue_activate event, which is fired whenever the login process to the application server succeeds. Code to instantiate the remote interface as well as to execute methods on that interface can be found behind the other controls on the tab (buttons, radio buttons, etc.).
The stock trade example demonstrates the invocation of a stateless session bean that returns a Java class (TradeResult) as the return value from a stock purchase or sale.
The list of holdings presented in the external DataWindow is hard-coded and will be refreshed whenever the application is restarted or the user disconnects and reconnects.
The implementation of the bean does not allow trades of over 500 shares; therefore, the PowerBuilder client code tests the number of shares actually traded to see if it matches the request.
The account example demonstrates functionality of an entity bean representing bank accounts.
The Retrieve Account List button calls a finder method to return a Java collection of all accounts with a non-negative balance. The code here demonstrates how to deal with Java interfaces within the PowerBuilder client.
The other buttons demonstrate how to create, remove and update entity beans and involve other simple dialogs to provide the necessary input for those operations. NOTE: the implementation of this EJB as provided by BEA does not enforce a primary key (the account number); therefore, the DuplicateKeyException never fires and it is possible to have multiple accounts with the same number.
For more information, see Application Techniques, Chapter 29, "Building an EJB client". Also look for other PB EJB client samples in CodeXchange, such as a PowerBuilder client accessing JBoss.
|