Class ApplicationContext

java.lang.Object
io.gitbub.devlibx.easy.helper.ApplicationContext

public class ApplicationContext extends Object
  • Constructor Details

    • ApplicationContext

      public ApplicationContext()
  • Method Details

    • setInjector

      public static void setInjector(com.google.inject.Injector injector)
      Parameters:
      injector - singleton injector to be used for objects
    • getInstance

      public static <T> T getInstance(Class<T> cls)
      Type Parameters:
      T - type of class to request
      Parameters:
      cls - type of class to request
      Returns:
      instance of request type
    • getInstance

      public static <T> T getInstance(com.google.inject.Key<T> key)
      Type Parameters:
      T - type of class to request with help of key
      Parameters:
      key - type of class to request with help of key
      Returns:
      instance of request type
    • getOptionalInstance

      public static <T> Optional<T> getOptionalInstance(Class<T> cls)
      Type Parameters:
      T - type of class to request
      Parameters:
      cls - type of class to request
      Returns:
      instance of request type or Optional.empty() otherwise