More PBNI possibilities
The ability to create visual, nonvisual, and marshaler extensions,
and to call PowerBuilder objects from external C++ applications,
opens up numerous opportunities to combine these capabilities to
develop more complex applications.
Writing an extension that loads the PBVM
Most of the examples in this book and on the PowerBuilder Code Samples Web site
show you how to
create an extension in C++ and use it in PowerBuilder,
or how to write a C++ application that loads the
PowerBuilder VM.
You could also write an extension that loads the PowerBuilder
VM and uses a custom class user object, using the techniques described
in this chapter. The following figure depicts the interaction between
the PBVM and an external application that uses an extension.
Figure 5-2: Interaction between PBNI, the PBVM, and external applications
Calling PowerBuilder from Java
You can combine the ability to call PowerBuilder classes from
C++, as described in this chapter, with the ability
to create marshaler extensions, as described in Chapter 3, "Creating Marshaler Extensions," to call PowerBuilder
from Java.
One way to do this is to create a Java proxy class that declares
static native methods that can be called to load the PBVM, create
PowerBuilder sessions, create PowerBuilder objects, and invoke PowerScript
functions. These native methods can call into the PBVM through PBNI.
Additional Java classes that represent the PBVM, PowerBuilder sessions,
and PowerBuilder objects can be based on the proxy class.
The Java classes call the Java native methods through JNI,
whereas the Java native methods call PowerBuilder through PBNI.
There is a sample that illustrates these techniques on the PowerBuilder Code Samples Web site
.