Class InternalBabelChannelBuilder
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.AbstractBabelChannelBuilder<InternalBabelChannelBuilder>
pt.unl.fct.di.novasys.babel2.channels.internal.InternalBabelChannelBuilder
- All Implemented Interfaces:
BabelChannelBuilder
public final class InternalBabelChannelBuilder
extends AbstractBabelChannelBuilder<InternalBabelChannelBuilder>
BabelChannelBuilder that creates (and caches) a single
InternalBabelChannel instance.
Because the internal channel simulates in-JVM communication, all
protocols in the same process share the same channel instance. The first
call to build(Babel, NodeStore, BabelNode, BabelProtocol) allocates the channel; subsequent calls
return the same object.
Obtain an instance via InternalBabelChannel.builder().
-
Field Summary
Fields inherited from class AbstractBabelChannelBuilder
DEFAULT_NUMBER_OF_CONNECTIONS, DEFAULT_NUMBER_OF_MESSAGESModifier and TypeFieldDescriptionstatic final intDefault number of connections to expect when initializing the channel.static final intDefault number of message types expected by this channel. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol) Creates a newBabelChannelinstance, registering it with the givenruntimeand limiting its interest to the provided message types.Returns theInternalBabelChannelpreviously created bybuild(Babel, NodeStore, BabelNode, BabelProtocol).Methods inherited from class AbstractBabelChannelBuilder
getChannel, getNumberOfConnections, getNumberOfMessages, setChannel, setNumberOfConnections, setNumberOfMessages, validateStateOrThrowModifier and TypeMethodDescriptionprotected final @Nullable BabelChannelReturns the channel instance created by this builder, ornullif not yet built.protected final intGets the expected number of connections set in this builder.protected final intGets the expected number of messages set in this builder.protected final voidsetChannel(BabelChannel channel) Sets the constructed channel instance created by this builder.setNumberOfConnections(int numberOfConnections) Sets the default number of connections expected.setNumberOfMessages(int numberOfMessages) Sets the expected number of distinct message types handled by this channel.protected final voidValidates that this builder has not yet built its channel instance.
-
Constructor Details
-
InternalBabelChannelBuilder
public InternalBabelChannelBuilder()Constructs a newInternalBabelChannelBuilder.
-
-
Method Details
-
getCreatedInstance
Returns theInternalBabelChannelpreviously created bybuild(Babel, NodeStore, BabelNode, BabelProtocol).- Returns:
- the created channel
- Throws:
IllegalStateException- ifbuild(Babel, NodeStore, BabelNode, BabelProtocol)has not been called yet
-
build
public BabelChannel build(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol) Description copied from interface:BabelChannelBuilderCreates a newBabelChannelinstance, registering it with the givenruntimeand limiting its interest to the provided message types.- Parameters:
runtime- the owningBabelruntimestore- theNodeStorethat will be used by this channelidentity-BabelNodeobject used to represent this Babel instance to other instancesprotocol- the protocol instance associated with this channel- Returns:
- a ready-to-use
BabelChannel
-