QJCC homepage

biz.chitec.quarterback.gjsa
Class LegacyServerConnector

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.ServerConnector
      extended bybiz.chitec.quarterback.gjsa.LegacyServerConnector
Direct Known Subclasses:
CLServerConnector

public class LegacyServerConnector
extends ServerConnector

Class to connect a Java client to a GJSA server. Connects to a server with a Client. Sets server immideately in object connective mode if protocol families are equal and then holds the connection open.

A connection desaster listener can be hooked on, whose method connectionDesaster() is called if the connection breaks down.

For now, there are two ways to interact with the server. The simple one is to call the query() method with a query, which will return with the server's reply. The is a so-called "synchronous message".

Furthermore, it is possible to register a FreeFloatingHandler. This one gets every message that comes from the server without a special query (a free floating message).

Version:
$Id: 445a4b772f8052ee2fdb4b3bad784ad215d2ad96 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000,2001,2002. Distributed under the terms of the GNU LGPL.

Nested Class Summary
private  class LegacyServerConnector.LineWakeupToggler
          sends from time to time empty request to server to prevent it from closing the connection.
(package private) static class LegacyServerConnector.Reader
          reader thread for a server connector.
 
Field Summary
protected  boolean backgroundsession
           
protected  java.io.BufferedWriter bos
          Description of the Field
protected  ConnectionEncryptionPresentor cep
          Description of the Field
protected  java.util.List conndeslist
          Description of the Field
protected  boolean connectionclosed
          Description of the Field
protected  ConnectionStatePresentor csp
          Description of the Field
protected  boolean desasteroccured
          Description of the Field
protected  boolean emptyafter
          Description of the Field
protected  boolean encmode
          Description of the Field
protected  java.lang.String encryptionstrategy
          Description of the Field
protected static EncryptionRulesSymbols ers
          Description of the Field
protected static EncryptionStrategySymbols ess
          Description of the Field
protected  ThreadInterface ffi
          Description of the Field
static int FLOODTIME
          Description of the Field
protected  boolean forcestring
          Description of the Field
protected  java.lang.String host
          Description of the Field
protected static long LINETOGGLETIME
          Description of the Field
protected  LegacyServerConnector.LineWakeupToggler lwt
          Description of the Field
static int MAXFLOODCOUNT
          Description of the Field
protected  Logger mess
          Description of the Field
protected  boolean mustbereestablished
          Description of the Field
 int myscnum
          Description of the Field
protected  boolean objmode
          Description of the Field
protected  java.io.ObjectOutputStream oos
          Description of the Field
protected  java.lang.String pname
          Description of the Field
protected  int port
          Description of the Field
protected  boolean printerr
          Description of the Field
protected  java.util.List pvp
          Description of the Field
protected  LegacyServerConnector.Reader reader
          Description of the Field
protected  ServerEnvelope reestablishcommands
          Description of the Field
private static int sbrcounter
          Counter for attached SyncBurstReceivers
static int SLEEPTIME
          Description of the Field
protected  java.net.Socket socket
          Description of the Field
static int SOCKET_SO_TIME
          Timeout for the socket in initialisation phase.
protected  ServerRequest sr
          Description of the Field
protected  boolean sslmode
          Description of the Field
protected static int staticlwtnum
          Description of the Field
protected static int staticnum
          Description of the Field
protected static int staticreadernum
          Description of the Field
protected  SyncBurstReceiver syncburstreceiver
          Description of the Field
protected  java.lang.Thread syncburstreceiverthread
          Description of the Field
protected  ThreadInterface ti
          Description of the Field
 
Constructor Summary
LegacyServerConnector(int port)
          Constructor for the ServerConnector object
LegacyServerConnector(java.lang.String host, int port)
          Constructor for the ServerConnector object
LegacyServerConnector(java.lang.String host, int port, java.lang.String encstrat)
          Constructor for the ServerConnector object
LegacyServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp)
          Constructor for the ServerConnector object
LegacyServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp, boolean forcestring, boolean emptyafter)
          Constructor for the ServerConnector object
LegacyServerConnector(java.lang.String xhost, int xport, java.lang.String xpname, java.util.List xpvp, boolean xforcestring, boolean xemptyafter, java.lang.String xencstrat)
          tries to open a connection to the given host/port-pair.
LegacyServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp, java.lang.String encstrat)
          Constructor for the ServerConnector object
 
Method Summary
 void addConnectionDesasterListener(ConnectionDesasterListener cdl)
          Adds a feature to the ConnectionDesasterListener attribute of the ServerConnector object
 void addConnectionEncryptionPresentor(ConnectionEncryptionPresentor ccep)
          Adds a feature to the ConnectionEncryptionPresentor attribute of the ServerConnector object
 void addConnectionStatePresentor(ConnectionStatePresentor ccsp)
          Adds a feature to the ConnectionStatePresentor attribute of the ServerConnector object
 void attachSyncBurstReceiver(SyncBurstReceiver sbr)
          Attaches and starts a SyncBurstReceiver to this ServerConnector.
 void close()
          Description of the Method
protected  void closeConnection()
          Description of the Method
 void connDesaster()
          Description of the Method
 void connectionOnHold(ServerEnvelope reest)
          Closes the connection to the server transparently for higher layers.
 void disableErrorMsgs()
          Description of the Method
 int getEncodingMode()
          Return encoding of the connection
protected  boolean getEncryptionAdvice(int clientstrategy, int serverwish)
          Determines whether the connection should be encrypted or not.
private  java.util.List getFirstAndSecondVersionPart(java.lang.String vers)
          Gets the firstAndSecondVersionPart attribute of the ServerConnector object
 boolean isBackgroundSession()
          Return whether the connector is throttling.
 boolean isEncrypting()
          Gets the encrypting attribute of the ServerConnector object
 boolean isObjectConnection()
          Gets the objectConnection attribute of the ServerConnector object
private  void keepLine()
          Description of the Method
protected  void openConnection()
          opens the connection to the server.
 ServerEnvelope query(ServerEnvelope se)
          low level query routine with IOException
 void removeConnectionDesasterListener(ConnectionDesasterListener cdl)
          Description of the Method
 void removeConnectionStatePresentor()
          Description of the Method
 void setBackgroundSession(boolean t)
          Set the connector to "throttling" mode => if someone else is sending, wait for that one to finish.
 void setFreeFloatingInterface(ThreadInterface ti)
          Sets the freeFloatingInterface attribute of the ServerConnector object
 void setMessageLogger(Logger mx)
          Sets the messageLogger attribute of the ServerConnector object
 void setReaderPriority(int newprio)
          Sets the readerPriority attribute of the ServerConnector object
 void startLineWakeupToggler()
          Description of the Method
 void stopSyncBurstReceiver()
          Stops a currently running SyncBurstReceiver.
 
Methods inherited from class biz.chitec.quarterback.gjsa.ServerConnector
openLegacyServerConnector, openLegacyServerConnector, openLegacyServerConnector, openLegacyServerConnector, openLegacyServerConnector, openLegacyServerConnector, openLegacyServerConnector, query, query, query, query, query, query, query, query, query, query, queryNE, queryNE, queryNE, queryNE, queryNE, queryNE, queryNE, queryNE, queryNE, queryNE, queryNE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ers

protected static final EncryptionRulesSymbols ers
Description of the Field


ess

protected static final EncryptionStrategySymbols ess
Description of the Field


sbrcounter

private static int sbrcounter
Counter for attached SyncBurstReceivers


SOCKET_SO_TIME

public static final int SOCKET_SO_TIME
Timeout for the socket in initialisation phase.

See Also:
Constant Field Values

FLOODTIME

public static final int FLOODTIME
Description of the Field

See Also:
Constant Field Values

MAXFLOODCOUNT

public static final int MAXFLOODCOUNT
Description of the Field

See Also:
Constant Field Values

SLEEPTIME

public static final int SLEEPTIME
Description of the Field

See Also:
Constant Field Values

LINETOGGLETIME

protected static final long LINETOGGLETIME
Description of the Field

See Also:
Constant Field Values

staticnum

protected static int staticnum
Description of the Field


staticreadernum

protected static int staticreadernum
Description of the Field


staticlwtnum

protected static int staticlwtnum
Description of the Field


myscnum

public int myscnum
Description of the Field


socket

protected java.net.Socket socket
Description of the Field


reader

protected LegacyServerConnector.Reader reader
Description of the Field


oos

protected java.io.ObjectOutputStream oos
Description of the Field


bos

protected java.io.BufferedWriter bos
Description of the Field


objmode

protected boolean objmode
Description of the Field


encmode

protected boolean encmode
Description of the Field


sslmode

protected boolean sslmode
Description of the Field


desasteroccured

protected boolean desasteroccured
Description of the Field


connectionclosed

protected boolean connectionclosed
Description of the Field


conndeslist

protected java.util.List conndeslist
Description of the Field


csp

protected ConnectionStatePresentor csp
Description of the Field


cep

protected ConnectionEncryptionPresentor cep
Description of the Field


ti

protected ThreadInterface ti
Description of the Field


sr

protected ServerRequest sr
Description of the Field


mess

protected Logger mess
Description of the Field


host

protected java.lang.String host
Description of the Field


port

protected int port
Description of the Field


pname

protected java.lang.String pname
Description of the Field


pvp

protected java.util.List pvp
Description of the Field


forcestring

protected boolean forcestring
Description of the Field


emptyafter

protected boolean emptyafter
Description of the Field


printerr

protected boolean printerr
Description of the Field


lwt

protected LegacyServerConnector.LineWakeupToggler lwt
Description of the Field


reestablishcommands

protected ServerEnvelope reestablishcommands
Description of the Field


mustbereestablished

protected boolean mustbereestablished
Description of the Field


ffi

protected ThreadInterface ffi
Description of the Field


encryptionstrategy

protected java.lang.String encryptionstrategy
Description of the Field


syncburstreceiverthread

protected java.lang.Thread syncburstreceiverthread
Description of the Field


syncburstreceiver

protected SyncBurstReceiver syncburstreceiver
Description of the Field


backgroundsession

protected boolean backgroundsession
Constructor Detail

LegacyServerConnector

public LegacyServerConnector(java.lang.String xhost,
                             int xport,
                             java.lang.String xpname,
                             java.util.List xpvp,
                             boolean xforcestring,
                             boolean xemptyafter,
                             java.lang.String xencstrat)
                      throws java.io.IOException
tries to open a connection to the given host/port-pair. In the first stage, Reader and Writer are opened to the socket to perform the String protocol the server is always in at any connection start. After switching to Object protocol, the Reader thread is startened.

Parameters:
xhost - Description of the Parameter
xport - Description of the Parameter
xpname - Description of the Parameter
xpvp - Description of the Parameter
xforcestring - Description of the Parameter
xemptyafter - Description of the Parameter
xencstrat - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

LegacyServerConnector

public LegacyServerConnector(java.lang.String host,
                             int port,
                             java.lang.String pname,
                             java.util.List pvp,
                             boolean forcestring,
                             boolean emptyafter)
                      throws java.io.IOException
Constructor for the ServerConnector object

Parameters:
host - Description of the Parameter
port - Description of the Parameter
pname - Description of the Parameter
pvp - Description of the Parameter
forcestring - Description of the Parameter
emptyafter - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

LegacyServerConnector

public LegacyServerConnector(java.lang.String host,
                             int port,
                             java.lang.String pname,
                             java.util.List pvp,
                             java.lang.String encstrat)
                      throws java.io.IOException
Constructor for the ServerConnector object

Parameters:
host - Description of the Parameter
port - Description of the Parameter
pname - Description of the Parameter
pvp - Description of the Parameter
encstrat - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

LegacyServerConnector

public LegacyServerConnector(java.lang.String host,
                             int port,
                             java.lang.String pname,
                             java.util.List pvp)
                      throws java.io.IOException
Constructor for the ServerConnector object

Parameters:
host - Description of the Parameter
port - Description of the Parameter
pname - Description of the Parameter
pvp - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

LegacyServerConnector

public LegacyServerConnector(java.lang.String host,
                             int port,
                             java.lang.String encstrat)
                      throws java.io.IOException
Constructor for the ServerConnector object

Parameters:
host - Description of the Parameter
port - Description of the Parameter
encstrat - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

LegacyServerConnector

public LegacyServerConnector(java.lang.String host,
                             int port)
                      throws java.io.IOException
Constructor for the ServerConnector object

Parameters:
host - Description of the Parameter
port - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

LegacyServerConnector

public LegacyServerConnector(int port)
                      throws java.io.IOException
Constructor for the ServerConnector object

Parameters:
port - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception
Method Detail

getFirstAndSecondVersionPart

private java.util.List getFirstAndSecondVersionPart(java.lang.String vers)
Gets the firstAndSecondVersionPart attribute of the ServerConnector object

Parameters:
vers - Description of the Parameter
Returns:
The firstAndSecondVersionPart value

getEncryptionAdvice

protected boolean getEncryptionAdvice(int clientstrategy,
                                      int serverwish)
Determines whether the connection should be encrypted or not. The Server has one of four wishes about encryption while the client follows one of five strategies. The actual result of the connection being encrypted or not or the whole connect process being aborted can be looked up in the following table (client in rows, server in columns):

Client\Server no encryption FORBIDDEN NOTNEEDED WANTED REQUIRED
never clear clear clear clear fail
onrequire clear clear clear clear encrypted
onwanted clear clear clear encrypted encrypted
always clear clear encrypted encrypted encrypted
alwaysforced fail fail encrypted encrypted encrypted
In the fail cases this method throws a IllegalStateException. Otherwise, it returns a boolean value according to the computation results.

Parameters:
clientstrategy - Description of the Parameter
serverwish - Description of the Parameter
Returns:
The encryptionAdvice value

openConnection

protected void openConnection()
                       throws java.io.IOException
opens the connection to the server. Relies on several object variables. Note that this method must be called either from constructors or from within a synchronized block.

Throws:
java.io.IOException - Description of the Exception

isEncrypting

public boolean isEncrypting()
Gets the encrypting attribute of the ServerConnector object

Specified by:
isEncrypting in class ServerConnector
Returns:
The encrypting value

connectionOnHold

public void connectionOnHold(ServerEnvelope reest)
                      throws java.io.IOException
Closes the connection to the server transparently for higher layers. The socket holding the connection to the server is closed. From now on, no connection to the server exists any more.

The next query sent to the ServerConnector will reestablish the connection. After opening the ports, the complete reest ServerEnvelope will be sent to the server to reach the state it had on closing.

Specified by:
connectionOnHold in class ServerConnector
Parameters:
reest - Description of the Parameter
Throws:
java.io.IOException - Description of the Exception

setMessageLogger

public void setMessageLogger(Logger mx)
Sets the messageLogger attribute of the ServerConnector object

Specified by:
setMessageLogger in class ServerConnector
Parameters:
mx - The new messageLogger value

disableErrorMsgs

public void disableErrorMsgs()
Description of the Method

Specified by:
disableErrorMsgs in class ServerConnector

startLineWakeupToggler

public void startLineWakeupToggler()
Description of the Method

Specified by:
startLineWakeupToggler in class ServerConnector

stopSyncBurstReceiver

public void stopSyncBurstReceiver()
Stops a currently running SyncBurstReceiver. Called internally everytime a sync burst must be stopped. It doesn't hurt to call this method with no sync burst running.

Specified by:
stopSyncBurstReceiver in class ServerConnector

attachSyncBurstReceiver

public void attachSyncBurstReceiver(SyncBurstReceiver sbr)
Attaches and starts a SyncBurstReceiver to this ServerConnector. The SyncBurstReceiver is started in a new Thread object instantiated directly by this ServerConnector.

Specified by:
attachSyncBurstReceiver in class ServerConnector
Parameters:
sbr - Description of the Parameter

closeConnection

protected void closeConnection()
Description of the Method


close

public void close()
Description of the Method

Specified by:
close in class ServerConnector

connDesaster

public void connDesaster()
Description of the Method

Specified by:
connDesaster in class ServerConnector

addConnectionStatePresentor

public void addConnectionStatePresentor(ConnectionStatePresentor ccsp)
Adds a feature to the ConnectionStatePresentor attribute of the ServerConnector object

Specified by:
addConnectionStatePresentor in class ServerConnector
Parameters:
ccsp - The feature to be added to the ConnectionStatePresentor attribute

addConnectionEncryptionPresentor

public void addConnectionEncryptionPresentor(ConnectionEncryptionPresentor ccep)
Adds a feature to the ConnectionEncryptionPresentor attribute of the ServerConnector object

Specified by:
addConnectionEncryptionPresentor in class ServerConnector
Parameters:
ccep - The feature to be added to the ConnectionEncryptionPresentor attribute

removeConnectionStatePresentor

public void removeConnectionStatePresentor()
Description of the Method

Specified by:
removeConnectionStatePresentor in class ServerConnector

setBackgroundSession

public void setBackgroundSession(boolean t)
Description copied from class: ServerConnector
Set the connector to "throttling" mode => if someone else is sending, wait for that one to finish.

Specified by:
setBackgroundSession in class ServerConnector

isBackgroundSession

public boolean isBackgroundSession()
Description copied from class: ServerConnector
Return whether the connector is throttling.

Specified by:
isBackgroundSession in class ServerConnector

isObjectConnection

public boolean isObjectConnection()
Gets the objectConnection attribute of the ServerConnector object

Returns:
The objectConnection value

getEncodingMode

public int getEncodingMode()
Description copied from class: ServerConnector
Return encoding of the connection

Specified by:
getEncodingMode in class ServerConnector

addConnectionDesasterListener

public void addConnectionDesasterListener(ConnectionDesasterListener cdl)
Adds a feature to the ConnectionDesasterListener attribute of the ServerConnector object

Specified by:
addConnectionDesasterListener in class ServerConnector
Parameters:
cdl - The feature to be added to the ConnectionDesasterListener attribute

removeConnectionDesasterListener

public void removeConnectionDesasterListener(ConnectionDesasterListener cdl)
Description of the Method

Specified by:
removeConnectionDesasterListener in class ServerConnector
Parameters:
cdl - Description of the Parameter

setFreeFloatingInterface

public void setFreeFloatingInterface(ThreadInterface ti)
Sets the freeFloatingInterface attribute of the ServerConnector object

Specified by:
setFreeFloatingInterface in class ServerConnector
Parameters:
ti - The new freeFloatingInterface value

setReaderPriority

public void setReaderPriority(int newprio)
Sets the readerPriority attribute of the ServerConnector object

Specified by:
setReaderPriority in class ServerConnector
Parameters:
newprio - The new readerPriority value

keepLine

private void keepLine()
               throws java.io.IOException
Description of the Method

Throws:
java.io.IOException - Description of the Exception

query

public ServerEnvelope query(ServerEnvelope se)
                     throws java.io.IOException
low level query routine with IOException

Specified by:
query in class ServerConnector
Parameters:
se - Description of the Parameter
Returns:
Description of the Return Value
Throws:
java.io.IOException - Description of the Exception
See Also:
ServerEnvelope

QJCC homepage