IPB_Session interface:
SetMarshaler method
Description
Sets a marshaler that will be used to invoke remote methods
and convert PowerBuilder data formats to the user's communication
protocol.
Syntax
SetMarshaler(pbproxyObject obj, IPBX_Marshaler* marshaler)
Argument
|
Description
|
obj
|
An object of type pbproxyObject to
be used as a proxy for a remote object that was created using NewProxyObject
|
marshaler
|
A class inherited from IPBX_Marshaler
|
Return Values
None.
Examples
This example creates a JavaMarshaler class and associates
it with a proxy object:
// Create JavaMarshaler
JavaMarshaler* marshaler = new JavaMarshaler(env,
proxy, jobj);
// Associate the JavaMarshaler with the PB proxy
session->SetMarshaler(proxy, marshaler);
ci->pArgs->GetAt(0)->SetObject(proxy);
ci->returnValue->SetLong(kSuccessful);
return PBX_OK;
Usage
The SetMarshaler function associates an
object of type IPBX_Marshaler with a PBProxy object. It
is possible to associate multiple marshaler objects with a single
proxy object. It is also possible to associate one marshaler object
with multiple proxy objects. Neither of these is good coding practice
and should be avoided.
Before calling SetMarshaler, you can call
the IPB_Session GetMarshaler function
to obtain an existing marshaler object associated with a given proxy object,
and then destroy the existing marshaler object before associating
a new marshaler with the proxy.
When a proxy object is destroyed, it calls the associated
marshaler object's Destroy method. If
multiple proxy objects are associated with a single marshaler object,
you need to implement some form of reference counting. Otherwise,
the marshaler object is destroyed when the first associated proxy object
is destroyed, and subsequent calls to the marshaler object's Destroy method,
when other associated proxy objects are destroyed, will throw exceptions.
To avoid these issues, there should be a one-to-one relationship
between marshaler and proxy objects.
See Also