|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xsocket.stream.MultithreadedServer
public final class MultithreadedServer
Implementation of a multithreaded server. For more information see
IMultithreadedServer
Field Summary |
---|
Fields inherited from interface org.xsocket.stream.IMultithreadedServer |
---|
DEFAULT_CONNECTION_TIMEOUT_SEC, DEFAULT_IDLE_TIMEOUT_SEC, DEFAULT_RECEIVE_BUFFER_PREALLOCATION_SIZE, SO_RCVBUF, SO_REUSEADDR |
Constructor Summary | |
---|---|
MultithreadedServer(IHandler handler)
constructor The idle- and connection time out will be set with the default values. |
|
MultithreadedServer(IHandler handler,
java.util.concurrent.Executor workerpool)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.net.InetAddress address,
int port,
IHandler handler)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.net.InetAddress address,
int port,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.net.InetAddress address,
int port,
IHandler handler,
java.util.concurrent.Executor workerPool)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.net.InetAddress address,
int port,
java.util.Map<java.lang.String,java.lang.Object> options,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.net.InetAddress address,
int port,
java.util.Map<java.lang.String,java.lang.Object> options,
IHandler appHandler,
java.util.concurrent.Executor workerpool,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.net.InetAddress address,
int port,
StreamSocketConfiguration socketConfiguration,
IHandler handler)
Deprecated. |
|
MultithreadedServer(java.net.InetAddress address,
int port,
StreamSocketConfiguration socketConfiguration,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
Deprecated. |
|
MultithreadedServer(java.net.InetAddress address,
int port,
StreamSocketConfiguration socketConfiguration,
IHandler appHandler,
java.util.concurrent.Executor workerpool,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
Deprecated. |
|
MultithreadedServer(int port,
IHandler handler)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(int port,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(int port,
IHandler handler,
java.util.concurrent.Executor workerpool)
constructor For idle-, connection time out see MultithreadedServer(IHandler) |
|
MultithreadedServer(int port,
java.util.Map<java.lang.String,java.lang.Object> options,
IHandler handler)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(int port,
java.util.Map<java.lang.String,java.lang.Object> options,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(int port,
StreamSocketConfiguration socketConfiguration,
IHandler handler)
Deprecated. |
|
MultithreadedServer(int port,
StreamSocketConfiguration socketConfiguration,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
Deprecated. |
|
MultithreadedServer(java.util.Map<java.lang.String,java.lang.Object> options,
IHandler handler)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(StreamSocketConfiguration socketConfiguration,
IHandler handler)
Deprecated. |
|
MultithreadedServer(java.lang.String ipAddress,
int port,
IHandler handler)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.lang.String ipAddress,
int port,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.lang.String ipAddress,
int port,
java.util.Map<java.lang.String,java.lang.Object> options,
IHandler handler)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.lang.String ipAddress,
int port,
java.util.Map<java.lang.String,java.lang.Object> options,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
constructor For idle-, connection time out and the used workerpool see MultithreadedServer(IHandler) |
|
MultithreadedServer(java.lang.String ipAddress,
int port,
StreamSocketConfiguration socketConfiguration,
IHandler handler)
Deprecated. |
|
MultithreadedServer(java.lang.String ipAddress,
int port,
StreamSocketConfiguration socketConfiguration,
IHandler handler,
boolean sslOn,
javax.net.ssl.SSLContext sslContext)
Deprecated. |
Method Summary | |
---|---|
void |
addListener(IMutlithreadedServerListener listener)
adds a listener |
void |
close()
|
int |
getConnectionTimeoutSec()
gets the connection timeout |
int |
getDispatcherPoolSize()
Deprecated. |
int |
getIdleTimeoutSec()
returns the idle timeout in sec. |
java.net.InetAddress |
getLocalAddress()
get the local address |
int |
getLocalPort()
get the server port |
java.lang.Object |
getOption(java.lang.String name)
returns the vlaue of a option |
java.util.Map<java.lang.String,java.lang.Class> |
getOptions()
Returns an unmodifiable map of the options supported by this endpont. |
int |
getReceiveBufferPreallocationSize()
Deprecated. no replacement |
java.util.concurrent.Executor |
getWorkerpool()
return the worker pool |
IWorkerPool |
getWorkerPool()
Deprecated. use IMultithreadedServer.getWorkerpool() instead |
boolean |
isOpen()
signals, if service is running |
boolean |
removeListener(IMutlithreadedServerListener listener)
removes a listener |
void |
run()
|
void |
setConnectionTimeoutSec(int timeoutSec)
sets the max time for a connections. |
void |
setDispatcherPoolSize(int size)
Deprecated. |
void |
setHandler(IHandler appHandler)
set the handler. |
void |
setIdleTimeoutSec(int timeoutSec)
sets the idle timeout in sec |
void |
setReceiveBufferPreallocationSize(int size)
Deprecated. use System.property instead. see IoProvider |
void |
setWorkerPool(IWorkerPool newWorkerPool)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultithreadedServer(IHandler handler) throws java.net.UnknownHostException, java.io.IOException
Executors.newFixedThreadPool(int)
with 250 max threads will be created.
handler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.io.IOException
- If some other I/O error occurs
java.net.UnknownHostException
- if the locale host cannot determinedpublic MultithreadedServer(IHandler handler, java.util.concurrent.Executor workerpool) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
handler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)workerpool
- the workerpool to use. By setting the WorkerPool with null the worker pool will be deactivated. The callback handler will be
executed by the main dispatching thread. If the handler performs blocking operations, the disptaching will also be blocked!
java.io.IOException
- If some other I/O error occurs
java.net.UnknownHostException
- if the locale host cannot determinedpublic MultithreadedServer(StreamSocketConfiguration socketConfiguration, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(java.util.Map<java.lang.String,java.lang.Object> options, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
options
- the socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.io.IOException
- If some other I/O error occurs
java.net.UnknownHostException
- if the locale host cannot determinedpublic MultithreadedServer(int port, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
port
- the local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(int port, IHandler handler, java.util.concurrent.Executor workerpool) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
port
- the local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)workerpool
- the workerpool to use. By setting the WorkerPool with null the worker pool will be deactivated. The callback handler will be
executed by the main dispatching thread. If the handler performs blocking operations, the disptaching will also be blocked!
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(int port, StreamSocketConfiguration socketConfiguration, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(int port, java.util.Map<java.lang.String,java.lang.Object> options, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
port
- the local portoptions
- the acceptor socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.net.InetAddress address, int port, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
address
- the local addressport
- the local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.net.InetAddress address, int port, IHandler handler, java.util.concurrent.Executor workerPool) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
address
- the local addressport
- the local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)workerPool
- the workerpool
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.net.InetAddress address, int port, StreamSocketConfiguration socketConfiguration, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(java.lang.String ipAddress, int port, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
ipAddress
- the local ip addressport
- the local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.lang.String ipAddress, int port, StreamSocketConfiguration socketConfiguration, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(java.lang.String ipAddress, int port, java.util.Map<java.lang.String,java.lang.Object> options, IHandler handler) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
ipAddress
- the local ip addressport
- the local portoptions
- the socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(int port, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
port
- local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)sslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(int port, StreamSocketConfiguration socketConfiguration, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(int port, java.util.Map<java.lang.String,java.lang.Object> options, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
port
- local portoptions
- the acceptor socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IHandlerLifeCycleListener)sslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.lang.String ipAddress, int port, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
ipAddress
- local ip addressport
- local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IConnectionScoped, IHandlerLifeCycleListener)sslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.lang.String ipAddress, int port, StreamSocketConfiguration socketConfiguration, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(java.lang.String ipAddress, int port, java.util.Map<java.lang.String,java.lang.Object> options, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
ipAddress
- local ip addressport
- local portoptions
- the acceptor socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IConnectionScoped, IHandlerLifeCycleListener)sslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.net.InetAddress address, int port, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
address
- local addressport
- local porthandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IConnectionScoped, IHandlerLifeCycleListener)sslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.net.InetAddress address, int port, StreamSocketConfiguration socketConfiguration, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(java.net.InetAddress address, int port, java.util.Map<java.lang.String,java.lang.Object> options, IHandler handler, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
address
- local addressport
- local portoptions
- the socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IConnectionScoped, IHandlerLifeCycleListener)sslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occurspublic MultithreadedServer(java.net.InetAddress address, int port, StreamSocketConfiguration socketConfiguration, IHandler appHandler, java.util.concurrent.Executor workerpool, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public MultithreadedServer(java.net.InetAddress address, int port, java.util.Map<java.lang.String,java.lang.Object> options, IHandler appHandler, java.util.concurrent.Executor workerpool, boolean sslOn, javax.net.ssl.SSLContext sslContext) throws java.net.UnknownHostException, java.io.IOException
MultithreadedServer(IHandler)
address
- local addressport
- local portoptions
- the acceptor socket optionshandler
- the handler to use (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IConnectionScoped, IHandlerLifeCycleListener)workerpool
- the workerpool to usesslOn
- true, is SSL should be activatedsslContext
- the ssl context to use
java.net.UnknownHostException
- if the locale host cannot determined
java.io.IOException
- If some other I/O error occursMethod Detail |
---|
public final void run()
run
in interface java.lang.Runnable
public java.lang.Object getOption(java.lang.String name) throws java.io.IOException
getOption
in interface IMultithreadedServer
name
- the name of the option
java.io.IOException
- In an I/O error occurspublic java.util.Map<java.lang.String,java.lang.Class> getOptions()
getOptions
in interface IMultithreadedServer
public void close()
close
in interface java.io.Closeable
public void addListener(IMutlithreadedServerListener listener)
addListener
in interface IMultithreadedServer
listener
- gthe listener to addpublic boolean removeListener(IMutlithreadedServerListener listener)
removeListener
in interface IMultithreadedServer
listener
- the listener to remove
public IWorkerPool getWorkerPool()
IMultithreadedServer.getWorkerpool()
instead
getWorkerPool
in interface IMultithreadedServer
public java.util.concurrent.Executor getWorkerpool()
getWorkerpool
in interface IMultithreadedServer
public void setWorkerPool(IWorkerPool newWorkerPool)
null
the
worker pool will be deactivated. The callback handler will be executed by the main
dispatching thread. If the handler performs blocking operations, the disptaching will
also be blocked!
setWorkerPool
in interface IMultithreadedServer
newWorkerPool
- the worker pool to set or null
to deactivate the worker poolpublic final void setDispatcherPoolSize(int size)
setDispatcherPoolSize
in interface IMultithreadedServer
size
- the dispatcher pool sizepublic int getDispatcherPoolSize()
getDispatcherPoolSize
in interface IMultithreadedServer
public boolean isOpen()
isOpen
in interface IMultithreadedServer
public void setHandler(IHandler appHandler)
setHandler
in interface IMultithreadedServer
appHandler
- the handler. (supported: IConnectHandler, IDisconnectHandler, IDataHandler, ITimeoutHandler, IConnectionScoped, ILifeCycle)public final int getLocalPort()
getLocalPort
in interface IMultithreadedServer
public final java.net.InetAddress getLocalAddress()
getLocalAddress
in interface IMultithreadedServer
public final int getReceiveBufferPreallocationSize()
getReceiveBufferPreallocationSize
in interface IMultithreadedServer
public void setReceiveBufferPreallocationSize(int size)
IoProvider
setReceiveBufferPreallocationSize
in interface IMultithreadedServer
size
- preallocation buffer sizepublic void setConnectionTimeoutSec(int timeoutSec)
setConnectionTimeoutSec
in interface IMultithreadedServer
timeoutSec
- the connection timeout in secpublic void setIdleTimeoutSec(int timeoutSec)
setIdleTimeoutSec
in interface IMultithreadedServer
timeoutSec
- idle timeout in secpublic int getConnectionTimeoutSec()
getConnectionTimeoutSec
in interface IMultithreadedServer
public int getIdleTimeoutSec()
getIdleTimeoutSec
in interface IMultithreadedServer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |