Class ServerEndpoint
- java.lang.Object
-
- de.gebit.integrity.remoting.transport.ServerEndpoint
-
public class ServerEndpoint extends Object
A server endpoint. This endpoint listens on a specified port and host IP for incoming connections from client endpoints. When a connection is established, it spawns a newEndpointfor that specific connection and continues listening for more connections.- Author:
- Rene Schneider - initial API and implementation
-
-
Constructor Summary
Constructors Constructor Description ServerEndpoint(String aHostIP, int aPort, Map<Class<? extends AbstractMessage>,MessageProcessor<?>> aProcessorMap, ClassLoader aClassLoader, boolean anIsForkFlag)Creates a new server endpoint that listens on a specified port/IP.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbroadcastMessage(AbstractMessage aMessage)Broadcasts a message to all active endpoints.voidcloseAll(boolean anEmptyOutputQueueFlag)Closes the server endpoint and all endpoints currently active.intgetPort()Returns the port number on which the server endpoint is listening.booleanisActive()
-
-
-
Constructor Detail
-
ServerEndpoint
public ServerEndpoint(String aHostIP, int aPort, Map<Class<? extends AbstractMessage>,MessageProcessor<?>> aProcessorMap, ClassLoader aClassLoader, boolean anIsForkFlag) throws UnknownHostException, IOException
Creates a new server endpoint that listens on a specified port/IP.- Parameters:
aHostIP- the host IP to listen onaPort- the port to bind to (0 = auto-choose a free port)aProcessorMap- the map of processors to use for processing incoming messagesaClassLoader- the classloader to use when deserializing objectsanIsForkFlag- whether this server endpoint is serving inside an Integrity fork process- Throws:
UnknownHostExceptionIOException
-
-
Method Detail
-
isActive
public boolean isActive()
-
getPort
public int getPort()
Returns the port number on which the server endpoint is listening.- Returns:
-
closeAll
public void closeAll(boolean anEmptyOutputQueueFlag)
Closes the server endpoint and all endpoints currently active.- Parameters:
anEmptyOutputQueueFlag- whether output queues to the endpoints shall be emptied before closing the connection.
-
broadcastMessage
public void broadcastMessage(AbstractMessage aMessage)
Broadcasts a message to all active endpoints.- Parameters:
aMessage- the message
-
-