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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the handler which is registered for the given target class or null if no handler for the class is registered.Get the handler which is registered for the given class by its name or null if no handler for the class is registered.booleanhasHandler(@NonNull Class<?> targetClass) Checks if this registry has a handler for the given target class.booleanhasHandler(@NonNull String targetClassName) Checks if this registry has a handler for the given target class name.Get all handlers which are registered to this registry.booleanregisterHandler(@NonNull RPCHandler rpcHandler) Registers the given handler to this registry, replacing the handler which was registered previously for the target class of the handler.booleanunregisterHandler(@NonNull RPCHandler rpcHandler) Unregisters the given rpc handler from this registry if previously registered.booleanunregisterHandler(@NonNull Class<?> rpcHandlerTargetClass) Unregisters the rpc handler associated with the given target class from this registry if registered previously.booleanunregisterHandler(@NonNull String rpcHandlerTargetClassName) Unregisters the rpc handler associated with the given target class name from this registry if registered previously.voidunregisterHandlers(@NonNull ClassLoader classLoader) Unregisters all rpc handlers from this registry whose classes were loaded by the given class loader.
-
Field Details
-
handlers
-
-
Constructor Details
-
DefaultRPCHandlerRegistry
public DefaultRPCHandlerRegistry()
-
-
Method Details
-
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:
registeredHandlersin interfaceRPCHandlerRegistry- Returns:
- all handlers which are registered to this registry.
-
hasHandler
Checks if this registry has a handler for the given target class.- Specified by:
hasHandlerin interfaceRPCHandlerRegistry- Parameters:
targetClass- the class to check for.- Returns:
- true if this registry has a handler for the given class, false otherwise.
-
hasHandler
Checks if this registry has a handler for the given target class name.- Specified by:
hasHandlerin interfaceRPCHandlerRegistry- 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
Get the handler which is registered for the given target class or null if no handler for the class is registered.- Specified by:
handlerin interfaceRPCHandlerRegistry- 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
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:
handlerin interfaceRPCHandlerRegistry- 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
Registers the given handler to this registry, replacing the handler which was registered previously for the target class of the handler.- Specified by:
registerHandlerin interfaceRPCHandlerRegistry- Parameters:
rpcHandler- the handler to register.- Returns:
- true if no handler was replaced to register the handler (clean insert), false otherwise.
-
unregisterHandler
Unregisters the given rpc handler from this registry if previously registered.- Specified by:
unregisterHandlerin interfaceRPCHandlerRegistry- Parameters:
rpcHandler- the handler to unregister.- Returns:
- true if the handler was removed from this registry, false otherwise.
-
unregisterHandler
Unregisters the rpc handler associated with the given target class from this registry if registered previously.- Specified by:
unregisterHandlerin interfaceRPCHandlerRegistry- Parameters:
rpcHandlerTargetClass- the class to unregister the rpc handler of.- Returns:
- true if the handler was removed from this registry, false otherwise.
-
unregisterHandler
Unregisters the rpc handler associated with the given target class name from this registry if registered previously.- Specified by:
unregisterHandlerin interfaceRPCHandlerRegistry- 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
Unregisters all rpc handlers from this registry whose classes were loaded by the given class loader.- Specified by:
unregisterHandlersin interfaceRPCHandlerRegistry- Parameters:
classLoader- the class loader to unregister the handlers based on.
-