org.llrp.ltk.net
Class LLRPIoHandlerAdapterImpl

java.lang.Object
  extended by org.apache.mina.common.IoHandlerAdapter
      extended by org.llrp.ltk.net.LLRPIoHandlerAdapter
          extended by org.llrp.ltk.net.LLRPIoHandlerAdapterImpl
All Implemented Interfaces:
org.apache.mina.common.IoHandler

public class LLRPIoHandlerAdapterImpl
extends LLRPIoHandlerAdapter

LLRPIoHandlerAdapterImpl is the default implementation of the LLRPIoHandlerAdapter. It handles incoming messages: routes incoming asynchronous messages to the LLRPEndpoint registered, replies to KEEP_ALIVE messages and handles incoming READER_NOTIFICATION messages and responses to synchronous calls.


Constructor Summary
LLRPIoHandlerAdapterImpl()
           
LLRPIoHandlerAdapterImpl(LLRPConnection connection)
           
 
Method Summary
 void exceptionCaught(org.apache.mina.common.IoSession session, java.lang.Throwable cause)
          
 LLRPConnection getConnection()
          gets connection on which handler is operating
 java.util.concurrent.BlockingQueue<ConnectionAttemptEvent> getConnectionAttemptEventQueue()
          returns queue with all incoming ConnectionAttemptEvent parameters which were embedded in READER_NOTIFICATION messages.
 java.util.concurrent.BlockingQueue<LLRPMessage> getSynMessageQueue()
          returns queue of all incoming messages where the messages type is equal to the one specified in the IoSession parameter LLRPConnection.SYNC_MESSAGE_ANSWER.
 boolean isKeepAliveAck()
          returns true if incoming KEEP_ALIVE messages are being acknowledged.
 boolean isKeepAliveForward()
          returns true if incoming KEEP_ALIVE messages are being forwarded to the LLRPEndpoint.
 void messageReceived(org.apache.mina.common.IoSession session, java.lang.Object message)
          is called whenever an LLRP Message is received.
 void messageSent(org.apache.mina.common.IoSession session, java.lang.Object message)
          
 void sessionIdle(org.apache.mina.common.IoSession session, org.apache.mina.common.IdleStatus status)
          
 void sessionOpened(org.apache.mina.common.IoSession session)
          
 void setConnection(LLRPConnection connection)
          sets connection on which handler is operating
 void setKeepAliveAck(boolean keepAliveAck)
          set whether incoming KEEP_ALIVE messages should be acknowledged.
 void setKeepAliveForward(boolean keepAliveForward)
          set whether incoming KEEP_ALIVE messages are being forwarded to the LLRPEndpoint.
 
Methods inherited from class org.apache.mina.common.IoHandlerAdapter
sessionClosed, sessionCreated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LLRPIoHandlerAdapterImpl

public LLRPIoHandlerAdapterImpl(LLRPConnection connection)

LLRPIoHandlerAdapterImpl

public LLRPIoHandlerAdapterImpl()
Method Detail

sessionOpened

public void sessionOpened(org.apache.mina.common.IoSession session)
                   throws java.lang.Exception

Specified by:
sessionOpened in interface org.apache.mina.common.IoHandler
Overrides:
sessionOpened in class org.apache.mina.common.IoHandlerAdapter
Throws:
java.lang.Exception

messageReceived

public void messageReceived(org.apache.mina.common.IoSession session,
                            java.lang.Object message)
                     throws java.lang.Exception
is called whenever an LLRP Message is received. The method replies to incoming KEEP_ALIVE messages by sending an KEEP_ALIVE_ACK when the keepAliveAck flag is set. ConnectionAttemptEvents of incoming are stored in a queue that can be retrieved using the getConnectionAttemptEventQueue method. messageReceived also checks whether the incoming message is a response to previously method sent via the LLRPConnection.transact method. Matching messages are stored in a queue that can be retrieved via the getSynMessageQueue() method. All incoming messages except KEEP_ALIVE and those identified as synchronous responses to the LLRPConnection.transact method are passed to the LLRPEndpoint registered.

Specified by:
messageReceived in interface org.apache.mina.common.IoHandler
Overrides:
messageReceived in class org.apache.mina.common.IoHandlerAdapter
Throws:
java.lang.Exception

messageSent

public void messageSent(org.apache.mina.common.IoSession session,
                        java.lang.Object message)
                 throws java.lang.Exception

Specified by:
messageSent in interface org.apache.mina.common.IoHandler
Overrides:
messageSent in class org.apache.mina.common.IoHandlerAdapter
Throws:
java.lang.Exception

exceptionCaught

public void exceptionCaught(org.apache.mina.common.IoSession session,
                            java.lang.Throwable cause)
                     throws java.lang.Exception

Specified by:
exceptionCaught in interface org.apache.mina.common.IoHandler
Overrides:
exceptionCaught in class org.apache.mina.common.IoHandlerAdapter
Throws:
java.lang.Exception

sessionIdle

public void sessionIdle(org.apache.mina.common.IoSession session,
                        org.apache.mina.common.IdleStatus status)
                 throws java.lang.Exception

Specified by:
sessionIdle in interface org.apache.mina.common.IoHandler
Overrides:
sessionIdle in class org.apache.mina.common.IoHandlerAdapter
Throws:
java.lang.Exception

getSynMessageQueue

public java.util.concurrent.BlockingQueue<LLRPMessage> getSynMessageQueue()
returns queue of all incoming messages where the messages type is equal to the one specified in the IoSession parameter LLRPConnection.SYNC_MESSAGE_ANSWER. This method is required by the transact (synchronous message sending) of the LLRP connections.

Specified by:
getSynMessageQueue in class LLRPIoHandlerAdapter

getConnectionAttemptEventQueue

public java.util.concurrent.BlockingQueue<ConnectionAttemptEvent> getConnectionAttemptEventQueue()
returns queue with all incoming ConnectionAttemptEvent parameters which were embedded in READER_NOTIFICATION messages. The getConnectionAttemptEventQueue method is used to fetch any ConnectionAttemptEvent that arrived in READER_NOTIFICATION messages. These events are used by LLRPConnection objects to check whether the connection could be established successfully.

Specified by:
getConnectionAttemptEventQueue in class LLRPIoHandlerAdapter

isKeepAliveAck

public boolean isKeepAliveAck()
returns true if incoming KEEP_ALIVE messages are being acknowledged.

Specified by:
isKeepAliveAck in class LLRPIoHandlerAdapter

setKeepAliveAck

public void setKeepAliveAck(boolean keepAliveAck)
set whether incoming KEEP_ALIVE messages should be acknowledged. Default case is that KEEP_ALIVE messages are acknowledged.

Specified by:
setKeepAliveAck in class LLRPIoHandlerAdapter
Parameters:
keepAliveAck - true if KEEP_ALIVE messages are to be acknowledged

isKeepAliveForward

public boolean isKeepAliveForward()
returns true if incoming KEEP_ALIVE messages are being forwarded to the LLRPEndpoint.

Specified by:
isKeepAliveForward in class LLRPIoHandlerAdapter
Returns:
keepAliveForward true if KEEP_ALIVE messages are forwarded, false otherwise

setKeepAliveForward

public void setKeepAliveForward(boolean keepAliveForward)
set whether incoming KEEP_ALIVE messages are being forwarded to the LLRPEndpoint. Default is with forwarding off.

Specified by:
setKeepAliveForward in class LLRPIoHandlerAdapter
Parameters:
keepAliveForward - true if KEEP_ALIVE messages are to be forwarded

getConnection

public LLRPConnection getConnection()
gets connection on which handler is operating

Specified by:
getConnection in class LLRPIoHandlerAdapter
Returns:
connection

setConnection

public void setConnection(LLRPConnection connection)
sets connection on which handler is operating

Specified by:
setConnection in class LLRPIoHandlerAdapter


Copyright © 2007 ETH Zurich.