Class AbstractInjector<T>

    • Field Detail

      • verifyingGuard

        protected transient org.picocontainer.injectors.AbstractInjector.ThreadLocalCyclicDependencyGuard verifyingGuard
        The cycle guard for the verification.
      • parameters

        protected transient Parameter[] parameters
        The parameters to use for initialization.
    • Constructor Detail

      • AbstractInjector

        protected AbstractInjector​(Object componentKey,
                                   Class<?> componentImplementation,
                                   Parameter[] parameters,
                                   ComponentMonitor monitor,
                                   boolean useNames)
        Constructs a new ComponentAdapter for the given key and implementation.
        Parameters:
        componentKey - the search key for this implementation
        componentImplementation - the concrete implementation
        parameters - the parameters to use for the initialization
        monitor - the component monitor used by this ComponentAdapter
        Throws:
        AbstractInjector.NotConcreteRegistrationException - if the implementation is not a concrete class
        NullPointerException - if one of the parameters is null
    • Method Detail

      • useNames

        public boolean useNames()
      • createDefaultParameters

        protected Parameter[] createDefaultParameters​(int length)
        Create default parameters for the given types.
        Parameters:
        length - parameter list length
        Returns:
        the array with the default parameters.
      • verify

        public void verify​(PicoContainer container)
                    throws PicoCompositionException
        Description copied from interface: ComponentAdapter
        Verify that all dependencies for this adapter can be satisfied. Normally, the adapter should verify this by checking that the associated PicoContainer contains all the needed dependencies.
        Specified by:
        verify in interface ComponentAdapter<T>
        Parameters:
        container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
        Throws:
        PicoCompositionException - if one or more dependencies cannot be resolved.
      • getComponentInstance

        public abstract T getComponentInstance​(PicoContainer container,
                                               Type into)
                                        throws PicoCompositionException
        Description copied from interface: ComponentAdapter
        Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example, Cached will always return the same instance.
        Specified by:
        getComponentInstance in interface ComponentAdapter<T>
        Parameters:
        container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
        into - the class that is about to be injected into. Use ComponentAdapter.NOTHING.class if this is not important to you.
        Returns:
        the component instance.
        Throws:
        PicoCompositionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambiguous situation within the container.
      • decorateComponentInstance

        public Object decorateComponentInstance​(PicoContainer container,
                                                Type into,
                                                T instance)
        Description copied from interface: Injector
        A preexiting component instance can be injected into after instantiation
        Specified by:
        decorateComponentInstance in interface Injector<T>
        Parameters:
        container - the container that can provide injectable dependencies
        instance - the instance to
        Returns:
      • accept

        public void accept​(PicoVisitor visitor)
        Description copied from interface: ComponentAdapter
        Accepts a visitor for this ComponentAdapter. The method is normally called by visiting a PicoContainer, that cascades the visitor also down to all its ComponentAdapter instances.
        Specified by:
        accept in interface ComponentAdapter<T>
        Overrides:
        accept in class AbstractAdapter<T>
        Parameters:
        visitor - the visitor.
      • getDescriptor

        public String getDescriptor()
        Description copied from interface: ComponentAdapter
        Get a string key descriptor of the component adapter for use in toString()
        Specified by:
        getDescriptor in interface ComponentAdapter<T>
        Returns:
        the descriptor
      • caughtInvocationTargetException

        protected T caughtInvocationTargetException​(ComponentMonitor componentMonitor,
                                                    Member member,
                                                    Object componentInstance,
                                                    InvocationTargetException e)
        inform monitor about exception while instantiating component
        Parameters:
        componentMonitor -
        member -
        componentInstance -
        e -
        Returns:
      • box

        protected Type box​(Type parameterType)