org.apache.qpid.server.protocol
Class AMQMinaProtocolSession

java.lang.Object
  extended by org.apache.qpid.server.protocol.AMQMinaProtocolSession
All Implemented Interfaces:
org.apache.qpid.framing.ProtocolVersionList, Managable, AMQProtocolSession

public class AMQMinaProtocolSession
extends java.lang.Object
implements AMQProtocolSession, org.apache.qpid.framing.ProtocolVersionList, Managable


Field Summary
 
Fields inherited from interface org.apache.qpid.framing.ProtocolVersionList
PROTOCOL_MAJOR, PROTOCOL_MINOR, pv
 
Constructor Summary
AMQMinaProtocolSession(org.apache.mina.common.IoSession session, QueueRegistry queueRegistry, ExchangeRegistry exchangeRegistry, org.apache.qpid.codec.AMQCodecFactory codecFactory)
           
AMQMinaProtocolSession(org.apache.mina.common.IoSession session, QueueRegistry queueRegistry, ExchangeRegistry exchangeRegistry, org.apache.qpid.codec.AMQCodecFactory codecFactory, AMQStateManager stateManager)
           
 
Method Summary
 void addChannel(AMQChannel channel)
          Associate a channel with this session.
 boolean amqpVersionEquals(byte major, byte minor)
           
 void closeChannel(int channelId)
          Close a specific channel.
 void closeSession()
          This must be called when the session is _closed in order to free up any resources managed by the session.
 void dataBlockReceived(org.apache.qpid.framing.AMQDataBlock message)
          Called when a protocol data block is received
 java.lang.String dump()
           
 byte getAmqpMajor()
          Convenience methods for managing AMQP version.
 byte getAmqpMinor()
           
static AMQProtocolSession getAMQProtocolSession(org.apache.mina.common.IoSession minaProtocolSession)
           
 AMQChannel getChannel(int channelId)
          Get the channel for this session associated with the specified id.
 java.lang.String getContextKey()
          Get the context key associated with this session.
 java.lang.Object getKey()
           
 java.lang.String getLocalFQDN()
          Get the fully qualified domain name of the local address to which this session is bound.
 ManagedObject getManagedObject()
           
 javax.security.sasl.SaslServer getSaslServer()
           
 void initHeartbeats(int delay)
          Initialise heartbeats on the session.
 void removeChannel(int channelId)
          In our current implementation this is used by the clustering code.
 void setContextKey(java.lang.String contextKey)
          Set the context key associated with this session.
 void setSaslServer(javax.security.sasl.SaslServer saslServer)
          Set the sasl server that is to perform authentication for this session.
 java.lang.String toString()
           
 void writeFrame(org.apache.qpid.framing.AMQDataBlock frame)
          Convenience method that writes a frame to the protocol session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AMQMinaProtocolSession

public AMQMinaProtocolSession(org.apache.mina.common.IoSession session,
                              QueueRegistry queueRegistry,
                              ExchangeRegistry exchangeRegistry,
                              org.apache.qpid.codec.AMQCodecFactory codecFactory)
                       throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

AMQMinaProtocolSession

public AMQMinaProtocolSession(org.apache.mina.common.IoSession session,
                              QueueRegistry queueRegistry,
                              ExchangeRegistry exchangeRegistry,
                              org.apache.qpid.codec.AMQCodecFactory codecFactory,
                              AMQStateManager stateManager)
                       throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException
Method Detail

getManagedObject

public ManagedObject getManagedObject()
Specified by:
getManagedObject in interface Managable

getAMQProtocolSession

public static AMQProtocolSession getAMQProtocolSession(org.apache.mina.common.IoSession minaProtocolSession)

dataBlockReceived

public void dataBlockReceived(org.apache.qpid.framing.AMQDataBlock message)
                       throws java.lang.Exception
Description copied from interface: AMQProtocolSession
Called when a protocol data block is received

Specified by:
dataBlockReceived in interface AMQProtocolSession
Parameters:
message - the data block that has been received
Throws:
java.lang.Exception - if processing the datablock fails

writeFrame

public void writeFrame(org.apache.qpid.framing.AMQDataBlock frame)
Convenience method that writes a frame to the protocol session. Equivalent to calling getProtocolSession().write().

Specified by:
writeFrame in interface AMQProtocolSession
Parameters:
frame - the frame to write

getContextKey

public java.lang.String getContextKey()
Description copied from interface: AMQProtocolSession
Get the context key associated with this session. Context key is described in the AMQ protocol specification (RFC 6).

Specified by:
getContextKey in interface AMQProtocolSession
Returns:
the context key

setContextKey

public void setContextKey(java.lang.String contextKey)
Description copied from interface: AMQProtocolSession
Set the context key associated with this session. Context key is described in the AMQ protocol specification (RFC 6).

Specified by:
setContextKey in interface AMQProtocolSession
Parameters:
contextKey - the context key

getChannel

public AMQChannel getChannel(int channelId)
                      throws org.apache.qpid.AMQException
Description copied from interface: AMQProtocolSession
Get the channel for this session associated with the specified id. A channel id is unique per connection (i.e. per session).

Specified by:
getChannel in interface AMQProtocolSession
Parameters:
channelId - the channel id which must be valid
Returns:
null if no channel exists, the channel otherwise
Throws:
org.apache.qpid.AMQException

addChannel

public void addChannel(AMQChannel channel)
Description copied from interface: AMQProtocolSession
Associate a channel with this session.

Specified by:
addChannel in interface AMQProtocolSession
Parameters:
channel - the channel to associate with this session. It is an error to associate the same channel with more than one session but this is not validated.

closeChannel

public void closeChannel(int channelId)
                  throws org.apache.qpid.AMQException
Close a specific channel. This will remove any resources used by the channel, including:

Specified by:
closeChannel in interface AMQProtocolSession
Parameters:
channelId - id of the channel to close
Throws:
org.apache.qpid.AMQException - if an error occurs closing the channel
java.lang.IllegalArgumentException - if the channel id is not valid

removeChannel

public void removeChannel(int channelId)
In our current implementation this is used by the clustering code.

Specified by:
removeChannel in interface AMQProtocolSession
Parameters:
channelId -

initHeartbeats

public void initHeartbeats(int delay)
Initialise heartbeats on the session.

Specified by:
initHeartbeats in interface AMQProtocolSession
Parameters:
delay - delay in seconds (not ms)

closeSession

public void closeSession()
                  throws org.apache.qpid.AMQException
This must be called when the session is _closed in order to free up any resources managed by the session.

Specified by:
closeSession in interface AMQProtocolSession
Throws:
org.apache.qpid.AMQException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

dump

public java.lang.String dump()

getKey

public java.lang.Object getKey()
Specified by:
getKey in interface AMQProtocolSession
Returns:
an object that can be used to identity

getLocalFQDN

public java.lang.String getLocalFQDN()
Get the fully qualified domain name of the local address to which this session is bound. Since some servers may be bound to multiple addresses this could vary depending on the acceptor this session was created from.

Specified by:
getLocalFQDN in interface AMQProtocolSession
Returns:
a String FQDN

getSaslServer

public javax.security.sasl.SaslServer getSaslServer()
Specified by:
getSaslServer in interface AMQProtocolSession
Returns:
the sasl server that can perform authentication for this session.

setSaslServer

public void setSaslServer(javax.security.sasl.SaslServer saslServer)
Description copied from interface: AMQProtocolSession
Set the sasl server that is to perform authentication for this session.

Specified by:
setSaslServer in interface AMQProtocolSession

getAmqpMajor

public byte getAmqpMajor()
Convenience methods for managing AMQP version. NOTE: Both major and minor will be set to 0 prior to protocol initiation.


getAmqpMinor

public byte getAmqpMinor()

amqpVersionEquals

public boolean amqpVersionEquals(byte major,
                                 byte minor)