PowerBuilder: Article

PowerBuilder 8.0 And EAServer Intergration Improvements

PowerBuilder 8.0 And EAServer Intergration Improvements

Many PowerBuilder programmers over the last year have been spending most, if not all, of their efforts developing Web-enabled applications or distributed solutions - solutions that take advantage of Sybase's Enterprise Application Server.

Almost every new project these days can be more portable, more cost-effective and, over time, easier to maintain by using an application server. The new PowerBuilder 8 has some real improvements that help developers get components built faster and deployed more easily.

I will start with the high level of five integration issues addressed in this release, followed by some hands-on "what to do" screen shots to help you dive right in. If you would like more detail on any of these areas, you will find them listed under these topic headings in the Welcome to PowerBuilder 8.0 help menu selection.

  • Creating an EAServer component that implements an existing interface
  • Client-and component-managed EAServer transactions
  • SSL connections and callbacks
  • Concurrency property for EAServer components
  • Multiple PowerBuilder VMs in EAServer
Implementing an Existing Interface
Now you can easily customize standard API interfaces. When using the wizards, if the "Implement an existing EAServer remote interface" option is taken, the IDL for the existing component will be used to create a custom class user object that contains the methods and properties. Then code your implementation and deploy.

If there is a Java component that your application is using and you think you can write it better in PowerBuilder, simply grab the interface and give it a try!

You can create a PowerBuilder implementation of any existing EAServer component. This option looks like it's intended mainly for users of Sybase Financial Server because the documentation specifically notes building implementations for the Open Financial Exchange (OFX), Financial Information eXchange (FIX), and Society for Worldwide Interbank Financial Telecommunications (SWIFT) protocols.

There will be other times this option will be useful - as with anything new, experiment a bit with it and see what you can do.

Streamlining Transactions
Remote control of transactions is what this really comes down to. New functions were added that allow code access to more information from the CORBACurrent service object. Clients and components can manage transactions in a server that is running the new two-phase commit transaction coordinator (OTS/XA).

Here are some quick bits on methods from the new functions that help manage transactions. Check the help documentation for more details, syntax, and parameters.

  • GetTransactionName: Typically used for debugging, GetTransactionName returns a string identifying the transaction associated with the calling thread.
  • RollbackTransaction: Rolls back the transaction associated with the calling thread.
  • BeginTransaction: Creates a transaction and associates it with the calling thread by trying to set the transaction context of the calling thread. This call will fail if a thread is already associated with a transaction. If successful, the calling thread can now obtain information about the transaction and control commits and rollbacks.
  • Init: Has a few quirks you must deal with. First, use the GetContextService to get a reference to the CORBACurrent object.
CORBACurrent i_CORBACurrentobject

GetContextService  (CORBACurrent, i_CORBACurrentobject )

Now use the reference i_CORBACurrentobject.init (connection or URL) call where you pass either a connection object or a URL to an EAServer box.

i_CORBACurrentobject.Init( i_connect  )
//  OR
i_CORBACurrentobject.Init( "iiop://EAServer:9000")

By using the connection object the code is portable, so the first option would be preferred. You must perform these initialization steps before using any of the other methods on i_CORBA- Currentobject. Also note, if the component is not marked as OTS style the initialization will fail.

  • SetTimeout: This allows you to specify the number of seconds that can elapse before a transaction is rolled back. This setting applies to transactions created by subsequent invocations of BeginTransaction. The default is 0 or no time out.
  • CommitTransaction: Completes the transaction associated with the calling thread; however, the transaction will not be completed if any other participants in the transaction vote to roll it back.
  • ResumeTransaction: Passing this function a Handle to any transaction will associate the calling thread to the transaction. Note that the only way to obtain a valid Handle for the transaction is by using the SuspendTransaction function.
  • SuspendTransaction: This will return a Handle for the transaction the calling thread is currently associated with. This Handle can be used by any thread in the same execution environment. Calling SuspendTransaction will disassociate the current thread from the transaction.
  • GetStatus: Using GetStatus will determine what is happening within a transaction that was initiated by a client or component using the BeginTransaction function. The codes returned indicate if the transaction has started, is in the process of preparing, committing, in transition, or is rolling back.
  • RollbackOnly: Can be used to "vote" which marks the current transaction for rollback.
SSL Connections and Callbacks
The SSLCallBack Object has been implemented so you no longer have to configure your SSL connections to not require the callback object. You can now provide your own implementation.

Tell EAServer to use your implementation by specifying the name of the object in the callbackImpl SSL property. This global property is set by calling the SetGlobalProperty function.

Finally, this is an enhancement we have been waiting for. If your standard components do not have this checked, and you're not 100% sure why - check it. Your Web applications will see a significant performance gain.

According to the PB 8 help files: "The concurrency property determines whether multiple instances of a component can be created to handle multiple client requests. An instance of a PowerBuilder component executes in its own session, and each session can only support one thread of execution. Therefore a single PowerBuilder component instance cannot simultaneously execute multiple client requests. However, multiple instances of the same component can each execute a separate client request."

Think of it as cloning without all the overhead costs of research, the legal expenses, or ethical questions. When concurrency is checked, clients do not have to stand in line to use your component. Who wants to wait in line anyway?

Previously, this property could be set in EAServer, but by making it a deployment option in PB 8 it will save everybody time.

Multiple PowerBuilder VMs
This will save you some migration headaches: Write once, run forever? Now that would have to be some pretty good code. As long as the PB Virtual Machine is on the server it can be hosted by EAServer 3.6 and later.

Getting Down to Work
Before you try anything, set up your EAServer profile. When I first tried to create components I had a problem. I did not have any EAServer profiles. Save yourself the trouble. Click on this new tool EAServer Profiles selection in PowerBar1 (see Figure 1).

This will pop open the EAServer Profiles window (see Figure 2). I have two set up presently.

Add your EAServer here. If you do not know what the settings should be, talk to your EAServer administrator. Presently the wizards require you to have a profile set up to create components. The creation process will not be allowed to go forward if profiles are not available.

There are two ways to create components: as a Target component or as a component within an existing Target.

Before I bash something, please note: I wrote this from the final beta, so if Sybase dealt with these gripes, great. If not, well, these are the things that annoyed me - and consider this an enhancement request.

Presently, the wizards do not allow adding new profiles on the fly or an option to specify a deployment server at a later time.

In addition, the wizards are "slower than desired" when you have an existing profile set up but the computer currently does not have access to EAServer. This makes it harder for you to write code remotely. I can still develop, but the wait seems a little silly.

Show Me
The new deployment project options look like Figure 3:

  • Full rebuild option (general)
  • Collapse class hierarchy (general)
  • Concurrency (component)
  • Support instance pooling (component)
  • Specify how many instances to create (component)
  • Use existing IDL on EAServer (component)
The complexity required by distributed architecture is a drawback, but the benefits are worth the effort for many applications. PB 8 is shielding developers from these complexities and allowing for better access.

If you need or want to, dive into more complex issues like the two-phase commit transaction coordinator (OTS/XA). This tool allows enough options for developers to accomplish many complex tasks without needing to worry about managing EAServer. I am not 100% satisfied with the 8.0 release, but PB 8 will make me a more productive developer and make managing EAServer boxes easier.

More Stories By Jerry Neppl

Jerry Neppl, previously CEO of a small liquidation company, has been working for PowerTeam, Inc., in Minneapolis, for the past year and a half, having fun and getting
paid to play everyday.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.