kaos.core.service.util
Class MethodCallProxy

java.lang.Object
  extended by kaos.core.service.util.MethodCallProxy
Direct Known Subclasses:
DirectoryServiceProxy, DSCoordinatorProxy

public class MethodCallProxy
extends java.lang.Object

Author:
jlott MethodCallProxy is the base class for handling synchronization of MethodCallRequest and MethodCallResult messages. It has a method which allows you to send a MethodCallRequest and blocks until it receives the matching MethodCallResult. The actual sending and receiving of the messages is handled externally, in order to make this class independent of the actual communication mechanism. (e.g. it can be used with a URL connection, as with the TunnelClient, or with a MessageTransportService, via the MethodCallProxyHelper or a custom implementation as with KAoSAgentDirectoryService).

Nested Class Summary
static class MethodCallProxy.OperationWaiter
          This class is used as a helper class to block Threads invoking the various Directory operations (register, deregister, modify, search).
 
Field Summary
protected static Logger _logger
           
protected  MsgSender _msgSender
           
protected  java.util.Map<java.lang.String,MethodCallProxy.OperationWaiter> _waiters
           
 
Constructor Summary
MethodCallProxy()
           
 
Method Summary
 MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
           
 MethodCallResultMsg getResult(MethodCallRequestMsg msgOut, java.lang.String operationName)
          Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager.
 void init(MsgSender msgSender)
           
protected  void notifyWaitersOfError(java.lang.Exception xcp)
           
 void receiveMessage(Msg msgIn)
           
protected  void sendMessage(Msg msgOut)
           
 void sendRequestNoWait(MethodCallRequestMsg msgOut)
          Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_logger

protected static Logger _logger

_waiters

protected java.util.Map<java.lang.String,MethodCallProxy.OperationWaiter> _waiters

_msgSender

protected MsgSender _msgSender
Constructor Detail

MethodCallProxy

public MethodCallProxy()
Method Detail

init

public void init(MsgSender msgSender)

receiveMessage

public void receiveMessage(Msg msgIn)

sendMessage

protected void sendMessage(Msg msgOut)
                    throws java.lang.Exception
Throws:
java.lang.Exception

getResult

public MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
                              throws DirectoryFailure
Throws:
DirectoryFailure

getResult

public MethodCallResultMsg getResult(MethodCallRequestMsg msgOut,
                                     java.lang.String operationName)
                              throws DirectoryFailure
Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager. Create an OperationWaiter object and store it in the _waiters hashtable. This object is associated with the current MethodCallRequestMsg and it will store the MethodCallResultsMsg, when the result arrives. After sending the TransportMessage, wait for the result.

Throws:
DirectoryFailure

sendRequestNoWait

public void sendRequestNoWait(MethodCallRequestMsg msgOut)
                       throws DirectoryFailure
Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager. Will not wait for the result.

Throws:
DirectoryFailure

notifyWaitersOfError

protected void notifyWaitersOfError(java.lang.Exception xcp)