Class DefaultRPCHandlerRegistry

java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.handler.DefaultRPCHandlerRegistry
All Implemented Interfaces:
RPCHandlerRegistry

@Singleton @Provides(RPCHandlerRegistry.class) public class DefaultRPCHandlerRegistry extends Object implements RPCHandlerRegistry
The default implementation of a rpc handler registry.
Since:
4.0
  • Field Details

  • Constructor Details

    • DefaultRPCHandlerRegistry

      public DefaultRPCHandlerRegistry()
  • Method Details

    • registeredHandlers

      @NonNull public @NonNull @UnmodifiableView Map<String,RPCHandler> registeredHandlers()
      Get all handlers which are registered to this registry. The keys of the map is the target class of the handler registered as its value.
      Specified by:
      registeredHandlers in interface RPCHandlerRegistry
      Returns:
      all handlers which are registered to this registry.
    • hasHandler

      public boolean hasHandler(@NonNull @NonNull Class<?> targetClass)
      Checks if this registry has a handler for the given target class. This method call should always be equivalent to registry.hasHandler(targetClass.getCanonicalName()).
      Specified by:
      hasHandler in interface RPCHandlerRegistry
      Parameters:
      targetClass - the class to check for.
      Returns:
      true if this registry has a handler for the given class, false otherwise.
    • hasHandler

      public boolean hasHandler(@NonNull @NonNull String targetClassName)
      Checks if this registry has a handler for the given target class name.
      Specified by:
      hasHandler in interface RPCHandlerRegistry
      Parameters:
      targetClassName - the name of the class to check for.
      Returns:
      true if this registry has a handler for the given target class, false otherwise.
    • handler

      @Nullable public @Nullable RPCHandler handler(@NonNull @NonNull Class<?> targetClass)
      Get the handler which is registered for the given target class or null if no handler for the class is registered. Equivalent to registry.handler(targetClass.getCanonicalName()).
      Specified by:
      handler in interface RPCHandlerRegistry
      Parameters:
      targetClass - the class to get the rpc handler for.
      Returns:
      the registered rpc handler for the class or null if no handler is registered.
    • handler

      @Nullable public @Nullable RPCHandler handler(@NonNull @NonNull String targetClassName)
      Get the handler which is registered for the given class by its name or null if no handler for the class is registered.
      Specified by:
      handler in interface RPCHandlerRegistry
      Parameters:
      targetClassName - the name of the class to get the handler for.
      Returns:
      the registered rpc handler for the class or null if no handler is registered.
    • registerHandler

      public boolean registerHandler(@NonNull @NonNull RPCHandler rpcHandler)
      Registers the given handler to this registry, replacing the handler which was registered previously for the target class of the handler.
      Specified by:
      registerHandler in interface RPCHandlerRegistry
      Parameters:
      rpcHandler - the handler to register.
      Returns:
      true if no handler was replaced to register the handler (clean insert), false otherwise.
    • unregisterHandler

      public boolean unregisterHandler(@NonNull @NonNull RPCHandler rpcHandler)
      Unregisters the given rpc handler from this registry if previously registered.
      Specified by:
      unregisterHandler in interface RPCHandlerRegistry
      Parameters:
      rpcHandler - the handler to unregister.
      Returns:
      true if the handler was removed from this registry, false otherwise.
    • unregisterHandler

      public boolean unregisterHandler(@NonNull @NonNull Class<?> rpcHandlerTargetClass)
      Unregisters the rpc handler associated with the given target class from this registry if registered previously. Equivalent to registry.unregisterHandler(rpcHandlerTargetClass.getCanonicalName()).
      Specified by:
      unregisterHandler in interface RPCHandlerRegistry
      Parameters:
      rpcHandlerTargetClass - the class to unregister the rpc handler of.
      Returns:
      true if the handler was removed from this registry, false otherwise.
    • unregisterHandler

      public boolean unregisterHandler(@NonNull @NonNull String rpcHandlerTargetClassName)
      Unregisters the rpc handler associated with the given target class name from this registry if registered previously.
      Specified by:
      unregisterHandler in interface RPCHandlerRegistry
      Parameters:
      rpcHandlerTargetClassName - the name of the class to unregister the rpc handler of.
      Returns:
      true if the handler was removed from this registry, false otherwise.
    • unregisterHandlers

      public void unregisterHandlers(@NonNull @NonNull ClassLoader classLoader)
      Unregisters all rpc handlers from this registry whose classes were loaded by the given class loader.
      Specified by:
      unregisterHandlers in interface RPCHandlerRegistry
      Parameters:
      classLoader - the class loader to unregister the handlers based on.