|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.beepcore.beep.core.SessionImpl
This class encapsulates the notion of a BEEP Session (a relationship between BEEP peers).
The implementor should sub-class Session
's abstract methods
for a given transport.
It's principal function is to sit on whatever network or referential
'connection' exists between the BEEP peers, read and write BEEP frames and
deliver them to or receive them from the associated Channel
.
Channel
Field Summary |
Fields inherited from interface org.beepcore.beep.core.Session |
SESSION_STATE_ABORTED, SESSION_STATE_ACTIVE, SESSION_STATE_CLOSE_PENDING, SESSION_STATE_CLOSED, SESSION_STATE_CLOSING, SESSION_STATE_GREETING_SENT, SESSION_STATE_INITIALIZED, SESSION_STATE_TUNING, SESSION_STATE_TUNING_PENDING |
Constructor Summary | |
protected |
SessionImpl(ProfileRegistry registry,
int firstChannel,
SessionCredential localCred,
SessionCredential peerCred,
SessionTuningProperties tuning,
java.lang.String serverName)
Default Session Constructor. |
Method Summary | |
void |
addChannelListener(org.beepcore.beep.core.event.ChannelListener l)
adds the listener from the list of listeners to be notified of future events. |
void |
addSessionListener(org.beepcore.beep.core.event.SessionListener l)
adds the listener from the list of listeners to be notified of future events. |
void |
close()
Closes the Session gracefully. |
protected Frame |
createFrame(byte[] header,
int headerLength)
This method is intended for use by tranport specific Sessions to create a new Frame object representing a BEEP MSG, RPY, ERR,
or NUL frames. |
protected abstract void |
disableIO()
Method disableIO |
protected abstract void |
enableIO()
Method enableIO |
protected void |
fireSessionReset(Session newSession)
|
protected int |
getChannelAvailableWindow(int channel)
Returns the channel's available window size. |
protected java.lang.String |
getChannelNumberAsString(Channel channel)
Get the channel number as a String |
SessionCredential |
getLocalCredential()
Get the local SessionCredential for this session. |
protected abstract int |
getMaxFrameSize()
Returns the maximum frame size that a channel should send for this session. |
SessionCredential |
getPeerCredential()
Get our peer's SessionCredential for this session. |
java.util.Collection |
getPeerSupportedProfiles()
Returns the profiles sent by the remote peer in the greeting. |
ProfileRegistry |
getProfileRegistry()
Returns the ProfileRegistry for Session . |
java.lang.String |
getServerName()
|
int |
getState()
Returns the state of Session . |
SessionTuningProperties |
getTuningProperties()
|
protected void |
init()
Initializes the Session . |
boolean |
isInitiator()
Indicates whehter or not this session is in the initiator role. |
protected boolean |
postFrame(Frame f)
Method postFrame |
void |
removeChannelListener(org.beepcore.beep.core.event.ChannelListener l)
Removes the listener from the list of listeners to be notified of future events. |
void |
removeSessionListener(org.beepcore.beep.core.event.SessionListener l)
Removes the listener from the list of listeners to be notified of future events. |
protected abstract Session |
reset(SessionCredential localCred,
SessionCredential peerCred,
SessionTuningProperties tuning,
ProfileRegistry registry,
java.lang.Object argument)
This method is used by a tuning profile to reset the session after the tuning is complete. |
protected abstract void |
sendFrame(Frame f)
Implement this method to send frames and on the sub-classed transport. |
protected void |
setLocalCredential(SessionCredential cred)
Method setLocalCredential |
protected void |
setPeerCredential(SessionCredential cred)
Method setPeerCredential |
protected void |
setTuningProperties(SessionTuningProperties tuning)
sets the tuning properties for this session |
Channel |
startChannel(java.util.Collection profiles,
MessageListener listener)
Sends a start channel request using the given list of profiles. |
Channel |
startChannel(java.util.Collection profiles,
RequestHandler handler)
Sends a start channel request using the given list of profiles. |
Channel |
startChannel(StartChannelProfile profile,
RequestHandler handler)
Sends a request to start a new Channel on this Session for the specified profile. |
Channel |
startChannel(java.lang.String profile)
Sends a request to start a new Channel on this Session for the specified profile. |
Channel |
startChannel(java.lang.String profile,
boolean base64Encoding,
java.lang.String data)
Sends a request to start a new Channel on this Session for the specified profile. |
Channel |
startChannel(java.lang.String profile,
boolean base64Encoding,
java.lang.String data,
MessageListener listener)
Sends a request to start a new Channel on this Session for the specified profile. |
Channel |
startChannel(java.lang.String profile,
MessageListener listener)
Sends a request to start a new Channel on this Session for the specified profile. |
Channel |
startChannel(java.lang.String profile,
RequestHandler handler)
Sends a request to start a new Channel on this Session for the specified profile. |
void |
terminate(java.lang.String reason)
This method is used to terminate the session when there is an non-recoverable error in the BEEP protocol (framing error, etc.). |
java.lang.String |
toString()
|
protected void |
tuningInit()
A reentrant version of init() that doesn't block the first I/O thread waiting on a greeting when it should die and go away. |
protected abstract boolean |
updateMyReceiveBufferSize(Channel channel,
long currentSeq,
int currentAvail)
This method is designed to allow for flow control across the multiplexed connection we have. |
protected void |
updatePeerReceiveBufferSize(int channelNum,
long lastSeq,
int size)
Method updatePeerReceiveBufferSize |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected SessionImpl(ProfileRegistry registry, int firstChannel, SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, java.lang.String serverName) throws BEEPException
registry
- The Profile Registry summarizing the profiles this
Session will supportfirstChannel
- used internally in the API, an indication of the
ordinality of the channels this peer can start, odd, or even.localCred
- peerCred
- tuning
- serverName
- Method Detail |
protected void init() throws BEEPException
Session
. Initializes Channel Zero and its
listener. Sends a greeting and waits for corresponding greeting.
BEEPException
protected void tuningInit() throws BEEPException
BEEPException
public void addChannelListener(org.beepcore.beep.core.event.ChannelListener l)
addChannelListener
in interface Session
removeChannelListener(org.beepcore.beep.core.event.ChannelListener)
public void addSessionListener(org.beepcore.beep.core.event.SessionListener l)
addSessionListener
in interface Session
removeSessionListener(org.beepcore.beep.core.event.SessionListener)
public void close() throws BEEPException
Session
gracefully. The profiles for
the open channels on the session may veto the close request.
close
in interface Session
BEEPException
public SessionCredential getLocalCredential()
SessionCredential
for this session.
getLocalCredential
in interface Session
null
if this session has not
been authenticatedpublic SessionCredential getPeerCredential()
SessionCredential
for this session.
getPeerCredential
in interface Session
null
if this session has not
been authenticatedpublic java.util.Collection getPeerSupportedProfiles()
getPeerSupportedProfiles
in interface Session
public ProfileRegistry getProfileRegistry()
ProfileRegistry
for Session
.
getProfileRegistry
in interface Session
ProfileRegistry
.ProfileRegistry
public int getState()
Session
.
getState
in interface Session
public boolean isInitiator()
isInitiator
in interface Session
public void removeChannelListener(org.beepcore.beep.core.event.ChannelListener l)
removeChannelListener
in interface Session
addChannelListener(org.beepcore.beep.core.event.ChannelListener)
public void removeSessionListener(org.beepcore.beep.core.event.SessionListener l)
removeSessionListener
in interface Session
addSessionListener(org.beepcore.beep.core.event.SessionListener)
public Channel startChannel(java.lang.String profile) throws BEEPException, BEEPError
Session
startChannel
in interface Session
profile
- The URI of the profile for the new Channel.
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).public Channel startChannel(java.lang.String profile, MessageListener listener) throws BEEPException, BEEPError
Session
startChannel
allows a
MessageListener
to be specified to be registered once the
Channel is started. This is useful for profiles that are peer-to-peer in
nature.
startChannel
in interface Session
profile
- The URI of the profile for the new Channel.listener
- A MessageListener
to receive MSG messages
sent by the remote peer of this Session.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.MessageListener
public Channel startChannel(java.lang.String profile, RequestHandler handler) throws BEEPException, BEEPError
Session
startChannel
allows a
RequestHandler
to be specified to be registered once the
Channel is started. This is useful for profiles that are peer-to-peer in
nature.
startChannel
in interface Session
profile
- The URI of the profile for the new Channel.handler
- A RequestHandler
to receive MSG messages
sent by the remote peer of this Session.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.public Channel startChannel(java.lang.String profile, boolean base64Encoding, java.lang.String data) throws BEEPException, BEEPError
Session
startChannel
allows a
MessageListener
to be specified to be registered once the
Channel is started. This is useful for profiles that are peer-to-peer in
nature.
startChannel
in interface Session
profile
- The URI of the profile for the new Channel.base64Encoding
- Indicates whether or not data
is
base64 encoded. data
must be base64
encoded if it is not valid XML CDATA.data
- An initial request to be sent piggyback'd along with the
request to start the Channel. This request can be at most
4K in size.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.MessageListener
public Channel startChannel(java.lang.String profile, boolean base64Encoding, java.lang.String data, MessageListener listener) throws BEEPException, BEEPError
Session
startChannel
allows a
MessageListener
to be specified to be registered once the
Channel is started. This is useful for profiles that are peer-to-peer in
nature.
startChannel
in interface Session
profile
- The URI of the profile for the new Channel.base64Encoding
- Indicates whether or not data
is
base64 encoded. data
must be base64
encoded if it is not valid XML CDATA.data
- An initial request to be sent piggyback'd along with the
request to start the Channel. This request can be at most
4K in size.listener
- A MessageListener
to receive MSG messages
sent by the remote peer of this Session.
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).MessageListener
public Channel startChannel(StartChannelProfile profile, RequestHandler handler) throws BEEPException, BEEPError
Session
startChannel
allows a
RequestHandler
to be specified to be registered once the
Channel is started.
startChannel
in interface Session
profile
- handler
- A RequestHandler
to receive MSG messages
sent by the remote peer of this Session.
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).public Channel startChannel(java.util.Collection profiles, MessageListener listener) throws BEEPException, BEEPError
Session
startChannel
in interface Session
profiles
- A collection of StartChannelProfile
(s).listener
- A MessageListener
to receive MSG messages
sent by the remote peer of this Session.
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).StartChannelProfile
,
MessageListener
public Channel startChannel(java.util.Collection profiles, RequestHandler handler) throws BEEPException, BEEPError
Session
startChannel
in interface Session
profiles
- A collection of StartChannelProfile
(s).handler
- A RequestHandler
to receive MSG messages
sent by the remote peer of this Session.
BEEPException
- Thrown for errors other than those defined by
the BEEP protocol (e.g. the Session is not in a
state to create a new Channel).
BEEPError
- Thrown if the remote peer is unable or refuses to
start a new Channel for the requested profile.StartChannelProfile
,
RequestHandler
public void terminate(java.lang.String reason)
terminate
in interface Session
reason
- public java.lang.String toString()
protected Frame createFrame(byte[] header, int headerLength) throws BEEPException
Frame
object representing a BEEP MSG, RPY, ERR,
or NUL frames.
Frame
for the specified values
BEEPException
protected abstract void disableIO()
protected abstract void enableIO()
protected int getChannelAvailableWindow(int channel) throws BEEPException
BEEPException
protected java.lang.String getChannelNumberAsString(Channel channel)
channel
- protected abstract int getMaxFrameSize() throws BEEPException
BEEPException
protected boolean postFrame(Frame f) throws BEEPException
f
-
BEEPException
protected abstract Session reset(SessionCredential localCred, SessionCredential peerCred, SessionTuningProperties tuning, ProfileRegistry registry, java.lang.Object argument) throws BEEPException
Session
with the tuning complete.
BEEPException
protected abstract void sendFrame(Frame f) throws BEEPException
f
- BEEP frame to send.
BEEPException
protected void setLocalCredential(SessionCredential cred)
cred
- protected void setPeerCredential(SessionCredential cred)
cred
- protected void setTuningProperties(SessionTuningProperties tuning)
tuning
- SessionTuningProperties
public SessionTuningProperties getTuningProperties()
getTuningProperties
in interface Session
public java.lang.String getServerName()
protected abstract boolean updateMyReceiveBufferSize(Channel channel, long currentSeq, int currentAvail) throws BEEPException
The idea is to throttle data being sent over this session to be manageable per Channel, so that a given Channel doesn't take up all the bandwidth.
This method restricts the bufferSize, per the beep spec, to be at most two-thirds of the socket's receiveBufferSize. If a size is requested beyond that, an exception is thrown.
channel
- currentSeq
- currentAvail
-
throws
- BEEPException if a specified buffer size is larger
than what's available on the Socket.
BEEPException
protected void updatePeerReceiveBufferSize(int channelNum, long lastSeq, int size) throws BEEPException
channelNum
- lastSeq
- size
-
BEEPException
protected void fireSessionReset(Session newSession)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |