QJCC homepage

biz.chitec.quarterback.gjsa
Class ServerEnvelope

java.lang.Object
  extended bybiz.chitec.quarterback.gjsa.ServerEnvelope
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ServerEnvelope
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

message object for GJSA communication. ServerEnvelope is the "master" object that is sent between server and client (in both directions). Its most important parts are the two lists of requests and replies. Normally, a ServerEnvelope is sent from client to server with only the quest list set appropriately. The same envelope is sent back again from server to client with the replies set (and the queries deleted to save space and time).

ServerEnvelope has some additional fields and methods for certain usages. First, it always is in one of two states: part of a synchronous or free floating communication. It has a target and a sequence field for connectionless communication and knows about a source address for the same reason.

A ServerEnvelope can have an InformableSender reference. Through its informSender() method, the sender can be informed that the envelope has been sent over the network connection. This is extremly useful for asynchronous or free floating communication where it must be avoided that the server sends the data blocks too fast.

Version:
$Id: e6312a03b74d3b80242ac6cd171ff3cca630ab2a $
Author:
Dirk Hillbrecht 1997-2000, chitec/Dirk Hillbrecht 2000. Distributed under the terms of the GNU LGPL.
See Also:
Serialized Form

Field Summary
static int FREEFLOATING
          possible type: free floating information sent by server
private  InformableSender is
           
private  SessionConnector newsessionconnector
           
private  java.util.List quests
           
private  java.util.List replies
           
private  int seq
          The sequence count
private  int session
          session number
private  java.net.InetAddress source
          The address of the client.
static int SYNCHRONIZED
          possible type: part of a synchonized connection
 int target
          target handle for connectionless connections
 int type
          envelope type
static int UNINITIALIZED
          possible type: not initialized yet.
 
Constructor Summary
ServerEnvelope()
          creates a synchronized envelope with no real content
ServerEnvelope(int tx, int sx, ServerReply sr)
          creates a replying envelope with type and sequence number
ServerEnvelope(int tx, ServerReply sr)
          creates an envelope with type tx and one reply
ServerEnvelope(int t, ServerRequest quest)
          creates an envelope with (connectionless) target t and one request.
ServerEnvelope(ServerRequest quest)
          creates a synchronized envelope with one request as content
ServerEnvelope(ServerRequest[] questsx)
          creates a synchronized envelope with several requests in an Array as content
ServerEnvelope(ServerRequest[] questsx, int sessionx)
          creates a synchronized envelope with several requests in an Array in a certain session as content
ServerEnvelope(ServerRequest quest, int sessionx)
          creates a synchronized envelope with one request in a certain session as content
 
Method Summary
 void addFirstReply(ServerReply repl)
          adds a reply to the beginning of the list.
 void addReply(ServerReply repl)
          adds a reply to the reply vector.
 void addRequest(int rn)
          adds a request consisting of the command rn.
 void addRequest(int rn, java.lang.Object p1)
          adds a request consisting of the command rn and one parameter.
 void addRequest(int rn, java.lang.Object[] p)
          adds a request consisting of the command rn and a parameter array.
 void addRequest(int rn, java.lang.Object p1, java.lang.Object p2)
          adds a request consisting of the command rn and two parameters.
 void addRequest(int rn, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3)
          adds a request consisting of the command rn and three parameters.
 void addRequest(int rn, java.lang.Object p1, java.lang.Object p2, java.lang.Object p3, java.lang.Object p4)
          adds a request consisting of the command rn and four parameters.
 void addRequest(ServerRequest req)
          adds a request by adding the passed parameter to the request vector.
 java.lang.Object clone()
          Clones this ServerEnvelope.
 ServerReply getFirstReply()
          Returns the first reply of the reply vector.
 ServerRequest getFirstRequest()
          return the first request
 ServerReply getLastReply()
          Returns the last reply of the reply vector.
 SessionConnector getNewSessionConnector()
          Returns a SessionConnector object which is useable for querying a new session.
 java.util.List getReplies()
          gets replies as a list.
 ServerReply[] getReplyArray()
          gets the replies an an array
 java.util.List getRequests()
          returns the complete request vector.
 int getSequence()
          returns the sequence field.
 int getSession()
          Returns the session.
 java.net.InetAddress getSource()
          returns the stored source of this envelope.
 int getTarget()
          returns the target field
 void informSender()
          informs the sender that the envelope has been sent.
 boolean isClosingReply()
          Returns whether this reply is closing the connection
 boolean isClosingRequest()
          Returns whether this reply will close the connection intentionally (by issuing QUIT)
 ServerRequest removeFirstRequest()
          Remove the first request from the request list and return it
 void removeReplies()
          removes the reply vector.
 void removeRequests()
          remove the complete request vector.
 void setInformableSender(InformableSender isx)
          sets an informable sender for this envelope
 void setReplies(java.util.List repl)
          sets an arbitrary reply vector
 void setReply(ServerReply repl)
          sets a reply vector consisting of exactly one reply object.
 void setRequests(java.util.List q)
          sets the requests.
 void setSequence(int s)
          set the sequence field (only used for connectionless connections)
 void setSession(int session)
          Sets the session.
 void setSource(java.net.InetAddress src)
          sets the source of this envelope.
 void setTarget(int t)
          set the target field (only used for connectionless connections)
 java.lang.String toString()
          converts the object to a String.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNINITIALIZED

public static final int UNINITIALIZED
possible type: not initialized yet.

See Also:
Constant Field Values

SYNCHRONIZED

public static final int SYNCHRONIZED
possible type: part of a synchonized connection

See Also:
Constant Field Values

FREEFLOATING

public static final int FREEFLOATING
possible type: free floating information sent by server

See Also:
Constant Field Values

type

public int type
envelope type


target

public int target
target handle for connectionless connections


session

private int session
session number


seq

private int seq
The sequence count


source

private java.net.InetAddress source
The address of the client.


is

private transient InformableSender is

newsessionconnector

private transient SessionConnector newsessionconnector

quests

private java.util.List quests

replies

private java.util.List replies
Constructor Detail

ServerEnvelope

public ServerEnvelope()
creates a synchronized envelope with no real content


ServerEnvelope

public ServerEnvelope(ServerRequest quest)
creates a synchronized envelope with one request as content


ServerEnvelope

public ServerEnvelope(ServerRequest[] questsx)
creates a synchronized envelope with several requests in an Array as content


ServerEnvelope

public ServerEnvelope(ServerRequest quest,
                      int sessionx)
creates a synchronized envelope with one request in a certain session as content


ServerEnvelope

public ServerEnvelope(ServerRequest[] questsx,
                      int sessionx)
creates a synchronized envelope with several requests in an Array in a certain session as content


ServerEnvelope

public ServerEnvelope(int t,
                      ServerRequest quest)
creates an envelope with (connectionless) target t and one request.


ServerEnvelope

public ServerEnvelope(int tx,
                      ServerReply sr)
creates an envelope with type tx and one reply


ServerEnvelope

public ServerEnvelope(int tx,
                      int sx,
                      ServerReply sr)
creates a replying envelope with type and sequence number

Method Detail

clone

public java.lang.Object clone()
Clones this ServerEnvelope. The vector objects for requests and replies are cloned, but the contents of the vectors are not.


getNewSessionConnector

public SessionConnector getNewSessionConnector()
Returns a SessionConnector object which is useable for querying a new session. The new session must be opened before. Normally, this happens implicitly.

Returns:
SessionConnector object, null if none available

setInformableSender

public void setInformableSender(InformableSender isx)
sets an informable sender for this envelope


informSender

public void informSender()
informs the sender that the envelope has been sent. If no informable sender has been set, nothing happens. This method is called normally only by serverpart.ServerWriter or the writing part of SessionConnector.

The reference to sender object is deleted immideately after this information. Therefore, a sender can and will be informed only _once_!


setReplies

public void setReplies(java.util.List repl)
sets an arbitrary reply vector


addReply

public void addReply(ServerReply repl)
adds a reply to the reply vector.


setReply

public void setReply(ServerReply repl)
sets a reply vector consisting of exactly one reply object. Replaces any replies that might have been set earlier.


addFirstReply

public void addFirstReply(ServerReply repl)
adds a reply to the beginning of the list.


getReplies

public java.util.List getReplies()
gets replies as a list.


getReplyArray

public ServerReply[] getReplyArray()
gets the replies an an array


getFirstReply

public ServerReply getFirstReply()
Returns the first reply of the reply vector.


getLastReply

public ServerReply getLastReply()
Returns the last reply of the reply vector.


isClosingRequest

public boolean isClosingRequest()
Returns whether this reply will close the connection intentionally (by issuing QUIT)


isClosingReply

public boolean isClosingReply()
Returns whether this reply is closing the connection


setRequests

public void setRequests(java.util.List q)
sets the requests.


addRequest

public void addRequest(ServerRequest req)
adds a request by adding the passed parameter to the request vector.


addRequest

public void addRequest(int rn)
adds a request consisting of the command rn.


addRequest

public void addRequest(int rn,
                       java.lang.Object p1)
adds a request consisting of the command rn and one parameter.


addRequest

public void addRequest(int rn,
                       java.lang.Object p1,
                       java.lang.Object p2)
adds a request consisting of the command rn and two parameters.


addRequest

public void addRequest(int rn,
                       java.lang.Object p1,
                       java.lang.Object p2,
                       java.lang.Object p3)
adds a request consisting of the command rn and three parameters.


addRequest

public void addRequest(int rn,
                       java.lang.Object p1,
                       java.lang.Object p2,
                       java.lang.Object p3,
                       java.lang.Object p4)
adds a request consisting of the command rn and four parameters.


addRequest

public void addRequest(int rn,
                       java.lang.Object[] p)
adds a request consisting of the command rn and a parameter array.


getRequests

public java.util.List getRequests()
returns the complete request vector.


getFirstRequest

public ServerRequest getFirstRequest()
return the first request


removeFirstRequest

public ServerRequest removeFirstRequest()
Remove the first request from the request list and return it


setTarget

public void setTarget(int t)
set the target field (only used for connectionless connections)


getTarget

public int getTarget()
returns the target field


setSequence

public void setSequence(int s)
set the sequence field (only used for connectionless connections)


getSequence

public int getSequence()
returns the sequence field.


setSource

public void setSource(java.net.InetAddress src)
sets the source of this envelope. This feature is used by the server for connectionless connections. For one handler for this type of connections, the querying envelopes must all come from the same source. This is checked by comparing the content of this field which is set by the server internally.


getSource

public java.net.InetAddress getSource()
returns the stored source of this envelope.


removeRequests

public void removeRequests()
remove the complete request vector. Sets the internal field to null. This is done by the server before returning the envelope with the replies to the client.


removeReplies

public void removeReplies()
removes the reply vector.


toString

public java.lang.String toString()
converts the object to a String. Mainly for debugging purposes.


getSession

public int getSession()
Returns the session.

Returns:
int

setSession

public void setSession(int session)
Sets the session.

Parameters:
session - The session to set

QJCC homepage