Class DefaultRPCSenderBuilder
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.sender.DefaultRPCSenderBuilder
- All Implemented Interfaces:
RPCProvider.Builder<RPCSender.Builder>,RPCSender.Builder
The default implementation of an RPC sender builder.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Supplier<NetworkChannel> private final RPCClassMetadataprivate DataBufFactoryprivate ObjectMapperprivate final RPCFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCSenderBuilder(@NonNull RPCFactory sourceFactory, @NonNull RPCClassMetadata classMetadata, @NonNull DataBufFactory dataBufFactory, @NonNull ObjectMapper objectMapper) Constructs a new builder instance for the target class (given by the class metadata) and the default data buf factory / object mapper from the source RPC factory. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Validates the options and target class provided to this builder and constructs the final sender instance in case everything checks out.dataBufFactory(@NonNull DataBufFactory dataBufFactory) Sets the data buf factory to use for everything that is related with data serialization in the final rpc provider.excludeMethod(@NonNull String name, @NonNull TypeDescriptor methodDescriptor) Excludes the method in the target class that has the given name and method descriptor from being discovered for RPC execution.objectMapper(@NonNull ObjectMapper objectMapper) Sets the object mapper for serialization of objects during RPC execution related to the final rpc provider.targetChannel(@NonNull NetworkChannel channel) Sets the singleton channel that will be used to send all RPCs that are using this sender to.targetChannel(@NonNull Supplier<NetworkChannel> channelSupplier) Sets the supplier to use to resolve the network channel to which RPCs using this sender should be sent.targetComponent(@NonNull NetworkComponent networkComponent) Sets the network component to use for obtaining the network channel to send RPCs using this sender to.
-
Field Details
-
sourceFactory
-
classMetadata
-
objectMapper
-
dataBufFactory
-
channelSupplier
-
-
Constructor Details
-
DefaultRPCSenderBuilder
public DefaultRPCSenderBuilder(@NonNull @NonNull RPCFactory sourceFactory, @NonNull @NonNull RPCClassMetadata classMetadata, @NonNull @NonNull DataBufFactory dataBufFactory, @NonNull @NonNull ObjectMapper objectMapper) Constructs a new builder instance for the target class (given by the class metadata) and the default data buf factory / object mapper from the source RPC factory.- Parameters:
sourceFactory- the rpc factory that constructed this object.classMetadata- the metadata for the target class.dataBufFactory- the default data buf factory of the source RPC factory.objectMapper- the default object mapper of the source RPC factory.- Throws:
NullPointerException- if the given class meta, data buf factory or object mapper is null.
-
-
Method Details
-
targetComponent
@NonNull public RPCSender.Builder targetComponent(@NonNull @NonNull NetworkComponent networkComponent) Sets the network component to use for obtaining the network channel to send RPCs using this sender to. For that purpose the first channel of the given component is always used. An exception during RPC execution will be thrown if the first channel of the component every becomes null or closed.- Specified by:
targetComponentin interfaceRPCSender.Builder- Parameters:
networkComponent- the network component to use the first channel of during RPC execution.- Returns:
- this builder, for chaining.
-
targetChannel
Sets the singleton channel that will be used to send all RPCs that are using this sender to. The target channel should not be closed while this sender is in use.- Specified by:
targetChannelin interfaceRPCSender.Builder- Parameters:
channel- the channel to which all RPCs that are using this sender are sent to.- Returns:
- this builder, for chaining.
-
targetChannel
@NonNull public RPCSender.Builder targetChannel(@NonNull @NonNull Supplier<NetworkChannel> channelSupplier) Sets the supplier to use to resolve the network channel to which RPCs using this sender should be sent. The given supplier is called every time the channel is needed, and is allowed to change over time. An exception during RPC execution will be thrown if this supplier ever returns null or a channel that is closed.- Specified by:
targetChannelin interfaceRPCSender.Builder- Parameters:
channelSupplier- the supplier to call to obtain the target channel for RPCs.- Returns:
- this builder, for chaining.
-
excludeMethod
@NonNull public RPCSender.Builder excludeMethod(@NonNull @NonNull String name, @NonNull @NonNull TypeDescriptor methodDescriptor) Excludes the method in the target class that has the given name and method descriptor from being discovered for RPC execution. The method will not be callable using the sender and will not be introspected during build.- Specified by:
excludeMethodin interfaceRPCSender.Builder- Parameters:
name- the name of the method to exclude.methodDescriptor- the descriptor of the method to exclude.- Returns:
- this builder, for chaining.
-
objectMapper
Sets the object mapper for serialization of objects during RPC execution related to the final rpc provider.- Specified by:
objectMapperin interfaceRPCProvider.Builder<RPCSender.Builder>- Parameters:
objectMapper- the object mapper to use.- Returns:
- this builder, for chaining.
-
dataBufFactory
Sets the data buf factory to use for everything that is related with data serialization in the final rpc provider.- Specified by:
dataBufFactoryin interfaceRPCProvider.Builder<RPCSender.Builder>- Parameters:
dataBufFactory- the data buf factory to use.- Returns:
- this builder, for chaining.
-
build
Validates the options and target class provided to this builder and constructs the final sender instance in case everything checks out.- Specified by:
buildin interfaceRPCSender.Builder- Returns:
- a new sender instance based on the options provided to this builder.
-