Package com.avrix.plugin
Class ServiceManager
java.lang.Object
com.avrix.plugin.ServiceManager
The service manager allows you to register services by their interfaces and access them
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
getService
(Class<T> serviceInterface) Returns the registered service by its interface.static <T> void
Registers a service by its interface.static <T> void
unregister
(Class<T> serviceInterface) Removes a service from the list of registered ones
-
Constructor Details
-
ServiceManager
public ServiceManager()
-
-
Method Details
-
register
Registers a service by its interface.- Type Parameters:
T
- service type- Parameters:
serviceInterface
- service interfaceserviceImplementation
- service implementation
-
unregister
Removes a service from the list of registered ones- Type Parameters:
T
- service type- Parameters:
serviceInterface
- service interface
-
getService
Returns the registered service by its interface.- Type Parameters:
T
- service type- Parameters:
serviceInterface
- service interface- Returns:
- an instance of the service corresponding to the specified interface, or
null
if the service is not found
-