Class DefaultRPCSender
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
eu.cloudnetservice.driver.network.rpc.defaults.sender.DefaultRPCSender
- All Implemented Interfaces:
RPCProvider,RPCSender
The default implementation of a rpc sender.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.github.benmanes.caffeine.cache.Cache<String,MethodInformation> protected static final Object[]protected final RPCFactoryprotected final NetworkComponentprotected final Class<?>Fields inherited from class eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
dataBufFactory, objectMapper -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCSender(@NonNull RPCFactory factory, @Nullable NetworkComponent component, @NonNull Class<?> targetClass, @NonNull ObjectMapper objectMapper, @NonNull DataBufFactory dataBufFactory) Constructs a new default rpc sender instance. -
Method Summary
Modifier and TypeMethodDescriptionGet the network component associated with this rpc sender.factory()Get the provider factory used to construct this rpc sender.invokeMethod(@NonNull String methodName) Creates a rpc to invoke the target method with no arguments, preventing a new object array allocation each time the method is invoked.invokeMethod(@NonNull String methodName, Object... args) Creates a rpc to invoke the target method with the given arguments.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
-
EMPTY_OBJECT_ARRAY
-
targetClass
-
factory
-
networkComponent
-
cachedMethodInformation
protected final com.github.benmanes.caffeine.cache.Cache<String,MethodInformation> cachedMethodInformation
-
-
Constructor Details
-
DefaultRPCSender
public DefaultRPCSender(@NonNull @NonNull RPCFactory factory, @Nullable @Nullable NetworkComponent component, @NonNull @NonNull Class<?> targetClass, @NonNull @NonNull ObjectMapper objectMapper, @NonNull @NonNull DataBufFactory dataBufFactory) Constructs a new default rpc sender instance.- Parameters:
factory- the factory used to create this instance.component- the network component which is associated with this component, might be null.targetClass- the target call for method invocations sent by this sender.objectMapper- the object mapper to use to write and read data from the buffers.dataBufFactory- the buffer factory used for buffer allocations.- Throws:
NullPointerException- if one of the required constructor parameters is null.
-
-
Method Details
-
factory
Get the provider factory used to construct this rpc sender. -
associatedComponent
Get the network component associated with this rpc sender.- Specified by:
associatedComponentin interfaceRPCSender- Returns:
- the network component associated with this rpc sender.
-
invokeMethod
Creates a rpc to invoke the target method with no arguments, preventing a new object array allocation each time the method is invoked. Equivalent tosender.invokeMethod(name, new Object[0]).- Specified by:
invokeMethodin interfaceRPCSender- Parameters:
methodName- the name of the method to invoke.- Returns:
- the rpc usable to fire the rpc request against the given method.
-
invokeMethod
Creates a rpc to invoke the target method with the given arguments. For this operation to succeed, the class must- contain a method which equals the given method name (case sensitive)
- that method must have the amount of arguments supplied via the arguments array.
- Specified by:
invokeMethodin interfaceRPCSender- Parameters:
methodName- the name of the method to invoke.args- the arguments to use for the method invocation.- Returns:
- the rpc usable to fire the rpc request against the given method.
-