kaos.core.service.util
Class MethodCallProxy

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

public class MethodCallProxy
extends java.lang.Object


Nested Class Summary
protected 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  JasBean _entityEnv
           
protected static Logger _logger
           
protected  Locator _myLocator
           
protected  java.lang.String _nickName
           
protected static java.lang.String _NICKNAME_ROOT
           
protected  Locator _remoteLocator
           
protected  java.lang.String _remoteNickname
           
protected  MessageSender _sender
           
protected  java.util.Hashtable _waiters
           
 
Constructor Summary
MethodCallProxy()
           
 
Method Summary
protected  Locator bindToMessageTransportService(MessageTransportService mts)
          Private methods.
 boolean equals(java.lang.Object obj)
           
protected  MethodCallResultMsg getResult(MethodCallRequestMsg msgOut)
           
protected  MethodCallResultMsg getResult(MethodCallRequestMsg msgOut, java.lang.String operationName)
          Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager.
 int hashCode()
           
 boolean initialize(MessageTransportService mts, JasBean entityEnv, Locator remoteLocator, java.lang.String remoteNickname)
           
protected  JasBean obtainEntityEnv()
           
protected  void printDebugString(java.lang.String msg, int loggerDisplayLevel)
          A utility method to print a String.
 void receiveMessage(TransportMessage msg)
          Receive a TransportMessage message from the MessageReceiver.
protected  void removeWaiter(java.lang.String id)
           
protected  void sendRequestNoWait(MethodCallRequestMsg msgOut)
          Wrap the MethodCallRequestMsg into a TransportMessage message and send it to the Domain Manager.
protected  MethodCallResultMsg waitForReply(java.lang.String operationID, java.lang.String operationName)
          This method is called immediately after a Directory operation is requested and a message containing the MethodCallRequestMsg is sent to the DM.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_NICKNAME_ROOT

protected static final java.lang.String _NICKNAME_ROOT
See Also:
Constant Field Values

_logger

protected static Logger _logger

_remoteNickname

protected java.lang.String _remoteNickname

_nickName

protected java.lang.String _nickName

_sender

protected MessageSender _sender

_myLocator

protected Locator _myLocator

_remoteLocator

protected Locator _remoteLocator

_waiters

protected java.util.Hashtable _waiters

_entityEnv

protected JasBean _entityEnv
Constructor Detail

MethodCallProxy

public MethodCallProxy()
Method Detail

initialize

public boolean initialize(MessageTransportService mts,
                          JasBean entityEnv,
                          Locator remoteLocator,
                          java.lang.String remoteNickname)

receiveMessage

public void receiveMessage(TransportMessage msg)
Receive a TransportMessage message from the MessageReceiver. Unwrap the TransportMessage to get the MethodCallResultMsg from the DomainManager. Notify the correct waiter object, blocking a Thread that invoked the Directory operation, whose results were just received in this receiveMessage call. Based on the result, the notification will unblock the waiting Thread, which will either deliver the DomainManager's reply to the correct invoker, or throw an exception, if the the DomainManager threw one as a reply.

Parameters:
msg - the TransportMessage containing DomainManager's reply to one of: register/deregister/modify/search/removeExecEnv requests.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

printDebugString

protected void printDebugString(java.lang.String msg,
                                int loggerDisplayLevel)
A utility method to print a String. Add the name of the class printing the String.

Parameters:
msg - The String to be printed.

bindToMessageTransportService

protected Locator bindToMessageTransportService(MessageTransportService mts)
                                         throws java.lang.Exception
Private methods. /****************************************************************************************** /** Obtain transport specific parameters, if any, obtain the Locator and MessageReceiver for this MethodCallProxy, and bind the Locator to the MessageReceiver.

Throws:
java.lang.Exception

getResult

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

getResult

protected 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

protected 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

obtainEntityEnv

protected JasBean obtainEntityEnv()

waitForReply

protected MethodCallResultMsg waitForReply(java.lang.String operationID,
                                           java.lang.String operationName)
                                    throws DirectoryFailure
This method is called immediately after a Directory operation is requested and a message containing the MethodCallRequestMsg is sent to the DM. If the result comes back even before this method is invoked (like in CORBA sometimes), then retrieve the result from the corrensponding OperationWaiter object and return the result. If this method is invoked before the result comes back, block the current Thread and wait for the result. Waiting is accomplished using the OperationWaiter object, which is associated with this request and invoking the wait() method on it. After the result is received and this waiting Thread is unblocked (in doNotify() method of the OperationWaiter), the result is returned to the agent.

Throws:
DirectoryFailure

removeWaiter

protected void removeWaiter(java.lang.String id)