String_To_Object

Description

Gets an object reference based on a passed string.

This function is used by PowerBuilder clients connecting to EAServer.

Applies to

JaguarORB objects

Syntax

jaguarorb.String_To_Object ( objstring , object)

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 Reference (IOR) that describes how to connect to the server hosting the object. EAServer supports both standard format IORs (which are hex-encoded) and a URL format that is human-readable.

object

A variable of type CORBAobject that will contain the object reference.

Returns

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.

NoteConnecting 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:

protocol : // host : iiop_port

where:

An example of a URL-format IOR is:

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

Example 1

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:

JaguarORB my_orb
CORBAObject my_corbaobj
Manager my_manager
Session my_session
Factory my_Factory
n_Bank_Account my_account

my_orb = CREATE JaguarORB
my_orb.init("ORBRetryCount=3,ORBRetryDelay=1000")
my_orb.String_To_Object("iiop://myhost:2000", &
   my_corbaobj)

my_corbaobj._narrow(my_manager, &
   "SessionManager/Manager")
my_session = my_manager.createSession("jagadmin", "")
my_corbaobj = my_session.lookup("Bank/n_Bank_Account")
my_corbaobj._narrow(my_Factory,    "SessionManager/Factory")
my_corbaobj = my_Factory.create()
my_corbaobj._narrow(my_account,"Bank/n_Bank_Account")

my_account.withdraw(100.0)

Example 2

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:

JaguarORB my_orb
CORBAObject my_corbaobj
Manager my_mgr
Session my_session
CartHome my_cartHome
Cart my_cart

long ll_return

my_orb = CREATE JaguarORB
my_orb.init("ORBLogFile='c:\temp\orblog'")
my_orb.String_to_Object("iiop://svr1:2000", &
    my_corbaObj)
my_corbaObj._narrow(my_mgr, "SessionManager/Manager" )
my_Session = my_mgr.createSession("jagadmin", "")
my_corbaObj = my_session.lookup("Cart")
ll_return = my_corbaObj._narrow(my_CartHome,
   "com/shopping/CartHome")   

my_corbaObj = my_CartHome.create()

my_Cart.addItem()

See also