|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.gjsa.server.ServerThreadBase
Logical counterpart of a client which is connected to the server. A ServerThreadBase is assigned to exactly one client and stays alive the whole time the client communicates with the server. It holds the basic data about the client and channelizes the communication between client and server.
The ServerThreadBase does not handle actual queries. Those are passed to a ServerThreadSession which does the handling and gives further logical separation in query handling.
A ServerThreadBase is always created by a SocketLayer instance. GJSA supports two types of connections: connectionbound (which means that the socket is open for the whole livetime of the connection between client and server) or connectionless (which means that a network connection is opened each time a query-response-pair is exchanged). For connectionbound connections, SocketLayer creates directly a ServerThreadBase and links that one into the Thread currently executed. For connectionless connections, the ServerThreadBase is created and stored into a Map where it can be found easily for further requests. So, in the connectionless case, a ServerThreadBase is run for each query in a different Thread while in the connectionbound case, it always runs in the same thread.
ServerThreadHandler
,
ServerThreadInitiator
,
GJSAServer
,
SessionConnector
Nested Class Summary | |
private static class |
ServerThreadBase.BurstLogDataStorage
|
Field Summary | |
private boolean |
authenticated
Marker that counterside has authenticated in whatever way. |
private long |
authenticatedtimeout
Idle timeouts |
protected Logger |
clie
target for logging messages |
protected boolean |
clientaddressisreportable
Flag whether the client is allowed to report a different client IP address. |
protected java.lang.String |
clienthostip
The real client's IP address |
protected java.lang.String |
clienthostname
The (DNS-)name of the real client host |
protected java.net.InetAddress |
clientInetAddr
The real client's InetAddress object |
protected java.util.Map |
cmdlogdata
Complete map of data for this thread base |
private java.lang.String |
connectionid
Complete id for logging output |
private boolean |
connectionless
Indicator whether this is a connectionless connection or not |
protected static int |
connnr
connection number. |
private ServerThreadSession |
currentsession
The session answering the current query |
protected java.util.Map |
data
Complete map of data for this thread base |
int |
encryptionrule
Description of the Field |
protected boolean |
encryptionstatecorrect
Description of the Field |
protected static EncryptionRulesSymbols |
ers
Description of the Field |
private ServerThreadSession |
initialsession
The initial ServerThreadSession |
private boolean |
isclosed
Flag that closing the ServerThreadBase has been finished. |
private boolean |
isclosing
Flag whether this ServerThreadBase is about to be closed by a QUIT command |
private int |
lastencodingmode
Encoding mode of the connection. |
private boolean |
lastencryptionmode
Encryption mode of the connection. |
private long |
lastinteraction
Time of last interaction from the client |
private boolean |
locallycontrolled
Flag whether the thread base is controlled by local commands |
private boolean |
locallycontrolledsettable
Flag whether the locallycontrolled flag may be set. |
protected Logger |
mess
target for logging messages |
boolean |
mustencrypt
Description of the Field |
boolean |
mustnotencrypt
Description of the Field |
protected int |
myconnnr
Own connection number. |
GJSAServer |
myserv
pointer to the Server object that has launched this ServerThreadBase |
private ThreadInterface |
readerinterface
Interface for reading from the SocketLayer. |
protected java.lang.String |
reportedclienthostip
The reported client's IP address. |
protected java.lang.String |
reportedclienthostname
The (DNS-)name of the client host which is reported as client by the real client. |
protected java.net.InetAddress |
reportedclientinetaddr
The reported client's address as InetAddress object |
protected java.util.Map |
senddata
Complete map of data for this thread base |
private int |
sequence
Sequence counter for connectionless connections |
private int |
sessionidcounter
Session counter to create session ids. |
private java.util.Map |
sessions
Map to all sessions |
private long |
unauthenticatedtimeout
Idle timeouts |
private ThreadInterface |
writerinterface
Interface for writing to the SocketLayer. |
Constructor Summary | |
ServerThreadBase(GJSAServer gx,
int encodingmode,
boolean encryptionmode,
java.net.InetAddress rx,
boolean clx,
long uat,
long ato)
Constructor for all cases. |
Method Summary | |
boolean |
clientMatchesPattern(java.lang.String pattern)
Description of the Method |
void |
close()
Close the handler. |
void |
closeSession()
|
ServerReply |
continueSyncBurst()
|
private void |
doClose()
Real closing method Works regardless of connectionless or connectionbound connection. |
void |
finishNewState(CommandExecutor commexec)
|
void |
finishNewState(java.util.List commexecs)
|
void |
finishNewState(java.util.List commexecs,
java.util.List allcommexecs)
|
void |
freeFloatingReply(int seq,
ServerReply sr)
writes a free floating reply. |
void |
freeFloatingReply(int seq,
ServerReply sr,
InformableSender isx)
writes a free floating reply. |
boolean |
getBurstAll()
|
boolean |
getBurstNext()
|
int |
getBurstSize()
|
java.lang.String |
getClientHostDescription()
Returns a complete declarative description of the client's name and IP. |
java.lang.String |
getClientHostIP()
Returns the IP address of the connected client. |
java.lang.String |
getClientHostName()
Returns the symbolic name of the real connected client. |
java.net.InetAddress |
getClientInetAddr()
Returns the InetAddress object for the currently connected client This method will also work for connectionless connect. |
java.lang.String |
getConnectionID()
Returns the connection ID which contains at least the connection number. |
int |
getConnectionNr()
Returns the connection number of this connection. |
java.util.Map |
getData()
Return complete data set for this connection |
GJSAServer |
getGJSAServer()
Gets the gJSAServer attribute of the ServerThreadBase object |
int |
getLastChildSessionID()
|
static int |
getMaxConnectionNr()
Returns the maximum assigned connection number. |
java.lang.Object |
getProperty(java.lang.Object key)
|
boolean |
getRemovementLogging()
Gets the removementLogging attribute of the ServerThreadBase object |
java.lang.String |
getReportedClientHostDescription()
Returns a complete declarative description of the reported client's name and IP. |
java.lang.String |
getReportedClientHostIP()
Returns the IP address of the connected client. |
java.lang.String |
getReportedClientHostName()
Returns the symbolic name of the real connected client. |
java.net.InetAddress |
getReportedClientInetAddr()
Returns the InetAddress object for the currently connected client This method will also work for connectionless connect. |
int |
getSequence()
Returns current sequence counter |
int |
getUniqueSessionID()
Returns a unique session id for new sessions. |
void |
handleLogObject(Logger src,
int nr,
java.lang.Object o)
Description of the Method |
void |
handleLogObject(Logger src,
java.lang.Object o)
interface method for LoggingReceiver. |
void |
incSequence()
Increases the sequence counter. |
void |
incSequenceAndDisableLocallyControlled()
Increases the sequence counter and disables the locally controlled-flag. |
void |
informConnectionListeners()
Informs data listeners on changes if they have occured via putData() before. |
ServerReply |
initBurstableReply(BurstMaker bm)
|
protected void |
initDataMap()
Initializes the data map and sends through CLIE logger |
private void |
initEncryptionFlags(java.lang.Object o)
Description of the Method |
private void |
initNameAndIP(java.net.InetAddress ix)
Primary initialisation of client IP address. |
private void |
initSessions()
initializes the session stack with initial executors |
boolean |
isClosing()
returns if connection has received QUIT command and can therefore be removed. |
boolean |
isConnectionless()
Returns whether this connection is connectionless |
boolean |
isEncryptionStateCorrect()
Returns whether the encryption state is correct for opening a session or a new state in an existing session. |
boolean |
isLocallyControlled()
Returns whether the ServerThreadBase is currently fed with server-local commands. |
boolean |
isTimedOut(long currenttime)
Returns whether this connection is timed out and should be closed. |
void |
leaveState()
|
void |
logMessage(int sessionid,
java.lang.Object message)
Logs a message of any session to the standard message logger. |
void |
loopSynchronous(SocketLayer sly,
ServerEnvelope firstquery)
|
boolean |
mayBeClosed()
returns whether the thread base may be closed or not. |
void |
newState(int newstate,
CommandExecutor commexec)
|
void |
newState(int newstate,
java.util.List commexecs)
|
void |
newState(int newstate,
java.util.List commexecs,
java.util.List allcommexecs)
|
int |
openSession()
|
void |
putData(java.lang.String key,
java.lang.Object value)
Put one data element into the map, sets flag that listeners should be informed. |
java.lang.Object |
putProperty(java.lang.Object key,
java.lang.Object value)
|
void |
registerSession(ServerThreadSession sts)
Register a session for calling |
void |
releaseSession(ServerThreadSession sts)
Release a session of the register. |
java.lang.Object |
removeProperty(java.lang.Object key)
|
ServerEnvelope |
reply(ServerEnvelope se)
"Main" query handler. |
ServerEnvelope |
reply(ServerEnvelope se,
boolean encrypted,
int currencodingmode)
Handle a ServerEnvelope, readjust the "encryption" setting and report the current connection encoding |
ServerReply |
replyOneQuery(ServerRequest sr)
Convenience method to handle a single query |
void |
retractNewState()
|
void |
setBurstAll(boolean bx)
|
void |
setBurstNext(boolean bx)
|
void |
setBurstSize(int s)
|
void |
setClientAddress(java.lang.String ipaddress)
Sets the client's address of the connection to a new value. |
private void |
setCurrentIdleStart()
|
void |
setLocallyControlled(boolean b)
Sets whether the ServerThreadBase is currently fed with server-local commands. |
void |
setTimeouts(long nto,
long ato)
Set the timeouts for the connection object |
void |
startClosing()
Start closing the stuff. |
void |
startNewState(int newstate)
|
java.lang.String |
toString()
Description of the Method |
void |
turnIntoAuthenticated()
Turns this connection into an authenticated one. |
void |
updateInteractionTimestamp()
Sets timestamp of last interaction to current time |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static int connnr
protected int myconnnr
protected static EncryptionRulesSymbols ers
public GJSAServer myserv
protected java.lang.String clienthostname
protected java.lang.String clienthostip
protected java.net.InetAddress clientInetAddr
protected boolean clientaddressisreportable
protected java.lang.String reportedclienthostname
protected java.lang.String reportedclienthostip
protected java.net.InetAddress reportedclientinetaddr
private ServerThreadSession initialsession
protected Logger mess
protected Logger clie
public int encryptionrule
public boolean mustencrypt
public boolean mustnotencrypt
protected boolean encryptionstatecorrect
protected java.util.Map data
protected java.util.Map senddata
protected java.util.Map cmdlogdata
private int sessionidcounter
private boolean isclosing
private boolean isclosed
private ThreadInterface writerinterface
private ThreadInterface readerinterface
private boolean connectionless
private java.lang.String connectionid
private java.util.Map sessions
private ServerThreadSession currentsession
private boolean authenticated
private long unauthenticatedtimeout
private long authenticatedtimeout
private long lastinteraction
private int sequence
private boolean locallycontrolled
private boolean locallycontrolledsettable
private int lastencodingmode
private boolean lastencryptionmode
Constructor Detail |
public ServerThreadBase(GJSAServer gx, int encodingmode, boolean encryptionmode, java.net.InetAddress rx, boolean clx, long uat, long ato)
Method Detail |
private void initNameAndIP(java.net.InetAddress ix)
ix
- IP address of the clientpublic boolean clientMatchesPattern(java.lang.String pattern)
pattern
- Description of the Parameter
public void setLocallyControlled(boolean b)
b
- Flag whether passwords should be checked or not.public boolean isLocallyControlled()
public java.net.InetAddress getClientInetAddr()
public java.lang.String getClientHostName()
public java.lang.String getClientHostIP()
public java.lang.String getClientHostDescription()
public java.net.InetAddress getReportedClientInetAddr()
public java.lang.String getReportedClientHostName()
public java.lang.String getReportedClientHostIP()
public java.lang.String getReportedClientHostDescription()
private void initEncryptionFlags(java.lang.Object o)
o
- Description of the Parameterprotected void initDataMap()
private void initSessions()
public int getUniqueSessionID()
public boolean getRemovementLogging()
public GJSAServer getGJSAServer()
public void registerSession(ServerThreadSession sts)
public void setClientAddress(java.lang.String ipaddress)
ipaddress
- The new client address, either by IP or by name.public void releaseSession(ServerThreadSession sts)
sts
- The session to be releasedpublic void setTimeouts(long nto, long ato)
nto
- Timeout in the non-authenticated caseato
- Timeout in the authenticated casepublic void turnIntoAuthenticated()
public boolean isTimedOut(long currenttime)
public void updateInteractionTimestamp()
public boolean isConnectionless()
public int getSequence()
public void incSequence()
public void incSequenceAndDisableLocallyControlled()
public java.lang.Object putProperty(java.lang.Object key, java.lang.Object value)
public java.lang.Object getProperty(java.lang.Object key)
public java.lang.Object removeProperty(java.lang.Object key)
public void setBurstAll(boolean bx)
public boolean getBurstAll()
public void setBurstNext(boolean bx)
public boolean getBurstNext()
public void setBurstSize(int s)
public int getBurstSize()
public ServerReply continueSyncBurst()
public ServerReply initBurstableReply(BurstMaker bm)
public int openSession()
public int getLastChildSessionID()
public void closeSession()
public void newState(int newstate, java.util.List commexecs, java.util.List allcommexecs)
public void newState(int newstate, java.util.List commexecs)
public void newState(int newstate, CommandExecutor commexec)
public void startNewState(int newstate)
public void retractNewState()
public void finishNewState(java.util.List commexecs, java.util.List allcommexecs)
public void finishNewState(java.util.List commexecs)
public void finishNewState(CommandExecutor commexec)
public void leaveState()
public boolean isClosing()
public void startClosing()
public boolean mayBeClosed()
public void freeFloatingReply(int seq, ServerReply sr, InformableSender isx) throws java.io.IOException
seq
- Description of the Parametersr
- Description of the Parameterisx
- Description of the Parameter
java.io.IOException
- Description of the Exceptionpublic void freeFloatingReply(int seq, ServerReply sr) throws java.io.IOException
seq
- Description of the Parametersr
- Description of the Parameter
java.io.IOException
- Description of the Exceptionpublic void logMessage(int sessionid, java.lang.Object message)
public void handleLogObject(Logger src, java.lang.Object o)
handleLogObject
in interface LoggingReceiver
src
- Description of the Parametero
- Description of the Parameterpublic void handleLogObject(Logger src, int nr, java.lang.Object o)
handleLogObject
in interface TransactionLoggingReceiver
src
- Description of the Parameternr
- Description of the Parametero
- Description of the Parameterpublic ServerReply replyOneQuery(ServerRequest sr)
public ServerEnvelope reply(ServerEnvelope se)
All requests in the ServerEnvelope are handled and the replies are collected. Actual query handling is done by the correct ServerThreadSession's reply() method. It is guaranteed that there are no more replies than there have been requests. The reply vector can be shorter, however, if a query raised a serious error or was to close the connection.
se
- ServerEnvelope containing the requests
public ServerEnvelope reply(ServerEnvelope se, boolean encrypted, int currencodingmode)
public void close()
private void doClose()
public java.lang.String toString()
private void setCurrentIdleStart()
public void putData(java.lang.String key, java.lang.Object value)
public void informConnectionListeners()
public java.util.Map getData()
public boolean isEncryptionStateCorrect()
public static int getMaxConnectionNr()
public int getConnectionNr()
public java.lang.String getConnectionID()
public void loopSynchronous(SocketLayer sly, ServerEnvelope firstquery) throws java.io.IOException
java.io.IOException
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |