QJCC homepage

biz.chitec.quarterback.gjsa
Class ServerConnector

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.ServerConnector
Direct Known Subclasses:
LegacyServerConnector, QueryOnlyServerConnectorWrapper, SessionConnector

public abstract class ServerConnector
extends java.lang.Object

Abstract superclass for old-style and new-style client connections to the server. This class is needed to make the transition to the new-style system easier. Almost everything is declared abstract here and implemented in either LegacyServerConnector (the old one) or SessionConnector (the new one).

Important: You cannot instanciate ServerConnector any more. Instead you have to call one of the factory methods. They instanciate always a LegacyServerConnector which implements everything needed.

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

Constructor Summary
ServerConnector()
           
 
Method Summary
abstract  void addConnectionDesasterListener(ConnectionDesasterListener cdl)
          Add listener for connection desasterts
abstract  void addConnectionEncryptionPresentor(ConnectionEncryptionPresentor ccep)
          Adds a presentor for the encryption state
abstract  void addConnectionStatePresentor(ConnectionStatePresentor ccsp)
          Adds a connection state presentor.
abstract  void attachSyncBurstReceiver(SyncBurstReceiver sbr)
          Attaches and starts a SyncBurstReceiver to this ServerConnector.
abstract  void close()
          Closes connection, does nothing if a desaster occured before
abstract  void connDesaster()
          Raises a connection desaster
abstract  void connectionOnHold(ServerEnvelope reest)
          Closes the connection to the server transparently for higher layers.
abstract  void disableErrorMsgs()
           
abstract  int getEncodingMode()
          Return encoding of the connection
abstract  boolean isBackgroundSession()
          Return whether the connector is throttling.
abstract  boolean isEncrypting()
          Gets the encrypting attribute of the ServerConnector object
static ServerConnector openLegacyServerConnector(int port)
           
static ServerConnector openLegacyServerConnector(java.lang.String host, int port)
           
static ServerConnector openLegacyServerConnector(java.lang.String host, int port, java.lang.String encstrat)
           
static ServerConnector openLegacyServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp)
           
static ServerConnector openLegacyServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp, boolean forcestring, boolean emptyafter)
           
static ServerConnector openLegacyServerConnector(java.lang.String xhost, int xport, java.lang.String xpname, java.util.List xpvp, boolean xforcestring, boolean xemptyafter, java.lang.String xencstrat)
          Opens a connection to a GJSA server
static ServerConnector openLegacyServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp, java.lang.String encstrat)
           
 ServerReply query(int cmd)
          Query parameterless command
 ServerReply query(int cmd, java.lang.Object p1)
           
 ServerReply query(int cmd, java.lang.Object[] params)
          Generic one-command query to the server which throws Exception in case of problems
 ServerReply query(int cmd, java.lang.Object p1, java.lang.Object p2)
           
 ServerReply query(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
           
 ServerReply query(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4)
           
 ServerReply query(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5)
           
 ServerReply query(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6)
           
abstract  ServerEnvelope query(ServerEnvelope se)
          Low level query The ServerEnvelope may contain multiple queries.
 ServerReply query(ServerRequest sr)
          Query one request, return that reply.
 ServerReply[] query(ServerRequest[] sr)
          Convenience method, queries multiple queries, returns all replies, everything as arrays.
 ServerReply queryNE(int cmd)
          Query parameterless command without exception
 ServerReply queryNE(int cmd, java.lang.Object p1)
           
 ServerReply queryNE(int cmd, java.lang.Object[] params)
          Generic one-command query to the server, IO problems are returned as error reply
 ServerReply queryNE(int cmd, java.lang.Object p1, java.lang.Object p2)
           
 ServerReply queryNE(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
           
 ServerReply queryNE(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4)
           
 ServerReply queryNE(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5)
           
 ServerReply queryNE(int cmd, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4, java.lang.Object p5, java.lang.Object p6)
           
 ServerEnvelope queryNE(ServerEnvelope se)
          Low level query without exception The ServerEnvelope may contain multiple queries.
 ServerReply queryNE(ServerRequest sr)
          Query one requests, exceptions are expressed as errors.
 ServerReply[] queryNE(ServerRequest[] sr)
          Performs multiple queries with catching all IOExceptions.
abstract  void removeConnectionDesasterListener(ConnectionDesasterListener cdl)
          Remove listener for connection desasters
abstract  void removeConnectionStatePresentor()
          Removes the presentor for the connection state
abstract  void setBackgroundSession(boolean b)
          Set the connector to "throttling" mode => if someone else is sending, wait for that one to finish.
abstract  void setFreeFloatingInterface(ThreadInterface ti)
          Set the interface where free floating messages are sent to.
abstract  void setMessageLogger(Logger mx)
          Sets the messageLogger attribute of the ServerConnector object
abstract  void setReaderPriority(int newprio)
          Set priority of the reader thread.
abstract  void startLineWakeupToggler()
           
abstract  void stopSyncBurstReceiver()
          Stops a currently running SyncBurstReceiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerConnector

public ServerConnector()
Method Detail

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(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
Opens a connection to a GJSA server

Parameters:
xhost - host name
xport - port number
xpname - protocol name
xpvp - local protocol version
xforcestring - flag to force string communication
xemptyafter - flag to send an empty command after each command
xencstrat - encryption strategy
Throws:
java.io.IOException - raised if opening fails for any reason

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(java.lang.String host,
                                                        int port,
                                                        java.lang.String pname,
                                                        java.util.List pvp,
                                                        boolean forcestring,
                                                        boolean emptyafter)
                                                 throws java.io.IOException
Throws:
java.io.IOException

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(java.lang.String host,
                                                        int port,
                                                        java.lang.String pname,
                                                        java.util.List pvp,
                                                        java.lang.String encstrat)
                                                 throws java.io.IOException
Throws:
java.io.IOException

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(java.lang.String host,
                                                        int port,
                                                        java.lang.String pname,
                                                        java.util.List pvp)
                                                 throws java.io.IOException
Throws:
java.io.IOException

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(java.lang.String host,
                                                        int port,
                                                        java.lang.String encstrat)
                                                 throws java.io.IOException
Throws:
java.io.IOException

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(java.lang.String host,
                                                        int port)
                                                 throws java.io.IOException
Throws:
java.io.IOException

openLegacyServerConnector

public static ServerConnector openLegacyServerConnector(int port)
                                                 throws java.io.IOException
Throws:
java.io.IOException

isEncrypting

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

Returns:
The encrypting value

connectionOnHold

public abstract 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.

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

setMessageLogger

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

Parameters:
mx - The new messageLogger value

disableErrorMsgs

public abstract void disableErrorMsgs()

startLineWakeupToggler

public abstract void startLineWakeupToggler()

stopSyncBurstReceiver

public abstract 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.


attachSyncBurstReceiver

public abstract 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.

Parameters:
sbr - Description of the Parameter

close

public abstract void close()
Closes connection, does nothing if a desaster occured before


connDesaster

public abstract void connDesaster()
Raises a connection desaster


addConnectionStatePresentor

public abstract void addConnectionStatePresentor(ConnectionStatePresentor ccsp)
Adds a connection state presentor.


addConnectionEncryptionPresentor

public abstract void addConnectionEncryptionPresentor(ConnectionEncryptionPresentor ccep)
Adds a presentor for the encryption state


removeConnectionStatePresentor

public abstract void removeConnectionStatePresentor()
Removes the presentor for the connection state


getEncodingMode

public abstract int getEncodingMode()
Return encoding of the connection


addConnectionDesasterListener

public abstract void addConnectionDesasterListener(ConnectionDesasterListener cdl)
Add listener for connection desasterts


removeConnectionDesasterListener

public abstract void removeConnectionDesasterListener(ConnectionDesasterListener cdl)
Remove listener for connection desasters


setFreeFloatingInterface

public abstract void setFreeFloatingInterface(ThreadInterface ti)
Set the interface where free floating messages are sent to.


setReaderPriority

public abstract void setReaderPriority(int newprio)
Set priority of the reader thread.


setBackgroundSession

public abstract void setBackgroundSession(boolean b)
Set the connector to "throttling" mode => if someone else is sending, wait for that one to finish.


isBackgroundSession

public abstract boolean isBackgroundSession()
Return whether the connector is throttling.


query

public abstract ServerEnvelope query(ServerEnvelope se)
                              throws java.io.IOException
Low level query The ServerEnvelope may contain multiple queries. On return, it will contain the replies to these queries. If the reply to one of these queries is ERROR, NO, or DENIED, the further queries will not be processed any more.

This method is the one which actually communicates with the server. All other query methods finally call this one.

Parameters:
se - ServerEnvelope with one or more queries set
Returns:
ServerEnvelope with one or more reples set
Throws:
java.io.IOException - If something goes wrong in the communication between client and server
See Also:
ServerEnvelope

queryNE

public final ServerEnvelope queryNE(ServerEnvelope se)
Low level query without exception The ServerEnvelope may contain multiple queries. On return, it will contain the replies to these queries. If the reply to one of these queries is ERROR, NO, or DENIED, the further queries will not be processed any more. If a connection failure happens during communication, only one reply will be in the reply part of the ServerEnvelope returned and it is ERROR. No exception will be thrown, however.

Parameters:
se - ServerEnvelope with one or more queries set
Returns:
ServerEnvelope with one or more reples set, in case of communication errors with one reply being ERROR

query

public final ServerReply[] query(ServerRequest[] sr)
                          throws java.io.IOException
Convenience method, queries multiple queries, returns all replies, everything as arrays.

Parameters:
sr - Array of queries
Returns:
Array of replies
Throws:
java.io.IOException

queryNE

public final ServerReply[] queryNE(ServerRequest[] sr)
Performs multiple queries with catching all IOExceptions. If an IOException occures, an array of size 1 with content "serious error" is returned.

Parameters:
sr - Array of queries
Returns:
Array of replies

query

public final ServerReply query(ServerRequest sr)
                        throws java.io.IOException
Query one request, return that reply.

Throws:
java.io.IOException

queryNE

public final ServerReply queryNE(ServerRequest sr)
Query one requests, exceptions are expressed as errors.


query

public final ServerReply query(int cmd,
                               java.lang.Object[] params)
                        throws java.io.IOException
Generic one-command query to the server which throws Exception in case of problems

Parameters:
cmd - Command symbols to send to the server
params - Parameters for the command. May be null or of size 0.
Returns:
Reply received from the server.
Throws:
java.io.IOException

query

public final ServerReply query(int cmd)
                        throws java.io.IOException
Query parameterless command

Throws:
java.io.IOException

query

public final ServerReply query(int cmd,
                               java.lang.Object p1)
                        throws java.io.IOException
Throws:
java.io.IOException

query

public final ServerReply query(int cmd,
                               java.lang.Object p1,
                               java.lang.Object p2)
                        throws java.io.IOException
Throws:
java.io.IOException

query

public final ServerReply query(int cmd,
                               java.lang.Object p1,
                               java.lang.Object p2,
                               java.lang.Object p3)
                        throws java.io.IOException
Throws:
java.io.IOException

query

public final ServerReply query(int cmd,
                               java.lang.Object p1,
                               java.lang.Object p2,
                               java.lang.Object p3,
                               java.lang.Object p4)
                        throws java.io.IOException
Throws:
java.io.IOException

query

public final ServerReply query(int cmd,
                               java.lang.Object p1,
                               java.lang.Object p2,
                               java.lang.Object p3,
                               java.lang.Object p4,
                               java.lang.Object p5)
                        throws java.io.IOException
Throws:
java.io.IOException

query

public final ServerReply query(int cmd,
                               java.lang.Object p1,
                               java.lang.Object p2,
                               java.lang.Object p3,
                               java.lang.Object p4,
                               java.lang.Object p5,
                               java.lang.Object p6)
                        throws java.io.IOException
Throws:
java.io.IOException

queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object[] params)
Generic one-command query to the server, IO problems are returned as error reply

Parameters:
cmd - Command symbols to send to the server
params - Parameters for the command. May be null or of size 0.
Returns:
Reply received from the server.

queryNE

public final ServerReply queryNE(int cmd)
Query parameterless command without exception


queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object p1)

queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object p1,
                                 java.lang.Object p2)

queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3)

queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4)

queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5)

queryNE

public final ServerReply queryNE(int cmd,
                                 java.lang.Object p1,
                                 java.lang.Object p2,
                                 java.lang.Object p3,
                                 java.lang.Object p4,
                                 java.lang.Object p5,
                                 java.lang.Object p6)

QJCC homepage