QJCC homepage

biz.chitec.quarterback.gjsa
Class CBServerConnector

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.SessionedServerConnector
      extended bybiz.chitec.quarterback.gjsa.CBServerConnector

public class CBServerConnector
extends SessionedServerConnector

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: 14ba42b54d08dda256083730170a10c162ce7607 $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000,2001,2002. Distributed under the terms of the GNU LGPL.

Nested Class Summary
private  class CBServerConnector.LineWakeupToggler
          Background thread to send keep alive packets through the connection
private  class CBServerConnector.ReaderThread
          Reader thread reading the data from the socket and writing them into the ThreadInterface
 
Nested classes inherited from class biz.chitec.quarterback.gjsa.SessionedServerConnector
 
Field Summary
protected  java.io.BufferedReader bis
           
protected  java.io.BufferedWriter bos
           
protected  boolean emptyafter
           
protected  int encryptionstrategy
           
static int FLOODTIME
           
protected  boolean forcestring
           
protected  java.lang.String host
           
protected static long LINETOGGLETIME
           
protected  CBServerConnector.LineWakeupToggler lwt
           
static int MAXFLOODCOUNT
           
protected  java.io.ObjectInputStream ois
           
protected  java.io.ObjectOutputStream oos
           
protected  java.lang.String pname
           
protected  int port
           
protected  boolean printerr
           
protected  java.util.List pvp
           
protected  CBServerConnector.ReaderThread reader
           
static int SLEEPTIME
           
protected  java.net.Socket socket
           
private static int staticreaderno
           
protected  ThreadInterface syncti
           
 
Fields inherited from class biz.chitec.quarterback.gjsa.SessionedServerConnector
connected, connectionport, encodingmode, encrypted, mess, myscno, pcs, serverseenclientip, serverseenclientname, SOCKET_SO_TIME, sslciphers, sslfactory, transmitting
 
Constructor Summary
CBServerConnector(java.lang.String host, int port)
           
CBServerConnector(java.lang.String host, int port, int encstrat)
           
CBServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp)
           
CBServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp, boolean forcestring, boolean emptyafter)
           
CBServerConnector(java.lang.String xhost, int xport, java.lang.String xpname, java.util.List xpvp, boolean xforcestring, boolean xemptyafter, int xencstrat)
           
CBServerConnector(java.lang.String host, int port, java.lang.String pname, java.util.List pvp, int encstrat)
           
 
Method Summary
protected  void closeOnDesaster()
           
protected  void doCloseConnection()
          Close the current connection
protected  void doOpenConnection()
          opens the connection to the server.
protected  ServerEnvelope readEnvelope()
          Read a reply from the server.
 void setReaderPriority(int newprio)
          Readjusts the reader thread priority
 void setSendKeepAlive(boolean doit)
          Enables and disables the session connector to/from sending keep alive packets to the server.
protected  void writeEnvelope(ServerEnvelope se)
          Write an envelope to the server.
 
Methods inherited from class biz.chitec.quarterback.gjsa.SessionedServerConnector
addFreeFloatingReceiver, addPropertyChangeListener, addPropertyChangeListener, closeConnection, fireDesaster, fireFreeFloatingMessage, getEncodingMode, getEncryptionAdvice, getServerSeenClientIP, getServerSeenClientName, getSession0, getSessionedServerConnector, getSessionedServerConnector, getSessionedServerConnector, isConnected, isEncrypted, isTransmitting, openConnection, openConnectionAsynchronously, openConnectionAsynchronously, queryOrBranch, removeFreeFloatingReceiver, removePropertyChangeListener, removePropertyChangeListener, setConnected, setEncodingMode, setEncrypted, setMessageLogger, setTransmission, setupConnectionParameters, stopOpenConnectionAsynchronously, unregisterServerConnector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLOODTIME

public static final int FLOODTIME
See Also:
Constant Field Values

MAXFLOODCOUNT

public static final int MAXFLOODCOUNT
See Also:
Constant Field Values

SLEEPTIME

public static final int SLEEPTIME
See Also:
Constant Field Values

LINETOGGLETIME

protected static final long LINETOGGLETIME
See Also:
Constant Field Values

staticreaderno

private static int staticreaderno

socket

protected java.net.Socket socket

reader

protected CBServerConnector.ReaderThread reader

oos

protected java.io.ObjectOutputStream oos

bos

protected java.io.BufferedWriter bos

ois

protected java.io.ObjectInputStream ois

bis

protected java.io.BufferedReader bis

host

protected java.lang.String host

port

protected int port

pname

protected java.lang.String pname

pvp

protected java.util.List pvp

forcestring

protected boolean forcestring

emptyafter

protected boolean emptyafter

printerr

protected boolean printerr

lwt

protected CBServerConnector.LineWakeupToggler lwt

syncti

protected ThreadInterface syncti

encryptionstrategy

protected int encryptionstrategy
Constructor Detail

CBServerConnector

public CBServerConnector(java.lang.String xhost,
                         int xport,
                         java.lang.String xpname,
                         java.util.List xpvp,
                         boolean xforcestring,
                         boolean xemptyafter,
                         int xencstrat)

CBServerConnector

public CBServerConnector(java.lang.String host,
                         int port,
                         java.lang.String pname,
                         java.util.List pvp,
                         boolean forcestring,
                         boolean emptyafter)
                  throws java.io.IOException

CBServerConnector

public CBServerConnector(java.lang.String host,
                         int port,
                         java.lang.String pname,
                         java.util.List pvp,
                         int encstrat)
                  throws java.io.IOException

CBServerConnector

public CBServerConnector(java.lang.String host,
                         int port,
                         java.lang.String pname,
                         java.util.List pvp)
                  throws java.io.IOException

CBServerConnector

public CBServerConnector(java.lang.String host,
                         int port,
                         int encstrat)
                  throws java.io.IOException

CBServerConnector

public CBServerConnector(java.lang.String host,
                         int port)
                  throws java.io.IOException
Method Detail

doOpenConnection

protected void doOpenConnection()
                         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.

Specified by:
doOpenConnection in class SessionedServerConnector
Throws:
java.io.IOException - Description of the Exception

setSendKeepAlive

public void setSendKeepAlive(boolean doit)
Description copied from class: SessionedServerConnector
Enables and disables the session connector to/from sending keep alive packets to the server. These packets prevent the server from closing the connection in case of inactivity.

Specified by:
setSendKeepAlive in class SessionedServerConnector

doCloseConnection

protected void doCloseConnection()
Close the current connection

Specified by:
doCloseConnection in class SessionedServerConnector

closeOnDesaster

protected void closeOnDesaster()

setReaderPriority

public void setReaderPriority(int newprio)
Readjusts the reader thread priority


writeEnvelope

protected void writeEnvelope(ServerEnvelope se)
                      throws java.io.IOException
Description copied from class: SessionedServerConnector
Write an envelope to the server.

Specified by:
writeEnvelope in class SessionedServerConnector
Throws:
java.io.IOException

readEnvelope

protected ServerEnvelope readEnvelope()
                               throws java.io.IOException
Description copied from class: SessionedServerConnector
Read a reply from the server.

Specified by:
readEnvelope in class SessionedServerConnector
Throws:
java.io.IOException

QJCC homepage