The IPBX_Marshaler interface is used to invoke remote methods and convert PowerBuilder data formats to the user’s communication protocol. A marshaler extension is a PowerBuilder extension that acts as the bridge between PowerBuilder and other components, such as EJBs, Java classes, CORBA objects, Web services, and so on.
Method |
Description |
---|---|
Destroys an instance of an object inherited from the IPBX_Marshaler structure |
|
Returns the handle of the PBX that contains the native class |
|
Used in PowerBuilder marshaler native classes to call remote methods |
Use the Destroy method to destroy instances of objects inherited from the IPBX_Marshaler structure.
Destroy( )
None.
This code destroys the current instance of the SampleMarshaler structure:
void SampleMarshaler::Destroy() { delete this; }
You must implement this method in the marshaler native class after creating an instance of a marshaler structure and invoking remote methods.
Returns the handle of the PBX that contains the native class. This method is required to allow the PowerBuilder VM to determine which PBXs can be unloaded.
GetModuleHandle( )
pbulong
This code in the implementation of a marshaler class returns the handle of the PBX:
extern pbulong thisModuleHandle; pbulong SampleMarshaler::GetModuleHandle() { return thisModuleHandle; }
The handle is set in the main module:
pbulong thisModuleHandle = 0; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { thisModuleHandle = (pbulong)hModule; switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
You must implement this method in the marshaler native class.
Used in PowerBuilder marshaler native classes to call remote methods.
InvokeRemoteMethod(IPB_Session *session, pbproxyobject obj, LPCTSTR methodDesc, PBCallInfo *ci)
Argument |
Description |
---|---|
session |
This IPB session |
obj |
The proxy object for the remote object |
methodDesc |
An arbitrary string stored as an alias
name for the remote method in the proxy, for example: |
ci |
The parameters and return value setting for the call |
PBXRESULT.PBX_OK if the call succeeded.
This example shows a header file for a sample marshaler class:
#include "sampleinclude.h"
#include <pbext.h> class SampleMarshaler : public IPBX_Marshaler { private: string d_mystring; long d_mylong; private: void myMethod(string arg1); public: SampleMarshaler( string myString, long mylong ); ~SampleMarshaler(); virtual PBXRESULT InvokeRemoteMethod ( IPB_Session* session, pbproxyObject obj, LPCTSTR methodDesc, PBCallInfo* ci );
virtual pbulong GetModuleHandle(); virtual void Destroy();};
The associated C++ implementation file contains code like this:
PBXRESULT SampleMarshaler::InvokeRemoteMethod ( IPB_Session* session, pbproxyObject obj, LPCTSTR methodDesc, PBCallInfo* ci ) { // method invocation }
You must implement this method in the marshaler native class.