String_To_Object PowerScript function
Description
Gets an object reference based on a passed string.
This function is used by PowerBuilder clients connecting to EAServer.
Controls
JaguarORB objects
Syntax
|
1 |
<span>jaguarorb</span>.<span>String_To_Object</span> ( <span>objstring , </span><span>object</span>) |
|
Argument |
Description |
|---|---|
|
jaguarorb |
An instance of JaguarORB. |
|
objstring |
A string that represents a CORBA object. The string representation of a CORBA object is an Interoperable |
|
object |
A variable of type CORBAobject that will |
Return Values
Long. Returns 0 if it succeeds and a
negative number if an error occurs.
Usage
The String_To_Object function
allows you to instantiate a proxy instance without using the Jaguar
naming service.
Connecting to EJB components
In PowerBuilder 7 and earlier releases, the JaguarORB String_To_Object function
was used to access EJB components in EAServer.
In PowerBuilder 8 and later, the Lookup function on the Connection object
can be used to instantiate a proxy for the home interface of an
EJB component in EAServer.
In PowerBuilder 9, the Lookup function on the EJBConnection
PowerBuilder extension object can be used to instantiate proxies
for EJB components running in any J2EE-compliant server.
When you use String_To_Object for proxy
instantiation, you instantiate the object directly. The disadvantage
of this approach is that you lose the benefits of server address
abstraction that are provided by the naming service.
To use the naming service API explicitly, you can use the Resolve_Initial_References function
to obtain an initial naming context. However, this technique is
not recommended because it requires use of deprecated SessionManager::Factory
methods. For more information about connecting to EAServer using the JaguarORB
object, see Application Techniques.
The String_To_Object can
be used to obtain an EAServer authentication manager
instance by using a URL format IOR. IOR strings in URL format must
have the form:
|
1 |
<span>protocol </span>: //<span> host</span> :<span> iiop_port</span> |
where:
-
protocol is
iiopsif
connecting to a secure port andiiopotherwise -
host is the EAServer host address or machine
name -
iiop_port is the port
number for IIOP requests
An example of a URL-format IOR is:
|
1 |
iiop://hosta:2000 |
If the server is part of a cluster, the objstring argument
can contain a list of IORs separated by semicolons.
After calling String_To_Object,
you can use the Manager interface to obtain an instance of the Session
interface, which allows you to create component instances. When
you use the Manager and Session interfaces, you need to generate
proxies for these interfaces and include these proxies in the library
list for the client. For information about methods on these interfaces,
see the interface repository documentation at the URL http://yourhost:yourport/ir/, where yourhost is
the server’s host name and yourport is
the HTTP port number.
The String_To_Object function
can also be used to deserialize a Proxy object reference. By serializing
an object reference, you can save the state of the object so that
it persists after the client terminates processing. Deserializing
the object reference gets an object reference from a serialized
string. String_To_Object is
often used in conjunction with Object_To_String,
which allows you to serialize an object reference.
Examples
The following example shows the use of the String_To_Object function
to obtain an EAServer authentication
manager instance. The function uses a URL format IOR:
|
1 |
JaguarORB my_orb<br>CORBAObject my_corbaobj<br>Manager my_manager<br>Session my_session<br>Factory my_Factory<br>n_Bank_Account my_account<br> <br>my_orb = CREATE JaguarORB<br>my_orb.init("ORBRetryCount=3,ORBRetryDelay=1000")<br>my_orb.<span>String_To_Object</span>("iiop://myhost:2000", &<br> my_corbaobj)<br> <br>my_corbaobj._narrow(my_manager, &<br> "SessionManager/Manager")<br>my_session = my_manager.createSession("jagadmin", "")<br>my_corbaobj = my_session.lookup("Bank/n_Bank_Account")<br>my_corbaobj._narrow(my_Factory,    "SessionManager/Factory")<br>my_corbaobj = my_Factory.create()<br>my_corbaobj._narrow(my_account,"Bank/n_Bank_Account")<br> <br>my_account.withdraw(100.0) |
In this example, the component is an EJB component.
When the _Narrow function is called
to convert the object reference returned from the Lookup call on
the Session object, the second argument includes the domain name
as well as the package name. This is necessary if the Java package
name uses the domainname.packagename format:
|
1 |
JaguarORB my_orb<br>CORBAObject my_corbaobj<br>Manager my_mgr<br>Session my_session<br>CartHome my_cartHome<br>Cart my_cart |
|
1 |
long ll_return<br> <br>my_orb = CREATE JaguarORB<br>my_orb.init("ORBLogFile='c: emporblog'")<br>my_orb.String_to_Object("iiop://svr1:2000", &<br>    my_corbaObj)<br>my_corbaObj._narrow(my_mgr, "SessionManager/Manager" )<br>my_Session = my_mgr.createSession("jagadmin", "")<br>my_corbaObj = my_session.lookup("Cart")<br>ll_return = my_corbaObj._narrow(my_CartHome,<br> "com/shopping/CartHome") <br> <br>my_corbaObj = my_CartHome.create()<br> <br>my_Cart.addItem() |