This class is the base class for any component connected to a dynamic view server and for the interface of these components as handled by the server. More...
#include <ilserver/mvendpt.h>
Classes | |
class | ConnectionListener |
Class used to listen disconnections. More... | |
Public Types | |
enum | TraceType { NO_TRACE, TRACE_TRANS, TRACE_MSG , TRACE_TAG_ERR, TRACE_TAG_PRINT } |
Specifies the type of trace attached to interactions between an object server and its components. See the trace functions of the class IlsMvEndPoint for more information. More... | |
Public Member Functions | |
void | traceConnectionDenied (IlsBoolean b) |
Allows you to control whether an error message should be displayed when a connection is refused. | |
Accessors | |
const IlsString & | getPeerName () const |
Returns remote process name. More... | |
const IlsString & | getPeerHost () const |
Returns host if remote connection. More... | |
IlsBoolean | isComponent () const |
This member function returns IlsTrue when the object is an instance of IlsMvComponent or of a derived class. Otherwise, it returns IlsFalse. | |
IlsBoolean | isLinked () const |
This member function returns IlsTrue when the component and the server are implemented in the same process. Otherwise, it returns IlsFalse. | |
Suppression | |
virtual void | suppress () |
Call this virtual member function instead of the destructor if you want to delete an instance of IlsMvEndPoint . More... | |
Request Input/Output Control | |
IlsBoolean | setEncoder (IlsMsgEncoder) |
Declares the function encoding to be applied on any message before it is sent through the connnection. More... | |
IlsBoolean | setDecoder (IlsMsgDecoder) |
Declares the function encoding to be applied on any message received through the connnection. More... | |
IlsMsgEncoder | getEncoder () const |
Returns the encoding function set through a call to the function setEncoder() or 0 by default. | |
IlsMsgDecoder | getDecoder () const |
Returns the decoding function set through a call to the function setDecoder() or 0 by default. | |
Loading Views Specification | |
void | loadViewSpec (const IlsString &fileOrString, IlsBoolean isString, IlsBoolean useXmlParser, IlsBoolean isSync) |
Loads a dynamic view-type specification to the server. More... | |
Callbacks to Member Functions | |
These callbacks are used to execute functions on objects that are implemented at the end point of the connection. Callbacks for member functions take a reference to the object that must execute the function as their first parameter.
Callbacks can be asynchronous, synchronous or duplex. A duplex callback is a pair of symmetric asynchronous calls. The result of the original callback is sent back to the caller as an argument to a second callback. To avoid deadlock problems related to synchronous calls, it is strongly recommended to keep a fully asynchronous interaction protocol between components and servers. This enables you to choose duplex callbacks whenever possible instead of synchronous callbacks. The relevant member functions must have been previously declared to the server model interpreter or to the representation model interpreter by using the macros | |
IlsBoolean | execAsyncObjectCallback (const IlsMvRef &ref, const IlsString &funNm, IlsMvValue *args, IlsCbArgNb nbArgs, IlsBoolean inTrans=IlsTrue, IlsBoolean freeArgs=IlsFalse) |
Executes an asynchronous call to the function funNm on the object identified by the reference ref. More... | |
IlsBoolean | execSyncObjectCallback (const IlsMvRef &ref, const IlsString &funNm, IlsMvValue *args, IlsCbArgNb nbArgs, IlsMvValue &result, IlsBoolean freeArgs=IlsFalse) |
This callback executes a synchronous call to the callback function funNm on the object identified by the reference ref. More... | |
IlsBoolean | execDuplexObjectCallback (const IlsMvRef &ref, const IlsString &funNm, IlsMvValue *args, IlsCbArgNb nbArgs, const IlsString &duplexFunNm, IlsMvValue *duplexArgs=0, IlsCbArgNb duplexNbArgs=0, IlsCbArgNb resultIndex=0, IlsBoolean inTrans=IlsTrue, IlsBoolean freeArgs=IlsFalse) |
Executes an asynchronous call to the function funNm on the "remote" object identified by the reference ref. More... | |
Callbacks to Global Functions | |
These callbacks are used to execute global functions at the end point of the connection. As callbacks to member functions, global callbacks can be asynchronous, synchronous or duplex. A duplex callback is a pair of symmetric asynchrono us calls. See Synchronous/Asynchronous Callbacks for more comments on these modes. The relevant global functions must have been previously declared to the server model interpreter of the server or to the representation model interpreter by using the macros | |
IlsBoolean | execAsyncGlobalCallback (const IlsString &funNm, IlsMvValue *args, IlsCbArgNb nbArgs, IlsBoolean inTrans=IlsTrue, IlsBoolean freeArgs=IlsFalse) |
This callback executes an asynchronous call to the global function funNm. More... | |
IlsBoolean | execSyncGlobalCallback (const IlsString &funNm, IlsMvValue *args, IlsCbArgNb nbArgs, IlsMvValue &result, IlsBoolean freeArgs=IlsFalse) |
This callback executes a synchronous call to the global function funNm. More... | |
IlsBoolean | execDuplexGlobalCallback (const IlsString &funNm, IlsMvValue *args, IlsCbArgNb nbArgs, const IlsString &duplexFunNm, IlsMvValue *duplexArgs=0, IlsCbArgNb duplexNbArgs=0, IlsCbArgNb resultIndex=0, IlsBoolean inTrans=IlsTrue, IlsBoolean freeArgs=IlsFalse) |
This callback executes an asynchronous call to the global function funNm . More... | |
Friends | |
class | IlsMvComponent |
class | IlsMvProcess |
Connection Control | |
IlsBoolean | disconnect () |
Closes the connection between the local end point and its peer end point, and then calls the function onDisconnect. More... | |
virtual void | onConnect () |
Called when the connection between the component and the server is established. More... | |
virtual void | onDisconnect () |
Called when the connection between the component and the server is destroyed. More... | |
virtual IlsConnectionStatus | testConnection (IlsTime *timeout=0) |
Can be used from server to component or from component to server to test the underlying connection between two processes. More... | |
virtual void | addConnectionListener (ConnectionListener *) |
Add a connection listener. | |
virtual void | removeConnectionListener (ConnectionListener *) |
Remove a connection listener. | |
static IlsMvEndPoint * | GetInteractor () |
Returns the current interacting component. More... | |
Thread Control | |
IlsThread * | startSendThread () |
Starts a thread in charge of sending the message to the peer end point. More... | |
IlsThread * | threadSending () |
Starts a thread that sends all notification updates and other messages generated by the server to the component. More... | |
IlsBoolean | stopSendThread (IlsBoolean flush) |
Stops the thread used to send messages. More... | |
IlsBoolean | isSendingThread () |
Returns IlsTrue if a special thread is started to send notification updates and other messages generated by the server to the component. More... | |
void | monitorSendingQueue (IlsBoolean b) |
Allows you to monitor the sending queue. More... | |
unsigned int | getPendingOutput () |
Returns the number of output messages stored in the sending queue associated with this component, if any. More... | |
static void | SetMT (IlsBoolean isMT) |
Call this static member function with the isMT parameter set to IlsTrue if you want to use the component API or the component interface API in a multithread context. | |
Trace | |
void | trace (int=TRACE_TRANS) |
Selects the type of traces at one of the end points of a view server-to-component connection. More... | |
IlsBoolean | isTraced (int=TRACE_TRANS) |
Tests the type of traces at one of the end points of a view server-to-component connection. More... | |
int | getTraceType () const |
Returns the type of traces currently selected. | |
static void | Trace (int=TRACE_TRANS) |
Selects the default type of traces selected. More... | |
static IlsBoolean | IsTraced (int=TRACE_TRANS) |
Tests the default type of traces selected. More... | |
static int | GetTraceType () |
Returns the default type of traces. | |
This class is the base class for any component connected to a dynamic view server and for the interface of these components as handled by the server.
Library: mvserver
and mvcomp
Each time a connection is established between a component and a view server, an instance of IlsMvComponent
or of a derived class is built on the component side and an instance of IlsMvComponentItf
or of a derived class is built on the server side. This means that any connection is handled at both end points by an object derived from the class IlsMvEndPoint
.
See the functions IlsMvComponent::Narrow()
and IlsMvComponentItf::Narrow()
to learn how to downcast an IlsMvEndPoint
object safely.
The class IlsMvEndPoint
defines the basic API that enables interaction between a server and a component. Most of this API is used internally by the component or by the server. However, the API for callback functions can be accessed directly by the user on this class.
IlsMvEndPoint
controls how incoming and outgoing requests are executed both on the component side and on the server side. This class ensures a consistent behavior, whether the component and the server are distributed or linked in the same process.
IlsMvEndPoint
also implements the trace mode for each server/component connection.
IlsBoolean IlsMvEndPoint::disconnect | ( | ) |
Closes the connection between the local end point and its peer end point, and then calls the function onDisconnect.
IlsFalse
. Otherwise, it returns IlsTrue
. IlsBoolean IlsMvEndPoint::execAsyncGlobalCallback | ( | const IlsString & | funNm, |
IlsMvValue * | args, | ||
IlsCbArgNb | nbArgs, | ||
IlsBoolean | inTrans = IlsTrue , |
||
IlsBoolean | freeArgs = IlsFalse |
||
) |
This callback executes an asynchronous call to the global function funNm.
It also takes the following parameters:
IlsMvValue
objects args
.nbArgs
is the size of this array.inTrans
freeArgs
This function returns
funNm | the global function's name |
args | an array of IlsMvValue objects that contains the function arguments |
nbArgs | size of the args array |
inTrans | indicates whether the callback must be executed using the transaction mechanism or not (see Transaction Control in the IlsMvComponent class description). If this parameter is set to IlsTrue (default value) and no current transaction has been initialized, a new transaction is implicitly created and committed. |
freeArgs | indicates whether the argument array must be freed by Rogue Wave Server or not:
|
IlsFalse
when the callback request cannot be sent, which means that the connection has been closed. Otherwise, it returns IlsTrue
.IlsTrue
return value does not mean that the function funNm has been successfully executed. IlsBoolean IlsMvEndPoint::execAsyncObjectCallback | ( | const IlsMvRef & | ref, |
const IlsString & | funNm, | ||
IlsMvValue * | args, | ||
IlsCbArgNb | nbArgs, | ||
IlsBoolean | inTrans = IlsTrue , |
||
IlsBoolean | freeArgs = IlsFalse |
||
) |
Executes an asynchronous call to the function funNm on the object identified by the reference ref.
ref | reference of the object on which executing the callback |
funNm | name of the member function to execute |
args | an array of IlsMvValue objects that contains the function arguments |
nbArgs | size of the args array |
inTrans | indicates whether the callback must be executed using the transaction mechanism or not (see Transaction Control in the IlsMvComponent class description). If this parameter is set to IlsTrue (default value) and no current transaction has been initialized, a new transaction is implicitly created and committed. |
freeArgs | indicates whether the argument array must be freed by Rogue Wave Server or not. |
IlsFalse
when the callback request cannot be sent, which means that the connection has been closed; otherwise it returns IlsTrue
. If the inTrans parameter is true, the call is batched in the current update transaction and the method returns true.IlsTrue
return value does not mean that the function funNm has been successfully executed. IlsBoolean IlsMvEndPoint::execDuplexGlobalCallback | ( | const IlsString & | funNm, |
IlsMvValue * | args, | ||
IlsCbArgNb | nbArgs, | ||
const IlsString & | duplexFunNm, | ||
IlsMvValue * | duplexArgs = 0 , |
||
IlsCbArgNb | duplexNbArgs = 0 , |
||
IlsCbArgNb | resultIndex = 0 , |
||
IlsBoolean | inTrans = IlsTrue , |
||
IlsBoolean | freeArgs = IlsFalse |
||
) |
This callback executes an asynchronous call to the global function funNm
.
As explained in Synchronous/Asynchronous Callbacks, the result of the function is sent back to the caller through a call to the duplex function duplexFunNm.
funNm | the global function's name |
args | an array of IlsMvValue objects that contains the function arguments |
nbArgs | size of the args array |
duplexFunNm | name of the duplex callback |
duplexArgs | arguments to be passed to the duplex function duplexFunNm stored as an array of IlsMvValue objects. |
duplexNbArgs | the size of the duplexArgs array |
resultIndex | the index of the arguments passed to the duplexFunNm function, which will contain the result of the function funNm. |
inTrans | indicates whether the callback must be executed using the transaction mechanism or not (see Transaction Control in the IlsMvComponent class description). If this parameter is set to IlsTrue (default value) and no current transaction has been initialized, a new transaction is implicitly created and committed. |
freeArgs | indicates whether the argument array must be freed by Rogue Wave Server or not:
|
IlsFalse
when the callback request cannot be sent, which means that the connection has been closed. Otherwise, it returns IlsTrue
.IlsTrue
return value does not mean that the function funNm has been successfully executed. The function referred to by the duplexFunNm parameter must have been declared locally as a global function. IlsBoolean IlsMvEndPoint::execDuplexObjectCallback | ( | const IlsMvRef & | ref, |
const IlsString & | funNm, | ||
IlsMvValue * | args, | ||
IlsCbArgNb | nbArgs, | ||
const IlsString & | duplexFunNm, | ||
IlsMvValue * | duplexArgs = 0 , |
||
IlsCbArgNb | duplexNbArgs = 0 , |
||
IlsCbArgNb | resultIndex = 0 , |
||
IlsBoolean | inTrans = IlsTrue , |
||
IlsBoolean | freeArgs = IlsFalse |
||
) |
Executes an asynchronous call to the function funNm on the "remote" object identified by the reference ref.
As explained in Synchronous/Asynchronous Callbacks, the result of the function is sent back to the caller through a call to the duplex function duplexFunNm on the "local" object associated with the reference ref.
ref | reference of the object on which executing the callback |
funNm | name of the member function to execute |
args | an array of IlsMvValue objects that contains the function arguments |
nbArgs | size of the args array |
duplexFunNm | name of the duplex callback |
duplexArgs | arguments to be passed to the duplex function duplexFunNm stored as an array of IlsMvValue objects. |
duplexNbArgs | the size of the duplexArgs array |
resultIndex | index of the arguments passed to the duplexFunNm function, which will contain the result of the function funNm . |
inTrans | indicates whether the callback must be executed using the transaction mechanism or not (Transaction Control in the IlsMvComponent class description). If this parameter is set to IlsTrue (its default value) and no current transaction has been initialized, a new transaction is implicitly created and committed. |
freeArgs | indicates whether the argument array must be freed by Rogue Wave Server or not:
|
IlsFalse
when the callback request cannot be sent, which means that the connection has been closed. Otherwise, it returns IlsTrue
.IlsTrue
return value does not mean that the function funNm has been successfully executed. IlsBoolean IlsMvEndPoint::execSyncGlobalCallback | ( | const IlsString & | funNm, |
IlsMvValue * | args, | ||
IlsCbArgNb | nbArgs, | ||
IlsMvValue & | result, | ||
IlsBoolean | freeArgs = IlsFalse |
||
) |
This callback executes a synchronous call to the global function funNm.
funNm | the global function's name |
args | an array of IlsMvValue objects that contains the function arguments |
nbArgs | size of the args array |
result | a reference assigned by Rogue Wave Server to the result of the global function. When the callback fails, the value of the result parameter remains unchanged. |
freeArgs | indicates whether the argument array must be freed by Rogue Wave Server or not:
|
IlsFalse
when the callback request cannot be sent, which means that the connection has been closed. Otherwise, it returns IlsTrue
. IlsBoolean IlsMvEndPoint::execSyncObjectCallback | ( | const IlsMvRef & | ref, |
const IlsString & | funNm, | ||
IlsMvValue * | args, | ||
IlsCbArgNb | nbArgs, | ||
IlsMvValue & | result, | ||
IlsBoolean | freeArgs = IlsFalse |
||
) |
This callback executes a synchronous call to the callback function funNm on the object identified by the reference ref.
ref | reference of the object on which executing the callback |
funNm | name of the member function to execute |
args | an array of IlsMvValue objects that contains the function arguments |
nbArgs | size of the args array |
result | a reference assigned by Rogue Wave Server to the result of the member function. |
freeArgs | indicates whether the argument array must be freed by Rogue Wave Server or not:
|
IlsFalse
when the callback request cannot be sent, which means that the connection has been closed. Otherwise, it returns IlsTrue
.
|
static |
Returns the current interacting component.
A current interactor is set when an incoming message is being processed, that is when a callback is executed, or when an notification is processed, or when a component-to-server request is processed. The interactor is:
IlsMvComponent
(or of a subclass) if the method is called while a message is processed on the component side, orIlsMvComponentItf
if the method is called while a message is processed on the server side.If the method is called without any message processing, it returns 0
.
const IlsString& IlsMvEndPoint::getPeerHost | ( | ) | const |
Returns host if remote connection.
In case of a distributed component-to-server connection, this member function returns the host name of the connected process. Otherwise, it returns the null constant IlsString::Null
.
const IlsString& IlsMvEndPoint::getPeerName | ( | ) | const |
Returns remote process name.
This member function returns the name assigned to the process at the peer end point of the connection (by a call to the static member function IlsMvProcess::SetName()
). By default, or if the connection is closed, the function returns the null string.
unsigned int IlsMvEndPoint::getPendingOutput | ( | ) |
Returns the number of output messages stored in the sending queue associated with this component, if any.
IlsBoolean IlsMvEndPoint::isSendingThread | ( | ) |
Returns IlsTrue
if a special thread is started to send notification updates and other messages generated by the server to the component.
IlsTrue
is there is a sending thread IlsBoolean IlsMvEndPoint::isTraced | ( | int | tt = TRACE_TRANS | ) |
Tests the type of traces at one of the end points of a view server-to-component connection.
The parameter should be assigned a value of type IlsMvEndPoint::TraceType
value or an ORing expression of values of this enumerated type. By default, this parameter is assigned the value TRACE_TRANS
.
This function returns IlsTrue
if all the trace type values making of the parameter value match the currently selected value.
|
static |
Tests the default type of traces selected.
The parameter should be assigned a value of type IlsMvEndPoint::TraceType
or an ORing expression of values of this enumerated type. By default, this parameter is assigned the value TRACE_TRANS
.
This function returns IlsTrue
if all the trace type values making up the parameter value correspond to the selected default value.
void IlsMvEndPoint::loadViewSpec | ( | const IlsString & | fileOrString, |
IlsBoolean | isString, | ||
IlsBoolean | useXmlParser, | ||
IlsBoolean | isSync | ||
) |
Loads a dynamic view-type specification to the server.
This member function loads a dynamic view-type specification to the server, either as an instance of IlsString
(if the isString parameter is set to IlsTrue
) or from the name of the view specification file (if isString is set to IlsFalse
). The isString parameter must be specified because it has no default value. The useXmlParameter must be specified in order to use (or not) the XML Parser to load the view. The function call is synchronous if the isSync parameter is set to IlsTrue
, or asynchronous otherwise.
This member function returns IlsTrue
if the file is found and the syntax of the dynamic-view type specification is valid. Otherwise, it returns IlsFalse
.
void IlsMvEndPoint::monitorSendingQueue | ( | IlsBoolean | b | ) |
Allows you to monitor the sending queue.
if a sending thread has been associated with this component. When this property is set to IlsTrue
, Rogue Wave Server calls the function IlsMvUser::updateSendingQueueLength()
each time a message is added to, or removed from, the sending queue. By default, the sending queue is not monitored. You can call this method when the function IlsMvUser::onBind()
is called.
b | IlsTrue for monitoring the queue. |
|
virtual |
Called when the connection between the component and the server is established.
It has an empty implementation. It can be overridden.
Reimplemented in IlsMvComponent.
|
virtual |
Called when the connection between the component and the server is destroyed.
This function has an empty implementation. It is overridden in the subclasses IlsMvComponent
and IlsMvComponentItf
.
Reimplemented in IlsMvComponentItf, and IlsMvComponent.
IlsBoolean IlsMvEndPoint::setDecoder | ( | IlsMsgDecoder | ) |
Declares the function encoding to be applied on any message received through the connnection.
It returns IlsFalse
if no connection is associated with the end point (server and component being linked within the same process). Else it returns IlsTrue
.
This function must be called from the function IlsMvServer::acceptConnection()
on the server side and IlsMvComponent::onConnect()
on the component side.
IlsBoolean IlsMvEndPoint::setEncoder | ( | IlsMsgEncoder | ) |
Declares the function encoding to be applied on any message before it is sent through the connnection.
It returns IlsFalse
if no connection is associated with the end point (server and component being linked within the same process). Else it returns IlsTrue
.
This function must be called from the function IlsMvServer::acceptConnection()
on the server side and IlsMvComponent::onConnect()
on the component side.
IlsThread* IlsMvEndPoint::startSendThread | ( | ) |
Starts a thread in charge of sending the message to the peer end point.
The multithread mode must have been previously selected (see SetMT()
).
This member function returns a pointer to the created thread or 0 if the thread execution failed.
IlsBoolean IlsMvEndPoint::stopSendThread | ( | IlsBoolean | flush | ) |
Stops the thread used to send messages.
flush | when set to IlsTrue , the pending output messages are sent before the thread is stopped. |
IlsTrue
when the thread is actually stopped.IlsFalse
if no "sending thread" has been previously started.
|
virtual |
Call this virtual member function instead of the destructor if you want to delete an instance of IlsMvEndPoint
.
This function:
Reimplemented in IlsMvComponentItf.
|
virtual |
Can be used from server to component or from component to server to test the underlying connection between two processes.
This call performs a synchronous ping to the peer process and waits for an acknowledgement. The timeout parameter controls how long the acknowledgement is expected. The default value is 0
which correspond to an infinite timeout.
This function returns the connection status as a value of the enumerated type IlsConnectionStatus:
CONN_OK
if the test has been performed correctly;CONN_TIMEOUT
if the test timed out;CONN_ERROR
if an exception was raised during the test, indicating that the connection is no longer available;CONN_CLOSED
if the connection has already been closed.If you want to use this function from a separate thread, call the SetMT()
function to set up the multithread safety of the function.
IlsThread* IlsMvEndPoint::threadSending | ( | ) |
Starts a thread that sends all notification updates and other messages generated by the server to the component.
See the IlsMvServer
constructor for details about the various server threaded execution modes.
void IlsMvEndPoint::trace | ( | int | = TRACE_TRANS | ) |
Selects the type of traces at one of the end points of a view server-to-component connection.
The parameter should be assigned a value of type IlsMvEndPoint::TraceType
or an ORing expression of values of this enumerated type. By default, this parameter is assigned the value TRACE_TRANS
. Notice that the type TRACE_TAG_ERR
cannot be selected after a transaction message has been exchanged through the connection.
|
static |
Selects the default type of traces selected.
The parameter should be assigned a value of type IlsMvEndPoint::TraceType
or an ORing expression of values of this enumerated type. By default, this parameter is assigned the value TRACE_TRANS
.