Implementing an existing interface
You can create PowerBuilder implementations of existing interfaces
using the EAServer Component Wizard
on the Target or PB Object tab in the New dialog box. A typical
use of this feature is to create an implementation of a standard API,
such as protocols for online banking and securities trading.
Selecting an interface
On the Specify Interface Implementation page in the wizard,
select Implement an Existing EAServer Remote
Interface, then select the EAServer profile
for the server that contains the IDL interface you want to implement.
You can select only one interface from the list that displays when
you expand the list of packages in the wizard.
For PowerBuilder components, the interface name is usually
the same as the component name, but the list of interfaces does
not map directly to the list of components on the server. The list
includes all IDL modules of type interface.
Setting options in the wizard
Once you have selected the interface to implement, you can
enter the EAServer name for the
component. The name of the PowerBuilder custom class user object
cannot be changed—it is always the same as the name of
the remote interface. You can set most other options, such as package
name, instance pooling, and so forth, as if you were creating a
new interface.
If you are building a PowerBuilder implementation of a standard
API, you will usually use the component name of the remote component,
but you should not use the same package name.
Since the interface of the remote component cannot be changed,
options that would change method signatures, such as supporting NULL values
for arguments, cannot be set in the wizard.
Editing the user object in the painter
In the custom class user object created by the wizard, public
attributes of the remote interface are represented as public instance
variables, and public methods as public functions. The scripts for
functions contain return statements so that they do not produce
compilation errors, but you need to provide a script to implement
each function. If the remote interface includes other dependencies,
such as structures, the wizard creates them in the same PBL as the
user object.
If you are using EAServer 6.0 or later, PowerBuilder components
are wrapped as EJB components, and a Remove method
is generated by EAServer as part of the component interface. You
do not need to use this method.
You can edit the user object just as you would any other custom
class user object—the User Object painter does not impose
any restrictions. However, you should not make any changes that
affect its interface. You should not delete any instance variables
and functions that correspond to attributes and methods in the existing
interface or change their mode from public to private or protected.
Functions cannot be overloaded and the return value or arguments cannot
be NULL values.
Deploying the component to EAServer
The project created by the wizard contains information about
the interface from which the wizard built the component. When you
run the project, PowerBuilder checks that:
-
All
public attributes and methods in the existing IDL interface are
defined as public instance variables and functions in the user object. -
No methods defined in the IDL interface are overloaded
in the user object.
If one of these checks fails, the component is deployed but
a warning displays in the Project painter and the Output window.
Using a different project
These checks are performed only if the component is deployed
using the project that was created when the component was created.
If you create a new project or add the component to another project,
no checks are performed when you run the project.
When you deploy using the project created with the component,
the new implementation always uses the existing IDL on the server.
You should be cautious if you use a different project, because you
will be able to deploy the component to the original package and
overwrite the existing IDL without seeing any warnings about changes
in the interface.
When you generate a proxy for an object that implements an
existing interface and uses the existing IDL on the server, the
proxy is based on the existing IDL. As a result, if you select the
Prepend EAServer Package Name
to Object Name option, the name prepended to the object name will
be the name of the IDL module, not the new package name.