The PowerBuilder Native Interface (PBNI) is a standard programming interface that enables developers to extend the functionality of PowerBuilder. Using PBNI, you can create extensions to PowerBuilder—nonvisual, visual, and marshaler extensions—and embed the PowerBuilder virtual machine (PBVM) into C++ applications. Through JNI, Java applications can also communicate with the PBVM.
PowerBuilder Enterprise only This feature is not available in the Professional and Desktop editions of PowerBuilder.
The most frequently-used type of PowerBuilder extension is a nonvisual extension. Nonvisual extensions provide a way to call C and C++ functions from PowerBuilder with more flexibility than the existing solution of declaring a function in a script, and to use object-oriented techniques when working with external objects.
Nonvisual extensions enable you to use datatypes that do not map to standard PowerBuilder datatypes. PBNI provides predefined datatypes that map to PowerBuilder datatypes, so that you can use PowerBuilder datatypes when you invoke the methods of the native class, and the native class can use the predefined types to call back into PowerBuilder.
Your native classes can call back into the PBVM from the C++ code and trigger PowerBuilder events and invoke functions. You can also call external functions that require callback functions. For example, if your PowerBuilder application uses an extension that is a SAX XML parser, the SAX parser can send information back to the PowerBuilder application about the items it has encountered in the XML document that it is parsing. The PowerBuilder application can respond by sending back instructions on how to handle those items.
Visual extensions can be used as though they were PowerBuilder visual user objects—they can be placed in windows or on other visual controls. Visual extensions enable you to subclass the Windows procedure (winproc) of a visual component so that you can use the latest "look and feel" for your applications.
Marshaler extensions act as bridges between PowerBuilder and other components, such as Enterprise JavaBeans (EJB) components, Java classes, Web services, and CORBA components. PowerBuilder provides a marshaler extension for creating clients for EJB components running in any J2EE-compliant application server.
To have direct access to a custom class user object running in the PBVM, and to take advantage of PBNI functions for data access and exchange, you can load the PBVM in a C++ application, create a session, and invoke the custom class user object's functions from the external application.
To call Java classes from PowerBuilder, you can build a marshaler extension that invokes Java methods through the Java Native Interface (JNI). You can also use JNI to enable Java to call into PowerBuilder through C or C++.