|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.resoa.stack.protocol.Session
public class Session
Session wraps a connection handle and is created during connection to or from remote. Use this object for message sending and disconnect requests to a remote end point. Sessions are generated by the stack, do not try to instance them by yourself!
If you intend to develop a server based solution, using Resoa stack, you should
cache Session instances, when they have been initialized in order to use them for
message sending.
New Sessions and state changes to a session are broadcasted by the stack, using the
Callback Callbacks.SessionState.
Incoming message from remote are broadcasted to the
StackChannelProcessor.onMessage(Object, Message).
You should implement a little message dispatcher within your StackChannel implementation to process
all incoming messages. The dispatcher might create Java objects out of the binary message content
(i.E. using jaxb for XML or JSON) and pass the newly instanced Java objects to the
underlying session/application.
| Constructor Summary | |
|---|---|
|
Session(Stack stack,
java.security.KeyPair privateRSA)
FOR INTERNAL USE ONLY. |
|
Session(Stack stack,
java.security.KeyPair privateRSA,
org.resoa.stack.config.StackProfile connectTo)
Session constructor FOR INTERNAL USE ONLY. |
protected |
Session(java.lang.String sessionID)
Used for debugging only |
| Method Summary | |
|---|---|
boolean |
checkProfile(org.resoa.stack.config.StackProfile remoteProfile)
FOR INTERNAL USE ONLY. |
void |
closeSocket()
Closes the socket |
void |
disconnect()
performs a regular disconnect |
void |
executeProtocolService(java.lang.String serviceID)
FOR INTERNAL USE ONLY. |
org.resoa.stack.config.StackConfig |
getConfig()
The underlying stack configuration |
int |
getFragmentationSize()
Returns the size in bytes, used for internal message fragmentation |
java.util.concurrent.locks.ReentrantLock |
getKillLock()
|
org.resoa.stack.config.StackProfile |
getLocalProfile()
Returns the local profile of the connection |
java.io.OutputStream |
getOutputStream()
FOR INTERNAL USE ONLY. |
org.resoa.stack.config.StackProfile |
getRemoteProfile()
Returns the remoteProfile of the connection |
java.lang.String |
getRsaAESKeyString()
FOR INTERNAL USE ONLY. |
SecurityParameter |
getSecurity()
FOR INTERNAL USE ONLY. |
java.lang.String |
getSessionID()
Returns the sessionID. |
java.nio.channels.SocketChannel |
getSocketChannel()
FOR INTERNAL USE ONLY. |
java.util.concurrent.locks.ReentrantLock |
getSocketLock()
|
TCPReader |
getTcpReader()
FOR INTERNAL USE ONLY. |
long |
getUpTime()
The uptime of the session |
boolean |
isBigEndian()
indicates the endian mode, default is true (BigEndian) |
boolean |
isDisconnecting()
True, if the session is disconnecting |
boolean |
isHandshakeTimeout()
true, if the session has a TCP socket connection, but handshake has run into timeout |
boolean |
isInitialized()
true, if session handshake has been completed and the message is ready for sending data. |
boolean |
isKilled()
true, if the session has been disconnected and will not reconnect again. |
boolean |
isNewInstanced()
true, if the session is in state instanced (0) |
boolean |
isReconnectable()
Returns true, if the session is reconnectable In case of a remote disconnect (not caused by exception), it is set to false. |
boolean |
isReconnecting()
true, if the session has been disconnected by remote or exception. |
boolean |
isServer()
indicates, if the stack runs in server mode |
boolean |
isTCPConnected()
true, if the session has a tcp socket (1) |
org.resoa.grid.Transaction |
newTransaction(org.resoa.grid.Transaction t)
send a message within a transactional context, use this if you need synchronized communication with the remote end point. |
void |
notifyTransaction(org.resoa.grid.Message msg)
FOR INTERNAL USE ONLY. |
void |
reconnect()
FOR INTERNAL USE ONLY. |
void |
registerFragmentID(java.lang.String fid)
FOR INTERNAL USE ONLY. |
void |
removeFragmentID(java.lang.String fid)
FOR INTERNAL USE ONLY. |
void |
sendMessage(org.resoa.grid.Message msg)
Send a new message |
void |
setBigEndian(boolean isBigEndian)
FOR INTERNAL USE ONLY. |
void |
setDisconnecting()
mark the session as disconnect request pending |
void |
setFragmentationSize(int fragmentationSize)
FOR INTERNAL USE ONLY. |
void |
setInitialized()
FOR INTERNAL USE ONLY. |
void |
setKilled(boolean notify)
FOR INTERNAL USE ONLY. |
void |
setReconnectable(boolean reconnectable)
Set the session reconnect state |
void |
setRemoteProfile(org.resoa.stack.config.StackProfile remoteProfile)
FOR INTERNAL USE ONLY. |
void |
setRsaAESKeyString(java.lang.String rsaAESKeyString)
FOR INTERNAL USE ONLY. |
void |
setSocket(java.net.Socket sessionSocket)
FOR INTERNAL USE ONLY. |
void |
startHandShake()
FOR INTERNAL USE ONLY. |
boolean |
waitForInitialized()
FOR INTERNAL USE ONLY. |
void |
writeSignature(org.resoa.grid.Message message)
FOR INTERNAL USE ONLY. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Session(java.lang.String sessionID)
public Session(Stack stack,
java.security.KeyPair privateRSA)
throws org.resoa.exception.ProtocolException
FOR INTERNAL USE ONLY.
Constructor for incoming connections
stack - the underlying stackprivateRSA - the private RSA
org.resoa.exception.ProtocolException
public Session(Stack stack,
java.security.KeyPair privateRSA,
org.resoa.stack.config.StackProfile connectTo)
throws org.resoa.exception.ProtocolException
FOR INTERNAL USE ONLY.
stack - the stackprivateRSA - the RSY keypairconnectTo - the remote profile
org.resoa.exception.ProtocolException| Method Detail |
|---|
public java.lang.String getSessionID()
getSessionID in interface org.resoa.grid.GridSessionpublic boolean isNewInstanced()
public boolean isTCPConnected()
public boolean isHandshakeTimeout()
public boolean isInitialized()
isInitialized in interface org.resoa.grid.GridSessionpublic boolean isDisconnecting()
isDisconnecting in interface org.resoa.grid.GridSessionpublic void setDisconnecting()
public boolean isReconnecting()
isReconnecting in interface org.resoa.grid.GridSessionpublic boolean isReconnectable()
isReconnectable in interface org.resoa.grid.GridSessionpublic void setReconnectable(boolean reconnectable)
reconnectable - public boolean isKilled()
isKilled in interface org.resoa.grid.GridSessionpublic void setInitialized()
FOR INTERNAL USE ONLY.
Sets the session status to initialized. Used by ProtocolSerivces only!
public void setKilled(boolean notify)
FOR INTERNAL USE ONLY.
Sets the session status to initialized. Used by ProtocolSerivces only!
public long getUpTime()
getUpTime in interface org.resoa.grid.GridSessionpublic boolean waitForInitialized()
FOR INTERNAL USE ONLY.
Waits timeout and returns true, is session is initialized
public org.resoa.grid.Transaction newTransaction(org.resoa.grid.Transaction t)
throws org.resoa.exception.ProtocolException,
org.resoa.exception.SystemOverloadException
send a message within a transactional context, use this if you need synchronized communication with the remote end point.
Transactions might be generated by org.resoa.grid.Transaction#newTransaction, which will wrap an stack message for transactional processing. This procedure will try to send the message to the backend and wait for a reply or run into a timeout. Timeouts have a default value, changed by org.resoa.grid.Transaction#TRANSACTION_TIMEOUT_SEC_DEFAULT. Individual timeouts in milliseconds might be set by Transaction#setTimeOut(long).If the request was answered within the wait time, you can find the content in the returned transaction object. In case of timeout the returned transaction object will still hold the request message, and the state is set to TransactionState#Timeout. You should be prepared, that the transactional reply might arrive after the wait time! The stack will notify you about this through the channel listeners and by setting the state to TransactionState#Delayed.
newTransaction in interface org.resoa.grid.GridSessionorg.resoa.exception.ProtocolException
org.resoa.exception.SystemOverloadExceptionpublic void notifyTransaction(org.resoa.grid.Message msg)
FOR INTERNAL USE ONLY.
notifies transaction on a new incoming transaction reply
msg - the Messagepublic boolean isServer()
isServer in interface org.resoa.grid.GridSessionpublic boolean isBigEndian()
isBigEndian in interface org.resoa.grid.GridSessionpublic void setBigEndian(boolean isBigEndian)
FOR INTERNAL USE ONLY.
isBigEndian - The isBigEndian to set.public int getFragmentationSize()
public void setFragmentationSize(int fragmentationSize)
FOR INTERNAL USE ONLY.
Changes the fragmentation size. This should only be done by protocol services. You can parameterize this value in the stack configuration.
fragmentationSize - The fragmentationSize to set.public void registerFragmentID(java.lang.String fid)
FOR INTERNAL USE ONLY.
Register a new pending fragmentID
fid - public void removeFragmentID(java.lang.String fid)
FOR INTERNAL USE ONLY.
Remove a fragmentID from pending cache
fid - public org.resoa.stack.config.StackProfile getLocalProfile()
public org.resoa.stack.config.StackProfile getRemoteProfile()
getRemoteProfile in interface org.resoa.grid.GridSessionpublic void setRemoteProfile(org.resoa.stack.config.StackProfile remoteProfile)
FOR INTERNAL USE ONLY.
remoteProfile - The remoteProfile to set.public SecurityParameter getSecurity()
FOR INTERNAL USE ONLY.
public java.lang.String getRsaAESKeyString()
FOR INTERNAL USE ONLY.
public void setRsaAESKeyString(java.lang.String rsaAESKeyString)
FOR INTERNAL USE ONLY.
rsaAESKeyString - Festzulegender rsaAESKeyStringpublic org.resoa.stack.config.StackConfig getConfig()
public java.util.concurrent.locks.ReentrantLock getSocketLock()
public java.util.concurrent.locks.ReentrantLock getKillLock()
public void closeSocket()
public java.io.OutputStream getOutputStream()
FOR INTERNAL USE ONLY. Ensure, that the session is synchronized, when invoking
Returns a BufferedOutputStream, wrapping the Socket out stream
public java.nio.channels.SocketChannel getSocketChannel()
FOR INTERNAL USE ONLY. Ensure, that the session is synchronized, when invoking
Returns a the SocketChannel instance
public void setSocket(java.net.Socket sessionSocket)
throws java.io.IOException
FOR INTERNAL USE ONLY.
sessionSocket - set the session socket
java.io.IOExceptionpublic TCPReader getTcpReader()
FOR INTERNAL USE ONLY.
public boolean checkProfile(org.resoa.stack.config.StackProfile remoteProfile)
FOR INTERNAL USE ONLY.
checks for acceptance of a remote profile
remoteProfile - public void disconnect()
disconnect in interface org.resoa.grid.GridSessionpublic void reconnect()
FOR INTERNAL USE ONLY.
Reconnects session to a Resoa accesspoint
public void sendMessage(org.resoa.grid.Message msg)
throws org.resoa.exception.ProtocolException,
org.resoa.exception.SystemOverloadException,
java.io.IOException
sendMessage in interface org.resoa.grid.GridSessionmsg - the message to send. You can create a message i.e. by
Message#newDownMessage(Session, byte[], Object, Priority, int).
org.resoa.exception.ProtocolException
org.resoa.exception.SystemOverloadException
java.io.IOException
public void executeProtocolService(java.lang.String serviceID)
throws org.resoa.exception.ProtocolException
FOR INTERNAL USE ONLY.
Execute a protocol Service
serviceID - the serviceID
org.resoa.exception.ProtocolException
public void startHandShake()
throws org.resoa.exception.ProtocolException
FOR INTERNAL USE ONLY.
Starts the session handshaking after a new tcp connection
org.resoa.exception.ProtocolException
public void writeSignature(org.resoa.grid.Message message)
throws org.resoa.exception.ProtocolException
FOR INTERNAL USE ONLY.
Creates a Resoa StackSignature
message - the message
org.resoa.exception.ProtocolException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||