Class DefaultRPCImplementationBuilder<T>
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.generation.DefaultRPCImplementationBuilder<T>
- Type Parameters:
T- the type that is being implemented.
- All Implemented Interfaces:
RPCImplementationBuilder<T>,RPCProvider.Builder<RPCImplementationBuilder<T>>
public final class DefaultRPCImplementationBuilder<T>
extends Object
implements RPCImplementationBuilder<T>
The default implementation of a rpc implementation builder.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordThe default implementation of an instance allocator using an internal instance factory as delegation.Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.network.rpc.factory.RPCImplementationBuilder
RPCImplementationBuilder.InstanceAllocator<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Supplier<NetworkChannel> private final RPCClassMetadataprivate DataBufFactoryprivate final RPCClassMetadataprivate final RPCGenerationCacheprivate intprivate ObjectMapperprivate Class<?> private final RPCFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCImplementationBuilder(@NonNull RPCFactory sourceFactory, @NonNull ObjectMapper objectMapper, @NonNull DataBufFactory dataBufFactory, @NonNull RPCClassMetadata classMetadata, @NonNull RPCGenerationCache generationCache) Constructs a new default implementation builder instance. -
Method Summary
Modifier and TypeMethodDescriptiondataBufFactory(@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 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.objectMapper(@NonNull ObjectMapper objectMapper) Sets the object mapper for serialization of objects during RPC execution related to the final rpc provider.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.
-
Field Details
-
sourceFactory
-
classMetadata
-
fullClasMetadata
-
generationCache
-
generationFlags
private int generationFlags -
objectMapper
-
senderTargetClass
-
dataBufFactory
-
channelSupplier
-
-
Constructor Details
-
DefaultRPCImplementationBuilder
public DefaultRPCImplementationBuilder(@NonNull @NonNull RPCFactory sourceFactory, @NonNull @NonNull ObjectMapper objectMapper, @NonNull @NonNull DataBufFactory dataBufFactory, @NonNull @NonNull RPCClassMetadata classMetadata, @NonNull @NonNull RPCGenerationCache generationCache) Constructs a new default implementation builder instance.- Parameters:
classMetadata- the metadata of class that is being implemented.generationCache- the cache for all generated implementations.- Throws:
NullPointerException- if the given class meta, sender builder or generation cache is null.
-
-
Method Details
-
superclass
@NonNull public @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.- Specified by:
superclassin interfaceRPCImplementationBuilder<T>- Parameters:
superclass- the actual superclass to use as the target for rpc invocations.- Returns:
- this builder, for chaining.
-
targetComponent
@NonNull public @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.- Specified by:
targetComponentin interfaceRPCImplementationBuilder<T>- Parameters:
networkComponent- the network component to use the first channel of during RPC execution.- Returns:
- this builder, for chaining.
-
targetChannel
@NonNull public @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.- Specified by:
targetChannelin interfaceRPCImplementationBuilder<T>- Parameters:
channel- the channel to which all RPCs that are using this sender are sent to.- Returns:
- this builder, for chaining.
-
targetChannel
@NonNull public @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.- Specified by:
targetChannelin interfaceRPCImplementationBuilder<T>- Parameters:
channelSupplier- the supplier to call to obtain the target channel for RPCs.- Returns:
- this builder, for chaining.
-
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.- Specified by:
implementConcreteMethodsin interfaceRPCImplementationBuilder<T>- Returns:
- this builder, for chaining.
-
excludeMethod
@NonNull public @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.- Specified by:
excludeMethodin interfaceRPCImplementationBuilder<T>- Parameters:
name- the name of the method to exclude.methodDescriptor- the descriptor of the method to exclude.- Returns:
- this builder, for chaining.
-
objectMapper
@NonNull public @NonNull RPCImplementationBuilder<T> objectMapper(@NonNull @NonNull ObjectMapper objectMapper) Sets the object mapper for serialization of objects during RPC execution related to the final rpc provider.- Specified by:
objectMapperin interfaceRPCProvider.Builder<T>- Parameters:
objectMapper- the object mapper to use.- Returns:
- this builder, for chaining.
-
dataBufFactory
@NonNull public @NonNull RPCImplementationBuilder<T> dataBufFactory(@NonNull @NonNull DataBufFactory 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<T>- Parameters:
dataBufFactory- the data buf factory to use.- Returns:
- this builder, for chaining.
-
generateImplementation
Generates an implementation of the target class and returns an allocator which can be used to construct an instance of the generated class.- Specified by:
generateImplementationin interfaceRPCImplementationBuilder<T>- Returns:
- an allocator which can be used to construct an instance of the underlying class.
-