Package jade.imtp.leap.nio
Class NIOHTTPBEDispatcher
- java.lang.Object
-
- jade.imtp.leap.nio.NIOHTTPBEDispatcher
-
- All Implemented Interfaces:
BEConnectionManager,Dispatcher,JICPMediator,NIOMediator
public class NIOHTTPBEDispatcher extends Object implements NIOMediator, Dispatcher, BEConnectionManager
- Author:
- Eduard Drenth: Logica, 11-jul-2009
-
-
Constructor Summary
Constructors Constructor Description NIOHTTPBEDispatcher()
-
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 mediatorPropertiesgetProperties()Retrieve the startup Properties for this NIOMediator.voidhandleConnectionError(Connection c, Exception e)Notify this NIOMediator that an error occurred on one of the Connections it was using.booleanhandleIncomingConnection(Connection c, JICPPacket pkt, InetAddress addr, int port)Handle an incoming connection.JICPPackethandleJICPPacket(Connection c, JICPPacket pkt, InetAddress addr, int port)Handle an incoming JICP packet received by the MediatorManagerJICPPackethandleJICPPacket(JICPPacket pkt, InetAddress addr, int port)Passes to this JICPMediator a JICP packet.voidinit(JICPMediatorManager mgr, String id, Properties props)Initialize parameters and activate the BackEndContainervoidkill()Termination self initiated or forced by the MediatorManager we are attached to.voidshutdown()Termination initiated by the BackEndContainer (i.e.voidtick(long time)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
-
kill
public void kill()
Termination self initiated or forced by the MediatorManager we are attached to.- Specified by:
killin interfaceJICPMediator
-
tick
public void tick(long time)
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
-
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. In both cases the Front-end is connecting --> Set the front-end status to CONNECTING, but don't use this connection: to allow us sending commands to the front-end an initial dummy response will be received soon.- 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.
-
handleJICPPacket
public JICPPacket handleJICPPacket(Connection c, JICPPacket pkt, InetAddress addr, int port) throws ICPException
Handle an incoming JICP packet received by the MediatorManager- Specified by:
handleJICPPacketin interfaceNIOMediator- Throws:
ICPException
-
handleJICPPacket
public JICPPacket handleJICPPacket(JICPPacket pkt, InetAddress addr, int port) throws ICPException
Description copied from interface:JICPMediatorPasses to this JICPMediator a JICP packet. This is called by the JICPServer this Mediator is attached to when a JICPPacket is received having the recipient-ID field set to the ID of this JICPMediator.- Specified by:
handleJICPPacketin interfaceJICPMediator- Parameters:
pkt- the JICPPacketaddr- the address of the mediated entityport- the local port used by the mediated entity- Throws:
ICPException
-
handleConnectionError
public void handleConnectionError(Connection c, Exception e)
Description copied from interface:NIOMediatorNotify this NIOMediator that an error occurred on one of the Connections it was using. This information is important since, unlike normal mediators, a NIOMediator may not read packets from connections on its own (the JICPMediatorManager does that in general).- Specified by:
handleConnectionErrorin interfaceNIOMediator
-
getProperties
public Properties getProperties()
Description copied from interface:NIOMediatorRetrieve the startup Properties for this NIOMediator.- Specified by:
getPropertiesin interfaceNIOMediator
-
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()
Termination initiated by the BackEndContainer (i.e. by the platform). When the BackEndContainer exits- Specified by:
shutdownin interfaceBEConnectionManager
-
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
-
-