Class RPCInternalInstanceFactory
java.lang.Object
eu.cloudnetservice.driver.impl.network.rpc.generation.RPCInternalInstanceFactory
- Direct Known Subclasses:
RPCInternalInstanceFactory.TempRPCInternalInstanceFactory
public sealed class RPCInternalInstanceFactory
extends Object
permits RPCInternalInstanceFactory.TempRPCInternalInstanceFactory
The internal instance factory for generated rpc api implementations. This class is only used within this package to
hide the actual work from the public-facing api.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA collection of special args that can be passed to a super constructor when invoking.(package private) static final classAn instance factory implementation that is temporarily not delegated (during class construction) to prevent issues with circular class references. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RPCInternalInstanceFactory[]private final Runnableprivate final MethodHandleprivate final eu.cloudnetservice.driver.network.rpc.RPCSender(package private) static final MethodType(package private) static final MethodTypeDescprivate final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateInternal constructor for TempRPCInternalInstanceFactory, do not use outside that implementation.privateRPCInternalInstanceFactory(int userArgCount, @NonNull Runnable allocationNotifier, @NonNull eu.cloudnetservice.driver.network.rpc.RPCSender fallbackClassRPCSender, @NonNull RPCInternalInstanceFactory[] additionalInstanceFactories, @NonNull MethodHandle constructorMethodHandle) Constructs a new internal instance factory. -
Method Summary
Modifier and TypeMethodDescriptionconstructInstance(@Nullable eu.cloudnetservice.driver.network.rpc.ChainableRPC baseRPC, @Nullable eu.cloudnetservice.driver.network.rpc.RPCSender classRPCSender, @NonNull Supplier<eu.cloudnetservice.driver.network.NetworkChannel> channelSupplier, @NonNull Object[] additionalConstructorArgs) Constructs a new instance of the generated rpc class.constructInstance(@Nullable eu.cloudnetservice.driver.network.rpc.ChainableRPC baseRPC, @NonNull Supplier<eu.cloudnetservice.driver.network.NetworkChannel> channelSupplier, @NonNull Object[] additionalConstructorArgs) Constructs a new instance of the generated rpc class.make(int userArgCount, MethodHandles.Lookup lookup, @NonNull Runnable allocationNotifier, @NonNull eu.cloudnetservice.driver.network.rpc.RPCSender classRPCSender, @NonNull RPCInternalInstanceFactory[] additionalInstanceFactories) Constructs a new internal instance factory for the generated rpc api implementation class.private voidreplaceSpecialArgs(Object[] args, @Nullable eu.cloudnetservice.driver.network.rpc.ChainableRPC baseRPC, @NonNull Supplier<eu.cloudnetservice.driver.network.NetworkChannel> channelSupplier) Replaces all requests for special arguments in the given target array.
-
Field Details
-
MT_BASIC_IMPLEMENTATION_CONSTRUCTOR
-
MTD_BASIC_IMPLEMENTATION_CONSTRUCTOR
-
allocationNotifier
-
userArgCount
private final int userArgCount -
fallbackClassRPCSender
private final eu.cloudnetservice.driver.network.rpc.RPCSender fallbackClassRPCSender -
additionalInstanceFactories
-
constructorMethodHandle
-
-
Constructor Details
-
RPCInternalInstanceFactory
private RPCInternalInstanceFactory()Internal constructor for TempRPCInternalInstanceFactory, do not use outside that implementation. -
RPCInternalInstanceFactory
private RPCInternalInstanceFactory(int userArgCount, @NonNull @NonNull Runnable allocationNotifier, @NonNull @NonNull eu.cloudnetservice.driver.network.rpc.RPCSender fallbackClassRPCSender, @NonNull @NonNull RPCInternalInstanceFactory[] additionalInstanceFactories, @NonNull @NonNull MethodHandle constructorMethodHandle) Constructs a new internal instance factory.- Parameters:
userArgCount- the count of arguments that are additionally supplied by the user.allocationNotifier- a runnable to run every time an instance of the class is allocated.fallbackClassRPCSender- the rpc sender instance to use for rpc lookups in the target class.additionalInstanceFactories- additional instance factories required for chained rpc constructions.constructorMethodHandle- the method handle for the constructor to invoke for construction requests.- Throws:
NullPointerException- if one of the given parameters is null.
-
-
Method Details
-
make
@NonNull public static @NonNull RPCInternalInstanceFactory make(int userArgCount, @NonNull MethodHandles.Lookup lookup, @NonNull @NonNull Runnable allocationNotifier, @NonNull @NonNull eu.cloudnetservice.driver.network.rpc.RPCSender classRPCSender, @NonNull @NonNull RPCInternalInstanceFactory[] additionalInstanceFactories) Constructs a new internal instance factory for the generated rpc api implementation class.- Parameters:
userArgCount- the count of arguments that are additionally supplied by the user.lookup- a lookup method handle targeting the generated implementation class.allocationNotifier- a runnable to run every time an instance of the class is allocated.classRPCSender- the rpc sender instance to use for rpc lookups in the target class.additionalInstanceFactories- additional instance factories required for chained rpc constructions.- Returns:
- a new internal instance factory to construct a generated api implementation.
- Throws:
NullPointerException- if one of the given parameters is null.IllegalStateException- if the target constructor is missing in the generated class.
-
constructInstance
@NonNull public @NonNull Object constructInstance(@Nullable @Nullable eu.cloudnetservice.driver.network.rpc.ChainableRPC baseRPC, @NonNull @NonNull Supplier<eu.cloudnetservice.driver.network.NetworkChannel> channelSupplier, @NonNull @NonNull Object[] additionalConstructorArgs) Constructs a new instance of the generated rpc class.- Parameters:
baseRPC- the base RPC to use for chained api calls.channelSupplier- the channel supplier to which all network requests should be sent.additionalConstructorArgs- the array of additional constructor args to supply to the generated class.- Returns:
- a constructed instance of the generated rpc class implementation.
- Throws:
NullPointerException- if the given channel supplier or additional args is null.IllegalArgumentException- if the given additional constructor args mismatch the expected count.IllegalStateException- if the construction of the generated class is not possible.
-
constructInstance
@NonNull public @NonNull Object constructInstance(@Nullable @Nullable eu.cloudnetservice.driver.network.rpc.ChainableRPC baseRPC, @Nullable @Nullable eu.cloudnetservice.driver.network.rpc.RPCSender classRPCSender, @NonNull @NonNull Supplier<eu.cloudnetservice.driver.network.NetworkChannel> channelSupplier, @NonNull @NonNull Object[] additionalConstructorArgs) Constructs a new instance of the generated rpc class.- Parameters:
baseRPC- the base RPC to use for chained api calls.classRPCSender- the rpc sender to use instead of the fallback one given to this factory.channelSupplier- the channel supplier to which all network requests should be sent.additionalConstructorArgs- the array of additional constructor args to supply to the generated class.- Returns:
- a constructed instance of the generated rpc class implementation.
- Throws:
NullPointerException- if the given channel supplier or additional args is null.IllegalArgumentException- if the given additional constructor args mismatch the expected count.IllegalStateException- if the construction of the generated class is not possible.
-
replaceSpecialArgs
private void replaceSpecialArgs(Object[] args, @Nullable @Nullable eu.cloudnetservice.driver.network.rpc.ChainableRPC baseRPC, @NonNull @NonNull Supplier<eu.cloudnetservice.driver.network.NetworkChannel> channelSupplier) Replaces all requests for special arguments in the given target array.- Parameters:
args- the argument to array to replace the special values in.baseRPC- the base RPC to use for chained api calls.channelSupplier- the channel supplier to which all network requests should be sent.- Throws:
NullPointerException- if the given args array or base rpc is null.
-