Class Endpoint
java.lang.Object
de.gebit.integrity.remoting.transport.Endpoint
An endpoint is a client- or serverside termination point of a message channel. The endpoint uses a TCP connection to
transmit messages bidirectionally, with processors waiting for new messages to arrive.
- Author:
- Rene Schneider - initial API and implementation
-
Constructor Summary
ConstructorsConstructorDescriptionEndpoint(String aHost, int aPort, Map<Class<? extends AbstractMessage>, MessageProcessor<?>> aProcessorMap, EndpointListener aListener, ClassLoader aClassLoader) Creates a new endpoint and connects to a remote host, on which aServerEndpointis expected to run.Endpoint(Socket aSocket, Map<Class<? extends AbstractMessage>, MessageProcessor<?>> aProcessorMap, EndpointListener aListener, ClassLoader aClassLoader) Creates a new endpoint from a specific, already-connected socket. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(boolean anEmptyOutputQueueFlag) Close the connection.protected com.esotericsoftware.kryo.KryoInstantiates the Kryo serialization framework.booleanisActive()booleanvoidsendMessage(AbstractMessage aMessage) Sends a message.
-
Constructor Details
-
Endpoint
public Endpoint(Socket aSocket, Map<Class<? extends AbstractMessage>, MessageProcessor<?>> aProcessorMap, EndpointListener aListener, ClassLoader aClassLoader) Creates a new endpoint from a specific, already-connected socket.- Parameters:
aSocket- the connected socketaProcessorMap- the processorsaListener- the listeneraClassLoader- the classloader to use when deserializing objects
-
Endpoint
public Endpoint(String aHost, int aPort, Map<Class<? extends AbstractMessage>, MessageProcessor<?>> aProcessorMap, EndpointListener aListener, ClassLoader aClassLoader) throws UnknownHostException, IOExceptionCreates a new endpoint and connects to a remote host, on which aServerEndpointis expected to run.- Parameters:
aHost- the host name or IPaPort- the port to connect toaProcessorMap- the map of processorsaListener- the listeneraClassLoader- the classloader to use when deserializing objects- Throws:
UnknownHostExceptionIOException
-
-
Method Details
-
sendMessage
Sends a message. This queues the message into the outqueue, which is then emptied asynchronously by theoutputProcessor.- Parameters:
aMessage- the message to send
-
isActive
public boolean isActive() -
isDisconnectRequested
public boolean isDisconnectRequested() -
close
public void close(boolean anEmptyOutputQueueFlag) Close the connection.- Parameters:
anEmptyOutputQueueFlag- whether the output queue shall be sent to the other endpoint before closing
-
instantiateKryo
protected com.esotericsoftware.kryo.Kryo instantiateKryo()Instantiates the Kryo serialization framework.- Returns:
- an instantiated and fully configured
Kryoinstance
-