mChaRM.multichannel
Class receiverStub

java.lang.Object
  |
  +--uka.karmi.rmi.server.RemoteObject
        |
        +--uka.karmi.rmi.server.UnicastRemoteObject
              |
              +--mChaRM.multichannel.stub
                    |
                    +--mChaRM.multichannel.receiverStub
All Implemented Interfaces:
java.lang.Cloneable, receiverStubInterface, uka.karmi.rmi.Remote, stubInterface
Direct Known Subclasses:
RMPReceiverStub, verboseReceiverStub

public class receiverStub
extends stub
implements receiverStubInterface

Instances of this class are used as stubs of the multi-channel on the receiver site. Each receiver connected to a multi-channel will be extended by a stub of such a multi-channel.
This class defines the meta-computations that have to be performed on the receiver side. Each new meta-behavior to be performed on the receiver side can be defined extending this class and overrinding the method receiverSideMetaBehavior.

Since:
Version 1.0
Version:
1.2
Author:
Walter Cazzola (cazzola@disi.unige.it)

Fields inherited from class uka.karmi.rmi.server.RemoteObject
serverRef
 
Constructor Summary
receiverStub(java.lang.Object myReferent, java.lang.String myKind, java.lang.String myReferentName)
          receiverStub constructor.
 
Method Summary
 void afterReceiverSideMetaBehavior(mChaRMMethodCall msg)
          it is called after the true invocation and performs meta-computation on the return value in the target locus.
 void beforeReceiverSideMetaBehavior(mChaRMMethodCall msg)
          it is called before the true invocation and performs meta-computation on the message in the target locus.
 java.lang.Object invoke(mChaRMMethodCall msg)
          it performs the meta-computation on the receiver side -- calling the method receiverSideMetaBehavior --, then really invoke the method reified by the meta-computationi -- invoking the tInvoke method.
protected  java.lang.Object tInvoke(mChaRMMethodCall msg)
          it invokes a method with the actual arguments on the receiver side.
 
Methods inherited from class mChaRM.multichannel.stub
referent, retrieveField, setReferent, setWhoIsMyCore, WhoIsMyCore
 
Methods inherited from class uka.karmi.rmi.server.UnicastRemoteObject
buildStub, clone, exportObject, exportObject, unexportObject
 
Methods inherited from class uka.karmi.rmi.server.RemoteObject
equals, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface mChaRM.multichannel.stubInterface
retrieveField
 

Constructor Detail

receiverStub

public receiverStub(java.lang.Object myReferent,
                    java.lang.String myKind,
                    java.lang.String myReferentName)
             throws uka.karmi.rmi.RemoteException,
                    ReceiverStubCannotBeRegisteredAsAServerException,
                    CoreNotFoundException
receiverStub constructor.
it initialize the stub, registers it as a remote server, and connect it to the core of the multi-channel.
Parameters:
myReferent - a representant of the stub referent.
myKind - the multi-channel's name.
myReferentName - the referent's name.
Throws:
ReceiverStubCannotBeRegisteredAsAServerException - thrown when the stub cannot be registered as a server.
CoreNotFoundException - thrown when the core of the multi-channel, which the stub is part of, doesn't exist or isn't correctly registered as a server.
Method Detail

invoke

public final java.lang.Object invoke(mChaRMMethodCall msg)
                              throws MethodDoesNotExistException
it performs the meta-computation on the receiver side -- calling the method receiverSideMetaBehavior --, then really invoke the method reified by the meta-computationi -- invoking the tInvoke method.
It is called by the coreMetaBehavior method of the multi-channel core. It cannot be overrode.
Note that as side-effect the receiverSideMetaBehavior method can change the value of the arguments used by tInvoke.
Specified by:
invoke in interface receiverStubInterface
Parameters:
msg - the hijacked method call.
Returns:
the result of the method invocation
Throws:
MethodDoesNotExistException - thrown when the method reified doesn't exist in the referent class.

tInvoke

protected final java.lang.Object tInvoke(mChaRMMethodCall msg)
                                  throws MethodDoesNotExistException
it invokes a method with the actual arguments on the receiver side.
it uses the reflection mechanism offered by the Java API Core Reflection. It is able to handle overloaded method. It cannot neither be overrode nor directly invoked by user.
Parameters:
msg - the hijacked method call.
Returns:
the result of the method invocation.
Throws:
MethodDoesNotExistException - thrown when the method reified doesn't exist in the referent class.

beforeReceiverSideMetaBehavior

public void beforeReceiverSideMetaBehavior(mChaRMMethodCall msg)
it is called before the true invocation and performs meta-computation on the message in the target locus.
as default nothing it is done, it is possible to define new behavior defing a new subclass overriding this method.
Parameters:
msg - the hijacked method call.

afterReceiverSideMetaBehavior

public void afterReceiverSideMetaBehavior(mChaRMMethodCall msg)
it is called after the true invocation and performs meta-computation on the return value in the target locus.
as default nothing it is done, it is possible to define new behavior defing a new subclass overriding this method.
Parameters:
msg - the hijacked method call.