Lookup (obsolete)

Allows a PowerBuilder client or component to obtain a factory or home interface in order to create an instance of an EAServer component. This function is used by PowerBuilder clients connecting to components running in EAServer, and by PowerBuilder components connecting to other components running on the same server.

Obsolete function

Lookup is obsolete, because EAServer is no longer supported since PowerBuilder 2017.

To

Use

Obtain the factory interface of a CORBA-compliant component running in EAServer

Syntax 1

Obtain the home interface of an EJB component running in EAServer

Syntax 2


Syntax 1: For CORBA-compliant EAServer components

Description

Allows a PowerBuilder client or component to obtain the factory interface of an EAServer component in order to create an instance of the component.

Applies to

Connection objects, TransactionServer objects

Syntax

objname.Lookup (objectvariable , componentname )

Argument

Description

objname

The name of the Connection object used to establish the connection or of an instance of the TransactionServer context object.

objectvariable

A global, instance, or local variable of the factory interface type.

componentname

A string whose value is the name of the component instance to be created. You can optionally prepend a package name followed by a slash to the component name (for example, "mypackage/mycomponent").


Return value

Long.

Returns 0 if it succeeds and a negative number if an error occurs.

Usage

The Lookup function can be used as an alternative to the CreateInstance function. It obtains a reference to a factory interface that you can use to create an instance of a component running in EAServer.

Use the Connection object's Lookup function to enable a PowerBuilder client to access a component running in EAServer. You can supply a server name or a list of server names in the location property of the Connection object.

Use the TransactionServer object's Lookup function to enable a PowerBuilder component running in EAServer to access another component running on the same server.

To use the Lookup function, you need to create an EAServer proxy library for the SessionManager package to obtain a proxy for the factory interface. Include this proxy library in your library list.

Examples

The following example uses Lookup to instantiate the factory interface for the n_Bank_Account component, then it uses the factory's create method to create an instance of the component:

// Instance variable:
// Connection myconnect
Factory my_Factory
CORBAObject mycorbaobj
n_Bank_Account my_account
long ll_result
 
ll_result = &
    myconnect.lookup(my_Factory,"Bank/n_Bank_Account")
mycorbaobj = my_Factory.create()
mycorbaobj._narrow(my_account, "Bank/n_Bank_Account")
my_account.withdraw(100.0)

See also

CreateInstance

Syntax 2: For instances of an EJB component

Description

Allows a PowerBuilder client or component to obtain the home interface of an EJB component in EAServer in order to create an instance of the component.

Applies to

Connection objects, TransactionServer objects

Syntax

objname.Lookup (objectvariable , componentname {, homeid} )

Argument

Description

objname

The name of the Connection object used to establish the connection or of an instance of the TransactionServer context object.

objectvariable

A global, instance, or local variable of the type of the home interface to be created.

componentname

A string whose value is the name of the EJB component to be created. You can optionally prepend a package name followed by a slash to the component name (for example, "mypackage/mycomponent").

homeid

A string whose value is the name of the home interface to be created. This argument is optional


Return value

Long.

Returns 0 if it succeeds and a negative number if an error occurs.

Usage

EJBConnection

You can also use the Lookup method of the EJBConnection PowerBuilder extension object to create an instance of an EJB component running on any J2EE compliant application server. For more information, see the section called “Lookup” in PowerBuilder Extension Reference.

The Lookup function creates an instance of the home interface of an EJB component so that you can use it to create an instance of the EJB. Use the Connection object's Lookup function to enable a PowerBuilder client to access a component running in EAServer. You can supply a server name or a list of server names in the location property of the Connection object. Use the TransactionServer object's Lookup function to enable a PowerBuilder component running in EAServer to access an EJB component running on the same server.

The Lookup function uses the standard CORBA naming service to resolve componentname to a CORBA object that is then narrowed to the home interface name of the component. If you do not specify the third argument to the Lookup function, PowerBuilder expects the home interface name to have the format PackageName/CompNameHome. However, most EJB components use a standard Java package directory structure and the home interface name has a format such as com/domain/project/CompNameHome.

You can ensure that a PowerBuilder client or component can locate the component's home interface by supplying the third argument to the Lookup function to specify the home interface name. A component's home interface name is defined in the com.sybase.jaguar.component.home.ids property in the EAServer repository. The home.ids property has a format like this:

IDL:com/domain/project/CompNameHome:1.0

The third argument should be the value of the component's home.ids string without the leading IDL: and trailing :1.0. For example:

ts.lookup(MyCartHome, "shopping/cart", &
   "com/sybase/shopping/CartHome")

Alternatively, you can use the fully-qualified Java class name of the home interface specified in dot notation. For example:

ts.lookup(MyCartHome, "shopping/cart", &
   "com.sybase.shopping.CartHome")

Lookup is case sensitive

Lookup in EAServer is case sensitive. Make sure that the case in the string you specify in the argument to the lookup function matches the case in the ejb.home property.

Examples

The following example uses Lookup with the Connection object to locate the home interface of the Multiply session EJB in the Java package abc.xyz.math:

// Instance variable:
// Connection myconnect
Multiply myMultiply
MultiplyHome myMultiplyHome
long ll_result, ll_product
 
ll_result = &
   myconnect.lookup(myMultiplyHome,"Math/Multiply", &
     "abc.xyz.math.MultiplyHome)
IF ll_result <> = 0 THEN
   MessageBox("Lookup failed", myconnect.errtext)
ELSE
  try
    myMultiply = myMultiplyHome.create()
  catch (ctscomponents_createexception ce)
    MessageBox("Create exception", ce.getmessage())
    // handle exception
  end try
  ll_product = myMultiply.multiply(1234, 4567)
END IF

Entity beans have a findByPrimaryKey method that you can use to find an EJB saved in the previous session. This example uses that method to find a shopping cart saved for Dirk Dent:

// Instance variable:
// Connection myconnect
Cart myCart
CartHome myCartHome
long ll_result
 
ll_result = &
  myconnect.lookup(myCartHome,"Shopping/Cart", &
     "com.mybiz.shopping.CartHome")
IF ll_result <> = 0 THEN
  MessageBox("Lookup failed", myconnect.errtext)
ELSE
  TRY
     myCart = myCartHome.findByPrimaryKey("DirkDent")
     myCart.addItem(101)
  CATCH ( ctscomponents_finderexception fe )
     MessageBox("Finder exception", &
         fe.getmessage())
   END TRY
END IF

Nonvisual objects deployed from PowerBuilder to EAServer can use an instance of the TransactionServer context object to locate the home interface of an EJB component in the same server:

CalcHome MyCalcHome
Calc MyCalc
TransactionServer ts
ErrorLogging errlog
long ll_result
 
this.GetContextService("TransactionServer", ts)
this.GetContextService("ErrorLogging", errlog)
ll_result = ts.lookup(MyCalcHome, "Utilities/Calc", &
   "com.biz.access.utilities.CalcHome")
IF ll_result <> 0 THEN
  errlog.log("Lookup failed: " + string(ll_result))
ELSE
  TRY     MyCalc = MyCalcHome.create()
     MyCalc.square(12)
  CATCH (ctscomponents_createexception ce)
     errlog.log("Create exception: " + ce.getmessage())
  END TRY
END IF

See also

ConnectToServer (obsolete)