Class DefaultRPCInvocationContext

java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.handler.context.DefaultRPCInvocationContext
All Implemented Interfaces:
RPCInvocationContext

public class DefaultRPCInvocationContext extends Object implements RPCInvocationContext
The default implementation of a rpc invocation context.
Since:
4.0
  • Field Details

    • argumentCount

      protected final int argumentCount
    • expectsMethodResult

      protected final boolean expectsMethodResult
    • normalizePrimitives

      protected final boolean normalizePrimitives
    • strictInstanceUsage

      protected final boolean strictInstanceUsage
    • methodName

      protected final String methodName
    • channel

      protected final NetworkChannel channel
    • arguments

      protected final DataBuf arguments
    • workingInstance

      protected final Object workingInstance
  • Constructor Details

    • DefaultRPCInvocationContext

      protected DefaultRPCInvocationContext(int argumentCount, boolean expectsMethodResult, boolean normalizePrimitives, boolean strictInstanceUsage, @NonNull @NonNull String methodName, @NonNull @NonNull NetworkChannel channel, @NonNull @NonNull DataBuf arguments, @Nullable @Nullable Object workingInstance)
      Constructs a new default rpc invocation context instance.
      Parameters:
      argumentCount - the number of arguments the target method has.
      expectsMethodResult - if true the caller of the method expects a result being sent back to the sender.
      normalizePrimitives - if true primitive data types which are null will be normalized to their default value.
      strictInstanceUsage - if true the caller will not use any other instance than provided to this context.
      methodName - the name of the method to invoke.
      channel - the channel from which the invocation request came.
      arguments - the buffer containing the arguments for the method invocation.
      workingInstance - the instance to work with, null if no binding instance should be used.
      Throws:
      NullPointerException - if either the given method name, channel or argument buffer is null.
  • Method Details

    • argumentCount

      public int argumentCount()
      Get the amount of arguments the target method must have.
      Specified by:
      argumentCount in interface RPCInvocationContext
      Returns:
      the amount of arguments of the target method.
    • expectsMethodResult

      public boolean expectsMethodResult()
      Get if the rpc invocation expects a result sent back to the sender.
      Specified by:
      expectsMethodResult in interface RPCInvocationContext
      Returns:
      true if the rpc call expects a result, false otherwise.
    • normalizePrimitives

      public boolean normalizePrimitives()
      Get if primitive return values should be normalized when unprocessable due to for example null return values during a downstream method invocation.
      Specified by:
      normalizePrimitives in interface RPCInvocationContext
      Returns:
      true if primitives should be normalized, false otherwise.
    • strictInstanceUsage

      public boolean strictInstanceUsage()
      Get if the instance supplied to this context must be used or if the rpc handler is free to use the instance to which its bound.
      Specified by:
      strictInstanceUsage in interface RPCInvocationContext
      Returns:
      true if the instance usage during processing should be strict, false otherwise.
    • methodName

      @NonNull public @NonNull String methodName()
      Get the name of the method which should be invoked during the current rpc processing.
      Specified by:
      methodName in interface RPCInvocationContext
      Returns:
      the name of the method which should be invoked.
    • channel

      @NonNull public @NonNull NetworkChannel channel()
      Get the network channel from which the invocation request came.
      Specified by:
      channel in interface RPCInvocationContext
      Returns:
      the network channel from which the invocation request came.
    • argumentInformation

      @NonNull public @NonNull DataBuf argumentInformation()
      Get the data buffer slice which should contain the argument information for the current method invocation. The buffer might however also contain information for the next rpc calls in the chain (if any).
      Specified by:
      argumentInformation in interface RPCInvocationContext
      Returns:
      the data buffer which should contain the argument information for the current method invocation.
    • workingInstance

      @Nullable public @Nullable Object workingInstance()
      Get the instance (if any) which should be considered first for a method invocation. This is used for calling methods based on the result of the previous rpc in a chained rpc.
      Specified by:
      workingInstance in interface RPCInvocationContext
      Returns:
      the instance to use for calling the requested method (if any).