Class Injectors


  • public class Injectors
    extends java.lang.Object
    Factory for CDI style Injectors.

    This mimics CDI style injection, which supports all features of Jakarta Inject, and additionally:

    • The Produces annotation on fields and methods
    • The Default annotation is added to sources when not annotated with any qualifiers or only annotated with Named and/or Any annotations
    • The Default annotation is added to targets when not annotated with any other qualifiers
    • The Any annotation is always added to all sources
    Not supported are:
    • Interceptors, Decorators and Events
    • Extensions via Jakarta Enterprise Inject SPI; instead use the provided SPI
    • Lifecycle management for sources created by producers
    There is partial support for:
    • The Instance extension of Provider
    Other differences:
    • Proxies are only available when the optional proxy extension is on the class path
    • Proxies are only created to resolve scope conflicts, but not to resolve circular dependencies
    • Exceptions thrown by the injector are of a different type with different messages
    • Sources can still be added and removed after initialization if so desired
    • Constructor Summary

      Constructors 
      Constructor Description
      Injectors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.int4.dirk.api.Injector autoDiscovering​(org.int4.dirk.spi.scope.ScopeResolver... scopeResolvers)
      Creates an Injector with auto discovery activated and the given ScopeResolvers.
      static org.int4.dirk.api.Injector manual​(org.int4.dirk.spi.scope.ScopeResolver... scopeResolvers)
      Creates an Injector which must be manually configured with the given ScopeResolvers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Injectors

        public Injectors()
    • Method Detail

      • autoDiscovering

        public static org.int4.dirk.api.Injector autoDiscovering​(org.int4.dirk.spi.scope.ScopeResolver... scopeResolvers)
        Creates an Injector with auto discovery activated and the given ScopeResolvers.
        Parameters:
        scopeResolvers - an optional array of ScopeResolvers
        Returns:
        an Injector, never null
      • manual

        public static org.int4.dirk.api.Injector manual​(org.int4.dirk.spi.scope.ScopeResolver... scopeResolvers)
        Creates an Injector which must be manually configured with the given ScopeResolvers.
        Parameters:
        scopeResolvers - an optional array of ScopeResolvers
        Returns:
        an Injector, never null