Package jade.imtp.leap.http
Class HTTPBEDispatcher
- java.lang.Object
-
- jade.imtp.leap.http.HTTPBEDispatcher
-
- All Implemented Interfaces:
BEConnectionManager,Dispatcher,JICPMediator
public class HTTPBEDispatcher extends Object implements BEConnectionManager, Dispatcher, JICPMediator
Class declaration- Author:
- Giovanni Caire - TILAB
-
-
Constructor Summary
Constructors Constructor Description HTTPBEDispatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]dispatch(byte[] payload, boolean flush, int oldSessionId)This is called by the Stub using this Dispatcher to dispatch a serialized command to the FrontEnd.FrontEndgetFrontEnd(BackEnd be, Properties props)Return a stub of the remote FrontEnd that is connected to the local BackEnd.StringgetID()Retrieve the ID of this mediatorprotected voidhandleConnectionError()booleanhandleIncomingConnection(Connection c, JICPPacket pkt, InetAddress addr, int port)Handle an incoming connection.JICPPackethandleJICPPacket(JICPPacket pkt, InetAddress addr, int port)Handle an incoming JICP packet received by the MediatorManager.protected voidhandlePeerExited()voidinit(JICPMediatorManager mgr, String id, Properties props)Initialize parameters and activate the BackEndContainervoidkill()Shutdown self initiated or forced by the MediatorManager this BackEndContainer is attached to.voidshutdown()Clean up this HTTPBEDispatcher.protected BackEndSkelstartBackEndContainer(Properties props)voidtick(long currentTime)This is periodically called by the JICPMediatorManager and should be used by a JICPMediator to evaluate the elapsed time without the need of a dedicated thread or timer.
-
-
-
Method Detail
-
getID
public String getID()
Description copied from interface:JICPMediatorRetrieve the ID of this mediator- Specified by:
getIDin interfaceJICPMediator
-
init
public void init(JICPMediatorManager mgr, String id, Properties props) throws ICPException
Initialize parameters and activate the BackEndContainer- Specified by:
initin interfaceJICPMediator- Throws:
ICPException
-
startBackEndContainer
protected final BackEndSkel startBackEndContainer(Properties props) throws ICPException
- Throws:
ICPException
-
kill
public void kill()
Shutdown self initiated or forced by the MediatorManager this BackEndContainer is attached to.- Specified by:
killin interfaceJICPMediator
-
handleJICPPacket
public JICPPacket handleJICPPacket(JICPPacket pkt, InetAddress addr, int port) throws ICPException
Handle an incoming JICP packet received by the MediatorManager.- Specified by:
handleJICPPacketin interfaceJICPMediator- Parameters:
pkt- the JICPPacketaddr- the address of the mediated entityport- the local port used by the mediated entity- Throws:
ICPException
-
handleIncomingConnection
public boolean handleIncomingConnection(Connection c, JICPPacket pkt, InetAddress addr, int port)
Handle an incoming connection. This is called by the MediatorManager when a CREATE or CONNECT_MEDIATOR request is received. The HTTPBEDispatcher reacts to this call by resetting the current situation- Specified by:
handleIncomingConnectionin interfaceJICPMediator- Parameters:
c- the connection to the mediated entitypkt- the packet that was sent by the mediated entity when opening this connectionaddr- the address of the mediated entityport- the local port used by the mediated entity- Returns:
- an indication to the JICPMediatorManager to keep the connection open.
-
tick
public void tick(long currentTime)
Description copied from interface:JICPMediatorThis is periodically called by the JICPMediatorManager and should be used by a JICPMediator to evaluate the elapsed time without the need of a dedicated thread or timer.- Specified by:
tickin interfaceJICPMediator
-
dispatch
public byte[] dispatch(byte[] payload, boolean flush, int oldSessionId) throws ICPExceptionThis is called by the Stub using this Dispatcher to dispatch a serialized command to the FrontEnd. Mutual exclusion with itself to ensure one command at a time is dispatched.- Specified by:
dispatchin interfaceDispatcher- Throws:
ICPException
-
getFrontEnd
public FrontEnd getFrontEnd(BackEnd be, Properties props) throws IMTPException
Return a stub of the remote FrontEnd that is connected to the local BackEnd.- Specified by:
getFrontEndin interfaceBEConnectionManager- Parameters:
be- The local BackEndprops- Additional (implementation dependent) connection configuration properties.- Returns:
- A stub of the remote FrontEnd.
- Throws:
IMTPException
-
shutdown
public void shutdown()
Clean up this HTTPBEDispatcher. The shutdown process can be activated in the following cases: 1) The local container is requested to exit --> The exit commad is forwarded to the FrontEnd 1.a) Forwarding OK. The FrontEnd sends back a response with the TERMINATED_INFO set. When this response is received the shutdown() method is called (see handleJICPPacket()). 1.b) Forwarding failed. The BackEndContainer ignores the exception and directly calls the shutdown() method. Note that in the case the FrontEnd spontaneously exits and in the case the max disconnection time expires the kill() method is called --> see case 1.- Specified by:
shutdownin interfaceBEConnectionManager
-
handlePeerExited
protected void handlePeerExited()
-
handleConnectionError
protected void handleConnectionError()
-
-