Interface PicoContainer

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void accept​(PicoVisitor visitor)
      Accepts a visitor that should visit the child containers, component adapters and component instances.
      <T> T getComponent​(java.lang.Class<T> componentType)
      Retrieve a component keyed by the component type.
      <T> T getComponent​(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)
      Retrieve a component keyed by the component type and binding type.
      java.lang.Object getComponent​(java.lang.Object componentKeyOrType)
      Retrieve a component instance registered with a specific key or type.
      java.lang.Object getComponent​(java.lang.Object componentKeyOrType, java.lang.reflect.Type into)  
      <T> ComponentAdapter<T> getComponentAdapter​(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)
      Find a component adapter associated with the specified type and binding type.
      <T> ComponentAdapter<T> getComponentAdapter​(java.lang.Class<T> componentType, NameBinding componentNameBinding)
      Find a component adapter associated with the specified type and binding name.
      ComponentAdapter<?> getComponentAdapter​(java.lang.Object componentKey)
      Find a component adapter associated with the specified key.
      java.util.Collection<ComponentAdapter<?>> getComponentAdapters()
      Retrieve all the component adapters inside this container.
      <T> java.util.List<ComponentAdapter<T>> getComponentAdapters​(java.lang.Class<T> componentType)
      Retrieve all component adapters inside this container that are associated with the specified type.
      <T> java.util.List<ComponentAdapter<T>> getComponentAdapters​(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)
      Retrieve all component adapters inside this container that are associated with the specified type and binding type.
      java.util.List<java.lang.Object> getComponents()
      Retrieve all the registered component instances in the container, (not including those in the parent container).
      <T> java.util.List<T> getComponents​(java.lang.Class<T> componentType)
      Returns a List of components of a certain componentType.
      PicoContainer getParent()
      Retrieve the parent container of this container.
    • Method Detail

      • getComponent

        java.lang.Object getComponent​(java.lang.Object componentKeyOrType)
        Retrieve a component instance registered with a specific key or type. If a component cannot be found in this container, the parent container (if one exists) will be searched.
        Parameters:
        componentKeyOrType - the key or Type that the component was registered with.
        Returns:
        an instantiated component, or null if no component has been registered for the specified key.
      • getComponent

        java.lang.Object getComponent​(java.lang.Object componentKeyOrType,
                                      java.lang.reflect.Type into)
      • getComponent

        <T> T getComponent​(java.lang.Class<T> componentType)
        Retrieve a component keyed by the component type.
        Parameters:
        componentType - the type of the component
        Returns:
        the typed resulting object instance or null if the object does not exist.
      • getComponent

        <T> T getComponent​(java.lang.Class<T> componentType,
                           java.lang.Class<? extends java.lang.annotation.Annotation> binding)
        Retrieve a component keyed by the component type and binding type.
        Parameters:
        componentType - the type of the component
        binding - the binding type of the component
        Returns:
        the typed resulting object instance or null if the object does not exist.
      • getComponents

        java.util.List<java.lang.Object> getComponents()
        Retrieve all the registered component instances in the container, (not including those in the parent container). The components are returned in their order of instantiation, which depends on the dependency order between them.
        Returns:
        all the components.
        Throws:
        PicoException - if the instantiation of the component fails
      • getParent

        PicoContainer getParent()
        Retrieve the parent container of this container.
        Returns:
        a PicoContainer instance, or null if this container does not have a parent.
      • getComponentAdapter

        ComponentAdapter<?> getComponentAdapter​(java.lang.Object componentKey)
        Find a component adapter associated with the specified key. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.
        Parameters:
        componentKey - the key that the component was registered with.
        Returns:
        the component adapter associated with this key, or null if no component has been registered for the specified key.
      • getComponentAdapter

        <T> ComponentAdapter<T> getComponentAdapter​(java.lang.Class<T> componentType,
                                                    NameBinding componentNameBinding)
        Find a component adapter associated with the specified type and binding name. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.
        Parameters:
        componentType - the type of the component.
        componentNameBinding - the name binding to use
        Returns:
        the component adapter associated with this class, or null if no component has been registered for the specified key.
      • getComponentAdapter

        <T> ComponentAdapter<T> getComponentAdapter​(java.lang.Class<T> componentType,
                                                    java.lang.Class<? extends java.lang.annotation.Annotation> binding)
        Find a component adapter associated with the specified type and binding type. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.
        Parameters:
        componentType - the type of the component.
        binding - the typed binding to use
        Returns:
        the component adapter associated with this class, or null if no component has been registered for the specified key.
      • getComponentAdapters

        <T> java.util.List<ComponentAdapter<T>> getComponentAdapters​(java.lang.Class<T> componentType)
        Retrieve all component adapters inside this container that are associated with the specified type. The addComponent adapters from the parent container are not returned.
        Parameters:
        componentType - the type of the components.
        Returns:
        a collection containing all the ComponentAdapters inside this container that are associated with the specified type. Changes to this collection will not be reflected in the container itself.
      • getComponentAdapters

        <T> java.util.List<ComponentAdapter<T>> getComponentAdapters​(java.lang.Class<T> componentType,
                                                                     java.lang.Class<? extends java.lang.annotation.Annotation> binding)
        Retrieve all component adapters inside this container that are associated with the specified type and binding type. The addComponent adapters from the parent container are not returned.
        Parameters:
        componentType - the type of the components.
        binding - the typed binding to use
        Returns:
        a collection containing all the ComponentAdapters inside this container that are associated with the specified type. Changes to this collection will not be reflected in the container itself.
      • getComponents

        <T> java.util.List<T> getComponents​(java.lang.Class<T> componentType)
        Returns a List of components of a certain componentType. The list is ordered by instantiation order, starting with the components instantiated first at the beginning.
        Parameters:
        componentType - the searched type.
        Returns:
        a List of components.
        Throws:
        PicoException - if the instantiation of a component fails
      • accept

        void accept​(PicoVisitor visitor)
        Accepts a visitor that should visit the child containers, component adapters and component instances.
        Parameters:
        visitor - the visitor