Class Injector

java.lang.Object
org.semanticweb.owlapi.utilities.Injector

public class Injector extends Object
Basic dependency injection utility, to replace the use of Guice and wrap calls to ServiceLoader.
  • Constructor Details

    • Injector

      public Injector()
      Default constructor
    • Injector

      public Injector(Injector i)
      Parameters:
      i - injector to copy
  • Method Details

    • bind

      public Injector bind(Class<?> t, Class<?> c, Annotation... annotations)
      Associate a key made of interface type and optional annotations with an implementation type
      Parameters:
      t - implementation type
      c - interface type
      annotations - annotations
      Returns:
      modified injector
    • bindToOne

      public Injector bindToOne(Object t, Class<?> c, Annotation... annotations)
      Associate a key made of interface type and optional annotations with an instance, replacing existing associations
      Parameters:
      t - instance
      c - interface type
      annotations - annotations
      Returns:
      modified injector
    • bindToOne

      public Injector bindToOne(Supplier<?> t, Class<?> c, Annotation... annotations)
      Associate a key made of interface type and optional annotations with a supplier of instances, replacing existing associations
      Parameters:
      t - supplier
      c - interface type
      annotations - annotations
      Returns:
      modified injector
    • bindOneMore

      public <T> Injector bindOneMore(T t, Class<T> c, Annotation... annotations)
      Associate a key made of interface type and optional annotations with an instance, adding to existing associations
      Type Parameters:
      T - type
      Parameters:
      t - instance
      c - interface type
      annotations - annotations
      Returns:
      modified injector
    • bindOneMore

      public <T> Injector bindOneMore(Supplier<T> t, Class<T> c, Annotation... annotations)
      Associate a key made of interface type and optional annotations with a supplier of instances, adding to existing associations
      Type Parameters:
      T - type
      Parameters:
      t - supplier
      c - interface type
      annotations - annotations
      Returns:
      modified injector
    • inject

      public <T> T inject(T t)
      Type Parameters:
      T - type
      Parameters:
      t - object to inject
      Returns:
      input object with all methods annotated with @Inject having been set with instances.
    • getImplementation

      public <T> T getImplementation(Class<T> c, Annotation... qualifiers)
      Type Parameters:
      T - type
      Parameters:
      c - class
      qualifiers - optional annotations
      Returns:
      instance
    • getImplementation

      public <T> T getImplementation(Class<T> c, OntologyConfigurator v, Annotation... qualifiers)
      Type Parameters:
      T - type
      Parameters:
      c - class
      v - configuration options
      qualifiers - optional annotations
      Returns:
      instance
    • getImplementation

      public <T> T getImplementation(Class<T> c, Map<Object,List<Supplier<?>>> overrides, Annotation... qualifiers)
      Type Parameters:
      T - type
      Parameters:
      c - class
      overrides - local overrides of existing bindings
      qualifiers - optional annotations
      Returns:
      instance