| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.xsocket.connection.Server
public class Server
Implementation of a server. For more information see
 IServer
| Field Summary | |
|---|---|
| protected static int | MIN_SIZE_WORKER_POOL | 
| protected static int | SIZE_WORKER_POOL | 
| protected static int | TASK_QUEUE_SIZE | 
| Fields inherited from interface org.xsocket.connection.IServer | 
|---|
| DEFAULT_CONNECTION_TIMEOUT_SEC, DEFAULT_IDLE_TIMEOUT_SEC, DEFAULT_READ_TRANSFER_PREALLOCATION_MIN_SIZE, DEFAULT_READ_TRANSFER_PREALLOCATION_SIZE, DEFAULT_READ_TRANSFER_USE_DIRECT, SO_RCVBUF, SO_REUSEADDR | 
| Constructor Summary | |
|---|---|
|   | Server(IHandler handler)constructor | 
|   | Server(InetAddress address,
       int port,
       IHandler handler)constructor | 
|   | Server(InetAddress address,
       int port,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn)constructor | 
|   | Server(InetAddress address,
       int port,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn)constructor | 
|   | Server(InetAddress address,
       int port,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn,
       int backlog)constructor | 
|   | Server(InetAddress address,
       int port,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn,
       int backlog,
       int minPoolsize,
       int maxPoolsize)constructor | 
| protected  | Server(InetSocketAddress address,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn,
       int backlog)constructor | 
| protected  | Server(InetSocketAddress address,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn,
       int backlog,
       int minPoolsize,
       int maxPoolsize)constructor | 
| protected  | Server(InetSocketAddress address,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn,
       int backlog,
       int minPoolsize,
       int maxPoolsize,
       int taskqueueSize)constructor | 
|   | Server(int port,
       IHandler handler)constructor | 
|   | Server(int port,
       IHandler handler,
       int backlog)constructor | 
|   | Server(int port,
       IHandler handler,
       int minPoolsize,
       int maxPoolsize)constructor | 
|   | Server(int port,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn)constructor | 
|   | Server(int port,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn,
       int minPoolsize,
       int maxPoolsize)constructor | 
|   | Server(int port,
       Map<String,Object> options,
       IHandler handler)constructor | 
|   | Server(int port,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn)constructor | 
|   | Server(Map<String,Object> options,
       IHandler handler)constructor | 
|   | Server(String ipAddress,
       int port,
       IHandler handler)constructor | 
|   | Server(String ipAddress,
       int port,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn)constructor | 
|   | Server(String ipAddress,
       int port,
       Map<String,Object> options,
       IHandler handler)constructor | 
|   | Server(String ipAddress,
       int port,
       Map<String,Object> options,
       IHandler handler,
       SSLContext sslContext,
       boolean sslOn)constructor | 
| Method Summary | |
|---|---|
|  void | addListener(IServerListener listener)adds a listener | 
|  void | close() | 
|  boolean | getAutoflush()get autoflush. | 
|  long | getConnectionTimeoutMillis()gets the connection timeout | 
|  IConnection.FlushMode | getFlushmode()return the flush mode for new connections | 
|  IHandler | getHandler()gets the handler | 
|  long | getIdleTimeoutMillis()returns the idle timeout in millis. | 
|  String | getImplementationDate()returns the implementation date | 
|  String | getImplementationVersion()returns the implementation version | 
|  InetAddress | getLocalAddress()get the local address | 
|  int | getLocalPort()get the server port | 
|  Set<INonBlockingConnection> | getOpenConnections() | 
|  Object | getOption(String name)returns the vlaue of a option | 
|  Map<String,Class> | getOptions()Returns an unmodifiable map of the options supported by this endpont. | 
|  String | getServerName()return the server name | 
|  String | getStartUpLogMessage()returns the startUp log message | 
|  Executor | getWorkerpool()return the worker pool | 
|  boolean | isOpen()signals, if service is running | 
| protected  void | onClosed() | 
| protected  void | onPreRejectConnection(NonBlockingConnection connection) | 
|  boolean | removeListener(IServerListener listener)removes a listener | 
|  void | run() | 
|  void | setAutoflush(boolean autoflush)set autoflush for new connections. | 
|  void | setConnectionTimeoutMillis(long timeoutMillis)sets the max time for a connections. | 
|  void | setFlushmode(IConnection.FlushMode flusmode)sets the flush mode for new connections. | 
|  void | setHandler(IHandler handler)set the handler | 
|  void | setIdleTimeoutMillis(long timeoutMillis)sets the idle timeout in millis | 
|  void | setMaxConcurrentConnections(int maxConcurrentConnections)sets the max number of concurrent connections | 
|  void | setMaxReadBufferThreshold(int maxSize)set the max app read buffer threshold | 
|  void | setServerName(String name)the the server name. | 
|  void | setStartUpLogMessage(String message)set the log message, which will be printed out during the start up | 
|  void | setWorkerpool(Executor executor)sets the worker pool | 
|  void | setWriteTransferRate(int bytesPerSecond)set the send delay time for a connection. | 
|  void | start()starts the given server within a dedicated thread. | 
|  String | toString() | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected static final int SIZE_WORKER_POOL
protected static final int MIN_SIZE_WORKER_POOL
protected static final int TASK_QUEUE_SIZE
| Constructor Detail | 
|---|
public Server(IHandler handler)
       throws UnknownHostException,
              IOException
handler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
IOException - If some other I/O error occurs
UnknownHostException - if the local host cannot determined
public Server(Map<String,Object> options,
              IHandler handler)
       throws UnknownHostException,
              IOException
options - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
IOException - If some other I/O error occurs
UnknownHostException - if the local host cannot determined
public Server(int port,
              IHandler handler)
       throws UnknownHostException,
              IOException
port - the local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(int port,
              IHandler handler,
              int minPoolsize,
              int maxPoolsize)
       throws UnknownHostException,
              IOException
port - the local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)minPoolsize - the min workerpool sizemaxPoolsize - the max workerpool size
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(int port,
              IHandler handler,
              int backlog)
       throws UnknownHostException,
              IOException
port - the local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)backlog - The maximum number number of pending connections. If has the value 0, or a negative value, then an implementation specific default is used.
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(int port,
              Map<String,Object> options,
              IHandler handler)
       throws UnknownHostException,
              IOException
port - the local portoptions - the acceptor socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(InetAddress address,
              int port,
              IHandler handler)
       throws UnknownHostException,
              IOException
address - the local addressport - the local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(String ipAddress,
              int port,
              IHandler handler)
       throws UnknownHostException,
              IOException
ipAddress - the local ip addressport - the local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(String ipAddress,
              int port,
              Map<String,Object> options,
              IHandler handler)
       throws UnknownHostException,
              IOException
ipAddress - the local ip addressport - the local portoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(int port,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn)
       throws UnknownHostException,
              IOException
port - local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to use
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(int port,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn,
              int minPoolsize,
              int maxPoolsize)
       throws UnknownHostException,
              IOException
port - local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to useminPoolsize - the min workerpool sizemaxPoolsize - the max workerpool size
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(int port,
              Map<String,Object> options,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn)
       throws UnknownHostException,
              IOException
port - local portoptions - the acceptor socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to use
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(String ipAddress,
              int port,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn)
       throws UnknownHostException,
              IOException
ipAddress - local ip addressport - local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to use
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(String ipAddress,
              int port,
              Map<String,Object> options,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn)
       throws UnknownHostException,
              IOException
ipAddress - local ip addressport - local portoptions - the acceptor socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to use
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(InetAddress address,
              int port,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn)
       throws UnknownHostException,
              IOException
address - local addressport - local porthandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to use
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(InetAddress address,
              int port,
              Map<String,Object> options,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn)
       throws UnknownHostException,
              IOException
address - local addressport - local portoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to use
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(InetAddress address,
              int port,
              Map<String,Object> options,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn,
              int backlog)
       throws UnknownHostException,
              IOException
address - local addressport - local portoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to usebacklog - The maximum number number of pending connections. If has the value 0, or a negative value, then an implementation specific default is used.
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
public Server(InetAddress address,
              int port,
              Map<String,Object> options,
              IHandler handler,
              SSLContext sslContext,
              boolean sslOn,
              int backlog,
              int minPoolsize,
              int maxPoolsize)
       throws UnknownHostException,
              IOException
address - local addressport - local portoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to usebacklog - The maximum number number of pending connections. If has the value 0, or a negative value, then an implementation specific default is used.minPoolsize - The min workerpool sizemaxPoolsize - The max workerpool size
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
protected Server(InetSocketAddress address,
                 Map<String,Object> options,
                 IHandler handler,
                 SSLContext sslContext,
                 boolean sslOn,
                 int backlog)
          throws UnknownHostException,
                 IOException
address - local addressoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to usebacklog - The maximum number number of pending connections. If has the value 0, or a negative value, then an implementation specific default is used.
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
protected Server(InetSocketAddress address,
                 Map<String,Object> options,
                 IHandler handler,
                 SSLContext sslContext,
                 boolean sslOn,
                 int backlog,
                 int minPoolsize,
                 int maxPoolsize)
          throws UnknownHostException,
                 IOException
address - local addressoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to usebacklog - The maximum number number of pending connections. If has the value 0, or a negative value, then an implementation specific default is used.minPoolsize - The min workerpool sizemaxPoolsize - The max workerpool size
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs
protected Server(InetSocketAddress address,
                 Map<String,Object> options,
                 IHandler handler,
                 SSLContext sslContext,
                 boolean sslOn,
                 int backlog,
                 int minPoolsize,
                 int maxPoolsize,
                 int taskqueueSize)
          throws UnknownHostException,
                 IOException
address - local addressoptions - the socket optionshandler - the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, IIdleTimeoutHandler, IConnectionTimeoutHandler, IConnectionScoped, ILifeCycle)sslOn - true, is SSL should be activatedsslContext - the ssl context to usebacklog - The maximum number number of pending connections. If has the value 0, or a negative value, then an implementation specific default is used.minPoolsize - The min workerpool sizemaxPoolsize - The max workerpool sizetaskqueueSize - The taskqueue size
UnknownHostException - if the local host cannot determined
IOException - If some other I/O error occurs| Method Detail | 
|---|
public void setHandler(IHandler handler)
handler - the handlerpublic final void setServerName(String name)
   IServer cacheServer = new Server(port, new CacheHandler());
   ConnectionUtils.start(server);
   server.setServerName("CacheServer");
   // prints out
   // 01::52::42,756 10 INFO [Server$AcceptorCallback#onConnected] CacheServer listening on 172.25.34.33/172.25.34.33:9921 (xSocket 2.0)
 
name - the server namepublic final String getServerName()
public String getStartUpLogMessage()
getStartUpLogMessage in interface IServerpublic void setStartUpLogMessage(String message)
setStartUpLogMessage in interface IServermessage - the startUp log messagepublic void run()
run in interface Runnable
public void start()
           throws IOException
ConnectionUtils.start(IServer)
start in interface IServerSocketTimeoutException - is the timeout has been reached
IOException
public final Object getOption(String name)
                       throws IOException
getOption in interface IServername - the name of the option
IOException - In an I/O error occurspublic IHandler getHandler()
IServer
getHandler in interface IServerpublic final Map<String,Class> getOptions()
getOptions in interface IServerpublic final void close()
close in interface Closeable
protected void onClosed()
                 throws IOException
IOException
protected void onPreRejectConnection(NonBlockingConnection connection)
                              throws IOException
IOExceptionpublic final void addListener(IServerListener listener)
addListener in interface IServerlistener - gthe listener to addpublic final boolean removeListener(IServerListener listener)
removeListener in interface IServerlistener - the listener to remove
public final Executor getWorkerpool()
getWorkerpool in interface IServerpublic final void setWorkerpool(Executor executor)
setWorkerpool in interface IServerexecutor - the workerpoolpublic final boolean isOpen()
isOpen in interface IServerpublic final void setMaxConcurrentConnections(int maxConcurrentConnections)
maxConcurrentConnections - the max number of concurrent connectionspublic void setMaxReadBufferThreshold(int maxSize)
maxSize - the max read buffer thresholdpublic final int getLocalPort()
getLocalPort in interface IServerpublic final InetAddress getLocalAddress()
getLocalAddress in interface IServerpublic Set<INonBlockingConnection> getOpenConnections()
public final IConnection.FlushMode getFlushmode()
getFlushmode in interface IServerpublic final void setFlushmode(IConnection.FlushMode flusmode)
INonBlockingConnection#setFlushmode(FlushMode) 
 for more information
setFlushmode in interface IServerflusmode - the flush modepublic final void setAutoflush(boolean autoflush)
IReadWriteableConnection#setAutoflush(boolean) 
 for more information
setAutoflush in interface IServerautoflush - true if autoflush should be activatedpublic final boolean getAutoflush()
IReadWriteableConnection#setAutoflush(boolean) 
 for more information
getAutoflush in interface IServerpublic final void setConnectionTimeoutMillis(long timeoutMillis)
setConnectionTimeoutMillis in interface IServer
public void setWriteTransferRate(int bytesPerSecond)
                          throws IOException
INonBlockingConnection#setFlushmode(org.xsocket.connection.IConnection.FlushMode))
setWriteTransferRate in interface IServerbytesPerSecond - the transfer rate of the outgoing data
IOException - If some other I/O error occurspublic void setIdleTimeoutMillis(long timeoutMillis)
setIdleTimeoutMillis in interface IServerpublic final long getConnectionTimeoutMillis()
getConnectionTimeoutMillis in interface IServerpublic final long getIdleTimeoutMillis()
getIdleTimeoutMillis in interface IServerpublic String getImplementationVersion()
public String getImplementationDate()
public String toString()
toString in class Object| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||