Invoking an EJB component method – PB Docs 125

Invoking an EJB component method

To
invoke an EJB component method, you need to execute the PowerScript statements
required to perform these operations:

  1. Use the Lookup function to access the component’s
    home interface.

  2. Invoke the method on the interface to create or
    find an instance of the component and get a reference to the component’s
    remote interface.

  3. Invoke the business methods on the remote interface.

note.png Does not apply to EJBConnection methods

This section applies to client applications that use an EAServer proxy object and PowerScript
functions. For information about invoking EJB methods in client
applications that use an EJB client proxy and EJBConnection methods, see Chapter 27, “Building an EJB client .” However, the
EJBConnection object is deprecated for use with EAServer and the PowerBuilder Application
Server Plug-in.

Specifying the home interface name

PowerBuilder provides an optional third argument to the Lookup function
to specify the name of the home interface. EJB components have a
property in EAServer called com.sybase.jaguar.component.home.ids.
You do not need to specify the third argument to the Lookup function
if the home.ids property looks like this:

For example:

In most cases, however, the home.ids property uses the java
package naming scheme and you should use the third argument to make
sure that the EJB home interface can be located. The string that
you specify for this argument must match the component’s
com.sybase.jaguar.component.home.ids property without the leading IDL: and
trailing :1.0.

For example, suppose the home.ids property is this:

Your Lookup function call should look like
this::

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

note.png Lookup is case sensitive

Lookup in EAServer is
case sensitive. Make sure that the case in the string you specify
for the arguments to the Lookup function matches
the case in the home.ids property.

Creating or finding an instance of an EJB

EAServer supports three
types of EJBs—session beans, entity beans, and message-driven
beans.

A session bean is created in response
to a client request. A client usually has exclusive use of the session
bean for the duration of that client session.

An entity bean represents persistent information stored in
a database. A client uses an entity bean concurrently with other
clients. Since an entity bean persists beyond the lifetime of the
client, you must use a primary key class name to identify or find a
preexisting component, if the bean has already been created.

A message–driven bean is similar to a stateless session
bean, but it responds only to JMS messages and has no direct client
interface.

The following examples assume that an EJB component that provides e–commerce
shopping cart functionality is running on EAServer.
This component is called Cart and is included in a package called
Shopping.

Example 1

This script instantiates the Cart component and invokes several component
methods. In this example, the second argument to the Lookup method
specifies the component name as well as the EAServer package
name:

Example 2

If the Cart EJB component is defined as an entity bean, then
the script must use the findByPrimaryKey method
to find and reference a preexisting or persistent component if one
exists:

Restrictions

PowerBuilder clients to EJB objects act as CORBA clients,
which means that they do not have the full capabilities of Java
clients. Java clients can use methods inherited from the javax.ejb.EJBObject
interface.

For example, a Java client can obtain a handle for a remote
interface instance. The handle is a binary encoding of the session
state between the client and the bean. The client can obtain a handle,
save it to disk or mail it to another location, then reestablish
the session at a later time. PowerBuilder clients can obtain similar
functionality using the Object_To_String and String_To_Object functions
of the JaguarORB object.

Handling exceptions

The remote interface of an EJB component can indicate errors
or warnings. Standard exceptions thrown by the EJB component are
mapped to CORBA system exceptions. The EJB component can also throw
user exceptions. For information about handling exceptions thrown
by EAServer components, see “Handling errors “.

For information about calling an EJB component from a PowerBuilder component
in EAServer, see “Accessing an EJB component”.


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