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 an RPC sender.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.network.rpc.RPCProvider
RPCProvider.Builder<B extends RPCProvider.Builder<B>>Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.network.rpc.RPCSender
RPCSender.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Supplier<NetworkChannel> private final RPCClassMetadataprivate static final StackWalkerFields inherited from class eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
dataBufFactory, objectMapper, sourceFactory, targetClass -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCSender(@NonNull Class<?> targetClass, @NonNull RPCFactory sourceFactory, @NonNull ObjectMapper objectMapper, @NonNull DataBufFactory dataBufFactory, @NonNull RPCClassMetadata rpcTargetMeta, @NonNull Supplier<NetworkChannel> channelSupplier) Constructs a new default rpc sender instance. -
Method Summary
Modifier and TypeMethodDescriptioninvokeCaller(Object... args) Returns a new RPC that can invoke the calling method with the provided arguments.invokeCallerWithOffset(int callerStackOffset, Object... args) Returns a new RPC that can invoke the calling method with the provided arguments.invokeMethod(@NonNull RPCMethodMetadata method, Object... args) Creates a new RPC to call the given target method with the given arguments.invokeMethod(@NonNull String methodName, @NonNull TypeDescriptor methodDesc, Object... args) Returns a new RPC that can invoke the method with the given name and descriptor.invokeMethod(@NonNull String methodName, Object... args) Tries to resolve a distinct method with the given name and argument count in the target class and returns a new RPC that can invoke the resolved method with the provided arguments.Methods inherited from class eu.cloudnetservice.driver.network.rpc.defaults.DefaultRPCProvider
dataBufFactory, objectMapper, sourceFactory, 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, sourceFactory, targetClass
-
Field Details
-
STACK_WALKER
-
rpcTargetMeta
-
channelSupplier
-
-
Constructor Details
-
DefaultRPCSender
public DefaultRPCSender(@NonNull @NonNull Class<?> targetClass, @NonNull @NonNull RPCFactory sourceFactory, @NonNull @NonNull ObjectMapper objectMapper, @NonNull @NonNull DataBufFactory dataBufFactory, @NonNull @NonNull RPCClassMetadata rpcTargetMeta, @NonNull @NonNull Supplier<NetworkChannel> channelSupplier) Constructs a new default rpc sender instance.- Parameters:
targetClass- the class in which this sender can call methods.sourceFactory- the rpc factory that constructed this object.objectMapper- the object mapper to use to write and read data from the buffers.dataBufFactory- the buffer factory used for buffer allocations.rpcTargetMeta- the metadata of the target class handled by this sender.channelSupplier- the channel supplier for RPCs without a specified target channel.- Throws:
NullPointerException- if one of the given parameters is null.
-
-
Method Details
-
invokeCaller
Returns a new RPC that can invoke the calling method with the provided arguments.- Specified by:
invokeCallerin interfaceRPCSender- Parameters:
args- the arguments to supply when invoking the method.- Returns:
- an RPC that calls the caller method on a remote component with the provided arguments.
-
invokeCallerWithOffset
Returns a new RPC that can invoke the calling method with the provided arguments.- Specified by:
invokeCallerWithOffsetin interfaceRPCSender- Parameters:
callerStackOffset- the offset on the stack where the target method is located.args- the arguments to supply when invoking the method.- Returns:
- an RPC that calls the caller method on a remote component with the provided arguments.
-
invokeMethod
Tries to resolve a distinct method with the given name and argument count in the target class and returns a new RPC that can invoke the resolved method with the provided arguments.- Specified by:
invokeMethodin interfaceRPCSender- Parameters:
methodName- the name of the method to invoke.args- the arguments to supply when invoking the method.- Returns:
- an RPC to invoke the resolved method with the given name and parameter count on the remote.
-
invokeMethod
@NonNull public @NonNull RPC invokeMethod(@NonNull @NonNull String methodName, @NonNull @NonNull TypeDescriptor methodDesc, Object... args) Returns a new RPC that can invoke the method with the given name and descriptor.- Specified by:
invokeMethodin interfaceRPCSender- Parameters:
methodName- the name of the method to invoke.methodDesc- the descriptor of the method to invoke.args- the arguments to supply for the method invocation.- Returns:
- an RPC to invoke the resolved method with the given parameters on a remote.
-
invokeMethod
@NonNull private @NonNull RPC invokeMethod(@NonNull @NonNull RPCMethodMetadata method, Object... args) Creates a new RPC to call the given target method with the given arguments.- Parameters:
method- the metadata of the method that should be called.args- the arguments of to supply to the target method.- Returns:
- a new RPC instance targeting the given methods with the given arguments.
- Throws:
NullPointerException- if the given method metadata or argument array is null.IllegalArgumentException- if the parameter count mismatches.
-