Class Globals


  • @Service(name="globals")
    @Singleton
    public class Globals
    extends Object
    Global class for storing the service locator for all hk2 services

    Very sensitive class, anything stored here cannot be garbage collected

    Author:
    Jerome Dochez
    • Method Detail

      • getDefaultBaseServiceLocator

        public static org.glassfish.hk2.api.ServiceLocator getDefaultBaseServiceLocator()
        Gets the default service locator

        This method is identical to getDefaultBaseServiceLocator()

        Returns:
      • getDefaultHabitat

        public static org.glassfish.hk2.api.ServiceLocator getDefaultHabitat()
        Gets the default service locator

        This method is identical to getDefaultBaseServiceLocator()

        Returns:
      • get

        public static <T> T get​(Class<T> type)
        Gets the service from the default service locator with the specified type

        See ServiceLocator.getService(java.lang.Class, java.lang.annotation.Annotation...)

        Type Parameters:
        T -
        Parameters:
        type -
        Returns:
      • setDefaultHabitat

        public static void setDefaultHabitat​(org.glassfish.hk2.api.ServiceLocator habitat)
        Sets the default service locator to a different one
        Parameters:
        habitat -
      • getStaticBaseServiceLocator

        public static org.glassfish.hk2.api.ServiceLocator getStaticBaseServiceLocator()
        Returns the default service locator. If it does not exist, one will be created.

        See getStaticHabitat()

        Returns:
      • getStaticHabitat

        public static org.glassfish.hk2.api.ServiceLocator getStaticHabitat()
        Returns the default service locator. If it does not exist, one will be created.
        Returns: