Class DefaultRPCHandler
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
eu.cloudnetservice.driver.network.rpc.defaults.handler.DefaultRPCHandler
- All Implemented Interfaces:
RPCHandler,RPCProvider
Represents the default implementation of a rpc handler.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.network.rpc.RPCHandler
RPCHandler.HandlingResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Class<?>protected final Objectprotected final MethodInvokerGeneratorprotected final com.github.benmanes.caffeine.cache.Cache<String,MethodInformation> Fields inherited from class eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
dataBufFactory, objectMapper, targetClass -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCHandler(@NonNull Class<?> clazz, @Nullable Object binding, @NonNull ObjectMapper objectMapper, @NonNull DataBufFactory dataBufFactory) Constructs a new default rpc handler instance. -
Method Summary
Modifier and TypeMethodDescriptionhandle(@NonNull RPCInvocationContext context) Handles the given rpc context using the information of this handler.voidregisterTo(@NonNull RPCHandlerRegistry registry) Registers this rpc handler to the given rpc handler registry.Methods inherited from class eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
dataBufFactory, objectMapper, targetClassMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.network.rpc.RPCProvider
dataBufFactory, objectMapper, targetClass
-
Field Details
-
bindingClass
-
bindingInstance
-
generator
-
methodCache
-
-
Constructor Details
-
DefaultRPCHandler
public DefaultRPCHandler(@NonNull @NonNull Class<?> clazz, @Nullable @Nullable Object binding, @NonNull @NonNull ObjectMapper objectMapper, @NonNull @NonNull DataBufFactory dataBufFactory) Constructs a new default rpc handler instance.- Parameters:
clazz- the raw clazz to which the handler is bound.binding- the instance to which the handler is bound, might be null if not needed.objectMapper- the object mapper used for reading / writing of arguments and return values.dataBufFactory- the data buf factory used to allocate response buffers.- Throws:
NullPointerException- if either the given class, object mapper or buffer factory is null.
-
-
Method Details
-
registerTo
Registers this rpc handler to the given rpc handler registry.- Specified by:
registerToin interfaceRPCHandler- Parameters:
registry- the registry to register to.
-
handle
@NonNull public @NonNull RPCHandler.HandlingResult handle(@NonNull @NonNull RPCInvocationContext context) Handles the given rpc context using the information of this handler. A handler must respect all settings set in the context. The handler decides whether it can handle the request based on the information provided through the context. If the instance use is set to strict in the context (or this handler has no instance set since construction) and no instance is provided through the context, the handler should return a successful result containing either null or the default primitive value based on the return value of the target method (if normalize primitives is set to true in the context). If an exception happens during the post of the rpc to the underlying method the result should be a failure containing as its result the thrown exception.- Specified by:
handlein interfaceRPCHandler- Parameters:
context- the context of the handler invocation.- Returns:
- the result of the handler execution.
-