Resolve_Initial_References PowerScript function
Description
Uses the CORBA naming service API to obtain the initial naming
context for an EAServer component.
This function is used by PowerBuilder clients connecting to EAServer.
Controls
JaguarORB objects
Syntax
1 |
<span>jaguarorb</span>.<span>Resolve_Initial_References</span> ( <span>objstring</span><span>, object </span>) |
Argument |
Description |
---|---|
jaguarorb |
An instance of JaguarORB |
objstring |
A string that has the value “NameService” |
object |
A reference variable of type CORBAobject |
Return Values
Long. Returns 0 if it succeeds and a
negative number if an error occurs.
Usage
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.
You can also use the JaguarORB object’s String_To_Object function
to instantiate a proxy instance without using the CORBA naming service explicitly.
For more information about connecting to EAServer using
the JaguarORB object, see Application Techniques.
When you use the CORBA naming service, you need to generate
proxies for the naming service interface and include these proxies
in the library list for the client.
Examples
The following example shows the use of the Resolve_Initial_References function
to obtain an initial naming context. After obtaining the naming context,
it uses the naming context’s resolve method to obtain a
reference to a Factory object for the component and then narrows
that reference to the SessionManager’s 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. The create method of
the Factory object obtains proxies for the component. It returns
a CORBA object reference that you can convert into a reference to
the component’s interface using the _Narrow function.
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:
1 |
CORBAObject my_corbaobj |
1 |
JaguarORB my_orb |
1 |
NamingContext my_nc |
1 |
NameComponent the_name[] |
1 |
Factory my_Factory |
1 |
n_jagcomp my_jagcomp |
1 |
1 |
my_orb = CREATE JaguarORB |
1 |
// Enclose the name of the URL in single quotes |
1 |
my_orb.init("ORBNameServiceURL='iiop://server1:2000'") |
1 |
1 |
my_orb.<span>Resolve_Initial_References</span>("NameService", & |
1 |
my_corbaobj) |
1 |
my_corbaobj._narrow(my_nc, & |
1 |
"omg.org/CosNaming/NamingContext") |
1 |
1 |
the_name[1].id = "mypackage/n_jagcomp" |
1 |
the_name[1].kind = "" |
1 |
1 |
TRY |
1 |
   my_corbaobj = my_nc.resolve(the_name) |
1 |
   my_corbaobj._narrow(my_Factory, &<br>     "SessionManager/Factory") |
1 |
   my_corbaobj = my_Factory.create("jagadmin","") |
1 |
   my_corbaobj._narrow(my_jagcomp, &<br>      "mypackage/n_jagcomp") |
1 |
CATCH (Exception e) <br>   MessageBox("Exception Raised!", e.getMessage())<br>END TRY |
1 |
my_jagcomp.getdata() |