org.clazzes.remoting.server
Class Server
java.lang.Object
org.clazzes.remoting.server.Server
- All Implemented Interfaces:
- Broadcastable, InvocationTarget
public class Server
- extends java.lang.Object
- implements InvocationTarget
A remoting server, which listens on a TCP/IP port.
- Author:
- wglas
Constructor Summary |
Server(java.net.URI uri)
Construct a server, which will listen to the given URI. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Server
public Server(java.net.URI uri)
throws java.io.IOException
- Construct a server, which will listen to the given URI.
Please note, that any name resolution required will be performed by
listen()
.
The following default parameters will be set:
- Parameters:
uri
- An URI with a supported scheme. Currently, only the tcp
scheme is supported.
- Throws:
java.io.IOException
- If the URI has an unsupported scheme.
broadcast
public void broadcast(java.lang.String subSystem,
java.lang.Object arg,
java.util.Map<java.lang.String,java.lang.Object> metadata)
- Specified by:
broadcast
in interface Broadcastable
- Parameters:
subSystem
- The subsystem name to which a oneway invocation will be broadcasted.arg
- The argument to the broadcast.metadata
- Metadata to pass to the call.
getMarshalClassLoader
public java.lang.ClassLoader getMarshalClassLoader()
- Returns:
- The class loader used for resolving deserialized objects. If not
set via
setMarshalClassLoader(ClassLoader)
, the context class
loader of the current thread is used.
setMarshalClassLoader
public void setMarshalClassLoader(java.lang.ClassLoader classLoader)
- Parameters:
classLoader
- The custom class loader used for resolving deserialized objects.
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService()
- Returns:
- The executor service used to execute the asynchronous reader process.
If no set via
setExecutorService(ExecutorService)
, the result
of Executors.newCachedThreadPool()
is returned.
setExecutorService
public void setExecutorService(java.util.concurrent.ExecutorService executorService)
- Parameters:
executorService
- The executor service used to execute the asynchronous reader process.
getClientTerminationListener
public ClientTerminationListener getClientTerminationListener()
- Returns:
- The user-specified termination listener.
setClientTerminationListener
public void setClientTerminationListener(ClientTerminationListener clientTerminationListener)
- Parameters:
clientTerminationListener
- A user-specified listener, which is used
to inform about the termination of a client.
getMaxClients
public int getMaxClients()
- Returns:
- The maximal number of clients used to connect to this server.
setMaxClients
public void setMaxClients(int maxClients)
- Parameters:
maxClients
- The maximal number of clients to set.
getServerParameters
public ServerParameters getServerParameters()
- Returns:
- The server parameters used. If no set via
setServerParameters(ServerParameters)
,
a new instance of ServerParameters
or SSLServerParameters
is returned
depending on the scheme of the URI passed to the constructor.
setServerParameters
public void setServerParameters(ServerParameters serverParameters)
- Parameters:
serverParameters
- The server parameters to set.
listen
public void listen()
throws java.io.IOException
- Description copied from interface:
InvocationTarget
- Start listening for connections.
- Specified by:
listen
in interface InvocationTarget
- Throws:
java.io.IOException
- Upon errors from the network layer.
deregisterInvocationHandler
public void deregisterInvocationHandler(java.lang.String subSystem)
- Specified by:
deregisterInvocationHandler
in interface InvocationTarget
- Parameters:
subSystem
- The subsystem name of the handler being registered.
registerInvocationHandler
public void registerInvocationHandler(java.lang.String subSystem,
InvocationHandler handler)
- Specified by:
registerInvocationHandler
in interface InvocationTarget
- Parameters:
subSystem
- The name of the subsystem of the handler being registered.handler
- The handler being registered.
setInvocationHandlers
public void setInvocationHandlers(java.util.Map<java.lang.String,InvocationHandler> handlers)
- Specified by:
setInvocationHandlers
in interface InvocationTarget
shutdown
public void shutdown()
- Description copied from interface:
InvocationTarget
- Shut down all clients and prepare for dismantling the server.
- Specified by:
shutdown
in interface InvocationTarget
Copyright © 2010. All Rights Reserved.