@DefaultImplementation(value=NetworkConnectionServiceImpl.class) public interface NetworkConnectionService extends AutoCloseable
NetworkConnectionService is a service which is designed for communicating messages with each other. It creates multiple ConnectionFactories, which create multiple connections.
Flow of message transfer:
connection.write(message) -> ConnectionFactory
-> src NetworkConnectionService (encode) -> dest NetworkConnectionService
.message -> dest NetworkConnectionService (decode) -> ConnectionFactory -> EventHandler
.Users can register a ConnectionFactory by registering their Codec, EventHandler, LinkListener and end point id. When users send messages via connections created by the ConnectionFactory,
NetworkConnectionService encodes the messages according to the Codec registered in the ConnectionFactory and sends them to the destination NetworkConnectionService.
Also, it receives the messages by decoding the messages and forwarding them to the corresponding EventHandler registered in the ConnectionFactory.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all resources and unregisters all registered connection factories.
|
<T> ConnectionFactory<T> |
getConnectionFactory(Identifier connectionFactoryId)
Gets an instance of ConnectionFactory which is registered by the registerConnectionFactory method.
|
<T> ConnectionFactory<T> |
registerConnectionFactory(Identifier connectionFactoryId,
Codec<T> codec,
EventHandler<Message<T>> eventHandler,
LinkListener<Message<T>> linkListener,
Identifier localEndPointId)
Registers an instance of ConnectionFactory corresponding to the connectionFactoryId.
|
void |
unregisterConnectionFactory(Identifier connectionFactoryId)
Unregisters a connectionFactory corresponding to the connectionFactoryId
and removes the localEndPointID of the connection factory from NameServer.
|
<T> ConnectionFactory<T> registerConnectionFactory(Identifier connectionFactoryId, Codec<T> codec, EventHandler<Message<T>> eventHandler, LinkListener<Message<T>> linkListener, Identifier localEndPointId)
connectionFactoryId
- a connection factory idcodec
- a codec for type TeventHandler
- an event handler for type TlinkListener
- a link listenerlocalEndPointId
- a local end point idvoid unregisterConnectionFactory(Identifier connectionFactoryId)
connectionFactoryId
- a connection factory id<T> ConnectionFactory<T> getConnectionFactory(Identifier connectionFactoryId)
connectionFactoryId
- a connection factory idvoid close() throws Exception
close
in interface AutoCloseable
Exception
- if this resource cannot be closedCopyright © 2017 The Apache Software Foundation. All rights reserved.