Class ServiceManager

java.lang.Object
com.avrix.plugin.ServiceManager

public class ServiceManager extends Object
The service manager allows you to register services by their interfaces and access them
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    getService(Class<T> serviceInterface)
    Returns the registered service by its interface.
    static <T> void
    register(Class<T> serviceInterface, T serviceImplementation)
    Registers a service by its interface.
    static <T> void
    unregister(Class<T> serviceInterface)
    Removes a service from the list of registered ones

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ServiceManager

      public ServiceManager()
  • Method Details

    • register

      public static <T> void register(Class<T> serviceInterface, T serviceImplementation)
      Registers a service by its interface.
      Type Parameters:
      T - service type
      Parameters:
      serviceInterface - service interface
      serviceImplementation - service implementation
    • unregister

      public static <T> void unregister(Class<T> serviceInterface)
      Removes a service from the list of registered ones
      Type Parameters:
      T - service type
      Parameters:
      serviceInterface - service interface
    • getService

      public static <T> T getService(Class<T> serviceInterface)
      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