PBDR.COM

About   -   Contact   -   Purchase   -   Search   -   What's New

 
 
Calling PowerBuilder Components from JSP

I've been working in a new application using JSP and EAServer with business components written in PowerBuilder. One of the first things you need to get working is the JSP calling the PowerBuilder objects. There are two ways you can achieve this.

The first way is the simplest and just connects to the Corba ORB (Jaguar) and calls a method on the ORB passing in a String with the package and object name, for example "MyPackage/MyObject".  This function will work fine for any basic applications and business objects but has two draw backs. The first being that you are creating an anonymous request to the ORB and as such the object given to your request will have no security rights to Jaguar. This means if your object accesses the Repository or needs to do any other cool tricks then it will fail with a security violation. Secondly there is no way (that I can see) of specifying the Host details of the machine to connect to, so if you want to connect to a different Jaguar machine you could not. Below is an example of the code:

   Properties p = new Properties();

   p.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB" );
   ORB orb = (com.sybase.CORBA.ORB) ORB.init( ( String[] )null, p );
   myPackage.MyObject jagLocalVar = MyPackage.MyObjectHelper.narrow( 
      orb.string_to_object( "Package/Object" ) );

The second way is slightly more complex and it differs because it connects to the Corba ORB and creates a session by logging into the ORB with a User ID and Password before creating the object. This has the advantage of giving the object you connect to the same access rights as the user id and password you logged in to the session as. The example code is shown below:

   Properties p = new Properties();

   p.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB" );
   ORB orb = (com.sybase.CORBA.ORB) ORB.init( ( String[] )null, p );
   Manager jagMan = ManagerHelper.narrow( orb.string_to_object( "iiop://IPADDR" ) );
   Session jagSes = jagMan.createSession( "userid", "******" );
   myPackage.MyObject jagLocalVar = MyPackage.MyObjectHelper.narrow( 
      jagSes.create( "Package/Object" ) );

In my application I have built a Java class with static methods that provides connection services to Jaguar with standardized functions for connecting to Jaguar and returning objects. That way if the machine, user id or password changes it can be changed in one place. It also removes the code for connecting from the JSP's making them more portable and lest complex for the developers.

 

Top of Page

Legal Notice

Ken Howe 2011