Class DefaultRPCHandlerBuilder<T>
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.handler.DefaultRPCHandlerBuilder<T>
- Type Parameters:
T- the type that the handler is handling.
- All Implemented Interfaces:
RPCHandler.Builder<T>,RPCProvider.Builder<RPCHandler.Builder<T>>
The default implementation of an RPC handler builder.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Objectprivate final RPCClassMetadataprivate DataBufFactoryprivate ObjectMapperprivate final RPCFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCHandlerBuilder(@NonNull RPCFactory sourceFactory, @NonNull RPCClassMetadata classMetadata, @NonNull ObjectMapper objectMapper, @NonNull DataBufFactory dataBufFactory) 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()Builds a new RPC handler based on the options provided to this builder.dataBufFactory(@NonNull DataBufFactory dataBufFactory) Sets the data buf factory to use for everything that is related with data serialization in the final rpc provider.objectMapper(@NonNull ObjectMapper objectMapper) Sets the object mapper for serialization of objects during RPC execution related to the final rpc provider.targetInstance(@Nullable Object instance) Sets the target instance on which all incoming RPC calls should be executed.
-
Field Details
-
sourceFactory
-
classMetadata
-
boundInstance
-
objectMapper
-
dataBufFactory
-
-
Constructor Details
-
DefaultRPCHandlerBuilder
public DefaultRPCHandlerBuilder(@NonNull @NonNull RPCFactory sourceFactory, @NonNull @NonNull RPCClassMetadata classMetadata, @NonNull @NonNull ObjectMapper objectMapper, @NonNull @NonNull DataBufFactory dataBufFactory) 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.objectMapper- the default object mapper of the source RPC factory.dataBufFactory- the default data buf factory of the source RPC factory.- Throws:
NullPointerException- if one of the given parameters is null.
-
-
Method Details
-
targetInstance
Sets the target instance on which all incoming RPC calls should be executed. If the given instance is null, the invocation context must provide the instance to call the method on. If neither is present an exception is thrown during execution.- Specified by:
targetInstancein interfaceRPCHandler.Builder<T>- Parameters:
instance- the instance on which the target method should be called.- 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<T>- Parameters:
objectMapper- the object mapper to use.- Returns:
- this builder, for chaining.
-
dataBufFactory
@NonNull public RPCHandler.Builder<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.
-
build
Builds a new RPC handler based on the options provided to this builder.- Specified by:
buildin interfaceRPCHandler.Builder<T>- Returns:
- a new RPC handler for the given target class.
-