Class MikronContext

java.lang.Object
net.reevik.mikron.ioc.MikronContext
All Implemented Interfaces:
AutoCloseable

public class MikronContext extends Object implements AutoCloseable
Mikron context is the inversion-of-control container, which control the life-cycle of the mikron managed instances. MikronContext instance is managed itself, even though it's not annotated with Managed so it can be injected in your application code.
Author:
Erhan Bagdemir
  • Method Details

    • init

      public static MikronContext init(Class<?> clazz)
    • register

      public void register(Object instance, String name)
      Registers a new managed instance explicitly, which makes the context rescan the packages so that the new managed instance can be wired.

      Parameters:
      instance - Which is registered manually in the current context.
      name - The managedInstanceName of the managed instance.
    • getManagedInstances

      public Map<String,ManagedInstance> getManagedInstances()
    • getInstance

      public <T> Optional<T> getInstance(String name)
    • getPropertiesRepository

      public PropertiesRepository getPropertiesRepository()
    • getConfiguration

      public Optional<Properties> getConfiguration(String configurationSourceKey)
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • findImplementingManagedInstances

      public Set<Class<?>> findImplementingManagedInstances(Class<?> parentType)
      Find and return the implementing managed instances.
      Parameters:
      parentType - Parent type, e.g., an interface declaring a concrete managed instance.
      Returns:
      All implementing concrete managed instances.