Class AbstractAdapter<T>

    • Constructor Detail

      • AbstractAdapter

        public AbstractAdapter​(Object componentKey,
                               Class componentImplementation)
        Constructs a new ComponentAdapter for the given key and implementation.
        Parameters:
        componentKey - the search key for this implementation
        componentImplementation - the concrete implementation
      • AbstractAdapter

        public AbstractAdapter​(Object componentKey,
                               Class componentImplementation,
                               ComponentMonitor monitor)
        Constructs a new ComponentAdapter for the given key and implementation.
        Parameters:
        componentKey - the search key for this implementation
        componentImplementation - the concrete implementation
        monitor - the component monitor used by this ComponentAdapter
    • Method Detail

      • getComponentKey

        public Object getComponentKey()
        Retrieve the key associated with the component.
        Specified by:
        getComponentKey in interface ComponentAdapter<T>
        Returns:
        the component's key. Should either be a class type (normally an interface) or an identifier that is unique (within the scope of the current PicoContainer).
        See Also:
        ComponentAdapter.getComponentKey()
      • checkTypeCompatibility

        protected void checkTypeCompatibility()
      • getComponentInstance

        public T getComponentInstance​(PicoContainer container)
                               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.
        Returns:
        the component instance.
        Throws:
        PicoCompositionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.
      • 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>
        Parameters:
        visitor - the visitor.
      • getDelegate

        public final ComponentAdapter<T> getDelegate()
        Description copied from interface: ComponentAdapter
        Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain.
        Specified by:
        getDelegate in interface ComponentAdapter<T>
        Returns:
        the next component adapter in line or null if there is no delegate ComponentAdapter.
      • findAdapterOfType

        public final <U extends ComponentAdapter> U findAdapterOfType​(Class<U> adapterType)
        Description copied from interface: ComponentAdapter
        Locates a component adapter of type componentAdapterType in the ComponentAdapter chain. Will return null if there is no adapter of the given type.
        Specified by:
        findAdapterOfType in interface ComponentAdapter<T>
        Type Parameters:
        U - the type of ComponentAdapter being located.
        Parameters:
        adapterType - the class of the adapter type being located. Never null.
        Returns:
        the appropriate component adapter of type U. May return null if the component adapter type is not returned.