Using the JaguarORB object – PB Docs 80

Using the JaguarORB object

To create a CORBA-compatible client, you can use the JaguarORB
object instead of the Connection object to establish the connection
to the server. The JaguarORB object allows you to access EAServer
from PowerBuilder clients in the same way as C++ clients.

Two techniques

The JaguarORB object supports two techniques for accessing
component interfaces, using its String_To_Object
and Resolve_Initial_References functions.

Using the String_To_Object function works
in the same way that the ConnectToServer and CreateInstance functions
on the Connection object do internally. The String_To_Object
function allows you to instantiate a proxy instance by passing a
string argument that describes how to connect to the server that
hosts the component. The disadvantage of this approach is that you lose
the benefits of server address abstraction that are provided by
using the naming service API explicitly.

If you want to use the Jaguar naming service API, you can
use the Resolve_Initial_References function to
obtain the initial naming context. However, this technique is not
recommended because it requires use of a deprecated SessionManager::Factory
create method. Most PowerBuilder clients do not need to use the
CORBA naming service explicitly. Instead, they can rely on the name
resolution that is performed automatically when they create EAServer
component instances using the CreateInstance and Lookup functions
of the Connection object.

About the naming service

The Jaguar naming service is an implementation of the CORBA
CosNaming component, which is a collection of interfaces that provide
support for object binding and lookup. For more information about
the CosNaming module, see the EAServer interface repository documentation.
The interface repository documentation can be viewed in a Web browser
by connecting to your server with the URL http://yourhost:yourport/ir/ where yourhost is
the server’s host name and yourport is
the HTTP port number.

Instantiation using String_To_Object

Obtaining proxies for SessionManager interfaces

To instantiate a proxy without explicitly using the CORBA
Naming Service, you use the String_To_Object function
of the JaguarORB object in conjunction with interfaces defined in
the SessionManager module. Before using the Manager, Session, and
Factory interfaces, you need to use the EAServer Proxy wizard to
create a proxy library project for the SessionManager module, build the
project, and include the generated proxy library in the library
list for the client target.

Identifying the server

You use the SessionManager::Manager interface to interact
with the server. You can identify the server using its Interoperable
Object Reference (IOR) or its URL. The IOR string encodes the server’s
host address and the port at which the server accepts IIOP requests.
Each time a server is started, it writes a hex-encoded IOR string
with standard encoding to two files for each listener, one containing
the IOR string by itself, and the other containing the IOR as part
of an HTML PARAM definition that can be inserted into an APPLET
tag. The files reside in the HTML subdirectory of the EAServer
directory. You can code the client to obtain the IOR string from
one of these files.

Creating an authenticated session

After initializing the ORB and obtaining the IOR or URL of
the server, use the String_To_Object function
to convert the string to a CORBA object reference that you can convert
to a reference to the Manager interface using the _Narrow function.
Then use the createSession method of the Manager interface to create an
authenticated session between the client application and the server.

Creating a reference to the component’s interface

Use the session’s lookup method to return a factory
for proxy object references to the component you want to call. Then
call the create method of the Factory object to obtain proxies for
the component. The create method returns a CORBA object reference
that you can convert into a reference to the component’s
interface using the _Narrow function.

A component’s default name is the package name and
the component name, separated by a slash, as in calculator/calc.
However, you can specify a different name with the component’s
com.sybase.jaguar.component.naming property. For example, you can
specify a logical name, such as USA/MyCompany/FinanceServer/Payroll.
For more information on configuring the naming service, see the
section on naming services in the EAServer System Administration
Guide

.

Examples

In this example, the first argument to the String_To_Object
function includes the URLs for two servers in a cluster:

In this example, the component is an EJB component. The Home
interface effectively performs the same role for the EJB that the
Factory interface does for a CORBA component:

note.gif Using a Connection object In PowerBuilder 8, you can use the Lookup function on the
Connection object to obtain a reference to the Home interface of
an EJB component. See “Invoking an EJB component
method”
.

Instantiation using the naming service API

Obtaining proxies for CosNaming and SessionManager interfaces

To instantiate a proxy using the CORBA naming service API,
you need to generate proxies for the naming service interface and
include these proxies in the library list for the client. Use the
EAServer Proxy wizard to create a proxy project for the CosNaming
module, build the project to create a proxy library, and add the
proxy library to the client target’s library list. You
also need a proxy for the SessionManager module.

Getting an initial naming context

After initializing the ORB, call the Resolve_Initial_References
function to obtain an initial naming context and use _Narrow
to convert it to a reference to the CORBA naming context interface.
You must identify the CosNaming package by including omg.orb in
the class name as shown in the example below.

Resolving the naming context

You need to resolve the naming context to obtain a reference
to a Factory object for the component and then narrow that reference
to the SessionManager::Factory interface. The resolve method takes
a name parameter, which is a sequence of NameComponent structures.
Each NameComponent structure has an id attribute
that identifies the component and a kind attribute
that can be used to describe the component. In the example below,
the name has only one component.

Creating a reference to the component’s interface

Call the create method of the Factory object to obtain proxies
for the component. The create method returns a CORBA object reference
that you can convert into a reference to the component’s
interface using the _Narrow function.

Example

The NamingContext and NameComponent types used in the example
are proxies imported from the CosNaming package in EAServer, and
the Factory type is imported from the SessionManager package:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x