Interface RPCImplementationBuilder<T>
- Type Parameters:
T- the type that is being implemented by the build process.
- All Superinterfaces:
RPCProvider.Builder<RPCImplementationBuilder<T>>
public interface RPCImplementationBuilder<T>
extends RPCProvider.Builder<RPCImplementationBuilder<T>>
A builder for an implementation of a class that will use RPC for all method calls.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn allocator for instances of generated rpc implementations. -
Method Summary
Modifier and TypeMethodDescriptionexcludeMethod(@NonNull String name, @NonNull TypeDescriptor methodDescriptor) Excludes the method in the target class that has the given name and method descriptor from being available for RPC execution.Generates an implementation of the target class and returns an allocator which can be used to construct an instance of the generated class.Enables that concrete methods (methods that are non-abstract and already have an implementation in the extending class or interfaces) should be implemented with RPC calls anyway.superclass(@NonNull Class<? super T> superclass) Sets the superclass to use for rpc executions.targetChannel(@NonNull NetworkChannel channel) Sets the singleton channel that will be used to send all RPCs to.targetChannel(@NonNull Supplier<NetworkChannel> channelSupplier) Sets the supplier to use to resolve the network channel to which RPCs should be sent.targetComponent(@NonNull NetworkComponent networkComponent) Sets the network component to use for obtaining the network channel to send RPCs to.Methods inherited from interface RPCProvider.Builder
dataBufFactory, objectMapper
-
Method Details
-
superclass
@NonNull @Contract("_ -> this") @NonNull RPCImplementationBuilder<T> superclass(@NonNull @NonNull Class<? super T> superclass) Sets the superclass to use for rpc executions. The given class must be the superclass of the actual target of this builder and will be used when invoking methods on the remote. Handlers on the remote must be bound to this class rather than the target class of this builder.- Parameters:
superclass- the actual superclass to use as the target for rpc invocations.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given superclass is null.IllegalArgumentException- if the given superclass is not assignable from the target of this builder.
-
targetComponent
@NonNull @Contract("_ -> this") @NonNull RPCImplementationBuilder<T> targetComponent(@NonNull @NonNull NetworkComponent networkComponent) Sets the network component to use for obtaining the network channel to send RPCs 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.- Parameters:
networkComponent- the network component to use the first channel of during RPC execution.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given network component is null.
-
targetChannel
@NonNull @Contract("_ -> this") @NonNull RPCImplementationBuilder<T> targetChannel(@NonNull @NonNull NetworkChannel channel) Sets the singleton channel that will be used to send all RPCs to. The target channel should not be closed while this sender is in use.- Parameters:
channel- the channel to which all RPCs that are using this sender are sent to.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given channel is null.IllegalArgumentException- if the given channel is closed.
-
targetChannel
@NonNull @Contract("_ -> this") @NonNull RPCImplementationBuilder<T> targetChannel(@NonNull @NonNull Supplier<NetworkChannel> channelSupplier) Sets the supplier to use to resolve the network channel to which RPCs 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.- Parameters:
channelSupplier- the supplier to call to obtain the target channel for RPCs.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given supplier is null.
-
implementConcreteMethods
Enables that concrete methods (methods that are non-abstract and already have an implementation in the extending class or interfaces) should be implemented with RPC calls anyway.- Returns:
- this builder, for chaining.
-
excludeMethod
@NonNull @Contract("_, _ -> this") @NonNull RPCImplementationBuilder<T> 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 available for RPC execution. It does not mean that the method will not be implemented in the generated class.- Parameters:
name- the name of the method to exclude.methodDescriptor- the descriptor of the method to exclude.- Returns:
- this builder, for chaining.
- Throws:
NullPointerException- if the given name or method descriptor is null.
-
generateImplementation
@NonNull @Contract("-> new") @NonNull RPCImplementationBuilder.InstanceAllocator<T> generateImplementation()Generates an implementation of the target class and returns an allocator which can be used to construct an instance of the generated class.- Returns:
- an allocator which can be used to construct an instance of the underlying class.
- Throws:
IllegalStateException- if one of the provided options is invalid.
-