com.retrogui.messageserver.server
Class MessageServer

java.lang.Object
  extended bycom.retrogui.messageserver.server.MessageServer
All Implemented Interfaces:
ISessionControl

public class MessageServer
extends java.lang.Object
implements ISessionControl

message server class


Field Summary
static int DEFAULT_MAX_CONNECTIONS
           
 
Constructor Summary
MessageServer(java.lang.String host, int port, AbstractServerApplicationFactory applicationFactory)
          Constructor
 
Method Summary
 int currentConnectionCount()
          Count of active connections obtained by counting all threads containing "InboundMessageHandler" Does not count open sockets and cannot tell if the client disconnected but the message handler was left as a zombie.
 java.util.Hashtable getApplications()
          Obtain a hashtable of all connected clients - each application is a DualRpcServerDispatcher object.
 IMessageEncoder getMessageEncoder()
           
 IMessageSerializer getMessageSerializer()
           
 boolean isSendAndReceiveMessages()
          getter
 void listen()
          Start the server.
 void setAcceptNewConnections(boolean isAcceptNewConnections)
          setter - true to accept new connections, false to reject.
 void setMaxConnections(int maxConnections)
           
 void setMessageEncoder(IMessageEncoder messageEncoder)
           
 void setMessageSerializer(IMessageSerializer messageSerializer)
           
 void setSendAndReceiveMessages(boolean isSendAndReceiveMessages)
          setter - set to false to prevent messages from being sent or received.
 void setSocketFactory(javax.net.ServerSocketFactory factory)
          setter for specifing alternate (SSL) socket factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_CONNECTIONS

public static final int DEFAULT_MAX_CONNECTIONS
See Also:
Constant Field Values
Constructor Detail

MessageServer

public MessageServer(java.lang.String host,
                     int port,
                     AbstractServerApplicationFactory applicationFactory)
Constructor

Parameters:
host -
port -
applicationFactory -
See Also:
Method Detail

listen

public void listen()
            throws java.net.UnknownHostException,
                   java.io.IOException
Start the server. Server listens on specified port for incoming connections. Set runtime parameters for optional arguments (max connections, etc) BEFORE calling listen().

Throws:
java.net.UnknownHostException
java.io.IOException
See Also:

currentConnectionCount

public int currentConnectionCount()
Count of active connections obtained by counting all threads containing "InboundMessageHandler" Does not count open sockets and cannot tell if the client disconnected but the message handler was left as a zombie.

Returns:
int

setSocketFactory

public void setSocketFactory(javax.net.ServerSocketFactory factory)
setter for specifing alternate (SSL) socket factory

Parameters:
factory -

setAcceptNewConnections

public void setAcceptNewConnections(boolean isAcceptNewConnections)
setter - true to accept new connections, false to reject. This is used to help conduct an orderly shutdown. To shutdown - set to reject connections, wait for a minute or so then kill the server.

Parameters:
isAcceptNewConnections -

setSendAndReceiveMessages

public void setSendAndReceiveMessages(boolean isSendAndReceiveMessages)
setter - set to false to prevent messages from being sent or received. Usually done prior to a shutdown. This flag controls whether the Session sendMessage() and getMessage() function and the flag does not cause the queues to stop. If this flag is set to false for long enough then the queues may grow excessively large.

Specified by:
setSendAndReceiveMessages in interface ISessionControl
Parameters:
isSendAndReceiveMessages -

isSendAndReceiveMessages

public boolean isSendAndReceiveMessages()
getter

Specified by:
isSendAndReceiveMessages in interface ISessionControl
Returns:

setMaxConnections

public void setMaxConnections(int maxConnections)

setMessageSerializer

public void setMessageSerializer(IMessageSerializer messageSerializer)
Parameters:
messageSerializer - The messageSerializer to set.

getMessageSerializer

public IMessageSerializer getMessageSerializer()
Specified by:
getMessageSerializer in interface ISessionControl
Returns:
Returns the messageSerializer.

setMessageEncoder

public void setMessageEncoder(IMessageEncoder messageEncoder)
Parameters:
messageEncoder - The messageEncoder to set.

getMessageEncoder

public IMessageEncoder getMessageEncoder()
Specified by:
getMessageEncoder in interface ISessionControl
Returns:
Returns the messageEncoder.

getApplications

public java.util.Hashtable getApplications()
Obtain a hashtable of all connected clients - each application is a DualRpcServerDispatcher object.

Returns:
Returns the applications.