Class DefaultPlexusContainer

    • Field Detail

      • DEFAULT_CONTAINER_NAME

        protected static final java.lang.String DEFAULT_CONTAINER_NAME
        See Also:
        Constant Field Values
      • DEFAULT_REALM_NAME

        protected static final java.lang.String DEFAULT_REALM_NAME
        See Also:
        Constant Field Values
      • containerContext

        protected Context containerContext
        Arbitrary data associated with the container. Data in the container has highest precedence when configuring a component to create.
      • configurationReader

        protected java.io.Reader configurationReader
      • classWorld

        protected org.codehaus.plexus.classworlds.ClassWorld classWorld
      • containerRealm

        protected org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm
      • componentDiscovererManager

        protected ComponentDiscovererManager componentDiscovererManager
        Simple index (registry) of ComponentDiscovers and ComponentDiscoveryListener.
      • componentFactoryManager

        protected ComponentFactoryManager componentFactoryManager
        Trivial class to look-up ComponentFactory instances in this container.
      • loggerManager

        protected LoggerManager loggerManager
        Generic logger interface.
      • configurationSource

        protected ConfigurationSource configurationSource
        Converts a ComponentDescriptor into PlexusConfiguration.
      • lookupRealm

        private java.lang.ThreadLocal<org.codehaus.plexus.classworlds.realm.ClassRealm> lookupRealm
    • Method Detail

      • addComponent

        public void addComponent​(java.lang.Object component,
                                 java.lang.String role)
        Specified by:
        addComponent in interface PlexusContainer
      • addComponent

        public <T> void addComponent​(T component,
                                     java.lang.Class<?> role,
                                     java.lang.String roleHint)
        Description copied from interface: PlexusContainer
        Adds live component instance to this container. Component instance is not associated with any class realm and will be ignored during lookup is lookup realm is provided using thread context classloader.
        Specified by:
        addComponent in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        component - The component.
        role - The role.
        roleHint - The hint.
      • addComponent

        public void addComponent​(java.lang.Object component,
                                 java.lang.String role,
                                 java.lang.String roleHint)
      • setLookupRealm

        public org.codehaus.plexus.classworlds.realm.ClassRealm setLookupRealm​(org.codehaus.plexus.classworlds.realm.ClassRealm realm)
        Description copied from interface: PlexusContainer
        Sets the lookup realm to use for lookup calls that don't have a ClassRealm parameter.
        Specified by:
        setLookupRealm in interface PlexusContainer
        Parameters:
        realm - the new realm to use.
        Returns:
        The previous lookup realm. It is advised to set it back once the old-style lookups have completed.
      • createChildRealm

        public org.codehaus.plexus.classworlds.realm.ClassRealm createChildRealm​(java.lang.String id)
        Specified by:
        createChildRealm in interface PlexusContainer
      • getInterfaceClass

        private java.lang.Class<?> getInterfaceClass​(java.lang.String role,
                                                     java.lang.String hint)
      • getRoleClass

        private java.lang.Class<?> getRoleClass​(java.lang.String role)
      • getRoleClass

        private java.lang.Class<?> getRoleClass​(java.lang.String role,
                                                java.lang.String hint)
      • lookup

        public java.lang.Object lookup​(java.lang.String role)
                                throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a component object with the given unique key or role.
        Specified by:
        lookup in interface PlexusContainer
        Parameters:
        role - a unique key for the desired component
        Returns:
        a Plexus component object
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookup

        public java.lang.Object lookup​(java.lang.String role,
                                       java.lang.String roleHint)
                                throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a component object with the given unique role/role-hint combination.
        Specified by:
        lookup in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired component
        roleHint - a hint for the desired component implementation
        Returns:
        a Plexus component object
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookup

        public <T> T lookup​(java.lang.Class<T> type)
                     throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a component object with the given unique key or role.
        Specified by:
        lookup in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the unique type of the component within the container
        Returns:
        a Plexus component object
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookup

        public <T> T lookup​(java.lang.Class<T> type,
                            java.lang.String roleHint)
                     throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a component object with the given unique role/role-hint combination.
        Specified by:
        lookup in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the non-unique type of the component
        roleHint - a hint for the desired component implementation
        Returns:
        a Plexus component object
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookup

        public <T> T lookup​(java.lang.Class<T> type,
                            java.lang.String role,
                            java.lang.String roleHint)
                     throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a component object with the given unique role/role-hint combination.
        Specified by:
        lookup in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the non-unique type of the component
        role - a non-unique key for the desired component
        roleHint - a hint for the desired component implementation
        Returns:
        a Plexus component object
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupList

        public java.util.List<java.lang.Object> lookupList​(java.lang.String role)
                                                    throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a List of component objects with the given role.
        Specified by:
        lookupList in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired components
        Returns:
        a List of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupList

        public java.util.List<java.lang.Object> lookupList​(java.lang.String role,
                                                           java.util.List<java.lang.String> roleHints)
                                                    throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a List of component objects with the given role.
        Specified by:
        lookupList in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired components
        roleHints - the list of hints.
        Returns:
        a List of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupList

        public <T> java.util.List<T> lookupList​(java.lang.Class<T> type)
                                         throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a List of component objects with the given role.
        Specified by:
        lookupList in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the non-unique type of the components
        Returns:
        a List of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupList

        public <T> java.util.List<T> lookupList​(java.lang.Class<T> type,
                                                java.util.List<java.lang.String> roleHints)
                                         throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a List of component objects with the given role.
        Specified by:
        lookupList in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the non-unique type of the components
        roleHints - the list of hints.
        Returns:
        a List of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupMap

        public java.util.Map<java.lang.String,​java.lang.Object> lookupMap​(java.lang.String role)
                                                                         throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
        Specified by:
        lookupMap in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired components
        Returns:
        a Map of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupMap

        public java.util.Map<java.lang.String,​java.lang.Object> lookupMap​(java.lang.String role,
                                                                                java.util.List<java.lang.String> roleHints)
                                                                         throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
        Specified by:
        lookupMap in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired components
        roleHints - the list of hints.
        Returns:
        a Map of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupMap

        public <T> java.util.Map<java.lang.String,​T> lookupMap​(java.lang.Class<T> type)
                                                              throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
        Specified by:
        lookupMap in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the non-unique type of the components
        Returns:
        a Map of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • lookupMap

        public <T> java.util.Map<java.lang.String,​T> lookupMap​(java.lang.Class<T> type,
                                                                     java.util.List<java.lang.String> roleHints)
                                                              throws ComponentLookupException
        Description copied from interface: PlexusContainer
        Looks up and returns a Map of component objects with the given role, keyed by all available role-hints.
        Specified by:
        lookupMap in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the non-unique type of the components
        roleHints - the list of hints.
        Returns:
        a Map of component objects
        Throws:
        ComponentLookupException - in case of lookup error.
      • hasComponent

        public boolean hasComponent​(java.lang.String role)
        Description copied from interface: PlexusContainer
        Returns true if this container has the keyed component.
        Specified by:
        hasComponent in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired component
        Returns:
        true if this container has the keyed component
      • hasComponent

        public boolean hasComponent​(java.lang.String role,
                                    java.lang.String roleHint)
        Description copied from interface: PlexusContainer
        Returns true if this container has a component with the given role/role-hint.
        Specified by:
        hasComponent in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired component
        roleHint - a hint for the desired component implementation
        Returns:
        true if this container has a component with the given role/role-hint
      • hasComponent

        public boolean hasComponent​(java.lang.Class<?> type)
        Description copied from interface: PlexusContainer
        Returns true if this container has a component with the given role/role-hint.
        Specified by:
        hasComponent in interface PlexusContainer
        Parameters:
        type - the non-unique type of the component
        Returns:
        true if this container has a component with the given role/role-hint
      • hasComponent

        public boolean hasComponent​(java.lang.Class<?> type,
                                    java.lang.String roleHint)
        Description copied from interface: PlexusContainer
        Returns true if this container has a component with the given role/role-hint.
        Specified by:
        hasComponent in interface PlexusContainer
        Parameters:
        type - the non-unique type of the component
        roleHint - a hint for the desired component implementation
        Returns:
        true if this container has a component with the given role/role-hint
      • hasComponent

        public boolean hasComponent​(java.lang.Class<?> type,
                                    java.lang.String role,
                                    java.lang.String roleHint)
        Description copied from interface: PlexusContainer
        Returns true if this container has a component with the given role/role-hint.
        Specified by:
        hasComponent in interface PlexusContainer
        Parameters:
        type - the non-unique type of the component
        role - a non-unique key for the desired component
        roleHint - a hint for the desired component implementation
        Returns:
        true if this container has a component with the given role/role-hint
      • getComponentDescriptor

        public ComponentDescriptor<?> getComponentDescriptor​(java.lang.String role)
        Description copied from interface: PlexusContainer
        Returns the ComponentDescriptor with the given component role and the default role hint. Searches up the hierarchy until one is found, null if none is found.
        Specified by:
        getComponentDescriptor in interface PlexusContainer
        Parameters:
        role - a unique role for the desired component's descriptor
        Returns:
        the ComponentDescriptor with the given component role
      • getComponentDescriptor

        public ComponentDescriptor<?> getComponentDescriptor​(java.lang.String role,
                                                             java.lang.String roleHint)
        Description copied from interface: PlexusContainer
        Returns the ComponentDescriptor with the given component role and hint. Searches up the hierarchy until one is found, null if none is found.
        Specified by:
        getComponentDescriptor in interface PlexusContainer
        Parameters:
        role - a unique role for the desired component's descriptor
        roleHint - a hint showing which implementation should be used
        Returns:
        the ComponentDescriptor with the given component role
      • getComponentDescriptor

        public <T> ComponentDescriptor<T> getComponentDescriptor​(java.lang.Class<T> type,
                                                                 java.lang.String role,
                                                                 java.lang.String roleHint)
        Description copied from interface: PlexusContainer
        Returns the ComponentDescriptor with the given component role and hint. Searches up the hierarchy until one is found, null if none is found.
        Specified by:
        getComponentDescriptor in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the Java type of the desired component
        role - a unique role for the desired component's descriptor
        roleHint - a hint showing which implementation should be used
        Returns:
        the ComponentDescriptor with the given component role
      • getComponentDescriptorMap

        public java.util.Map<java.lang.String,​ComponentDescriptor<?>> getComponentDescriptorMap​(java.lang.String role)
        Description copied from interface: PlexusContainer
        Returns a Map of ComponentDescriptors with the given role, keyed by role-hint. Searches up the hierarchy until all are found, an empty Map if none are found.
        Specified by:
        getComponentDescriptorMap in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired components
        Returns:
        a Map of component descriptors keyed by role-hint
      • getComponentDescriptorMap

        public <T> java.util.Map<java.lang.String,​ComponentDescriptor<T>> getComponentDescriptorMap​(java.lang.Class<T> type,
                                                                                                          java.lang.String role)
        Description copied from interface: PlexusContainer
        Returns a Map of ComponentDescriptors with the given role, keyed by role-hint. Searches up the hierarchy until all are found, an empty Map if none are found.
        Specified by:
        getComponentDescriptorMap in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the Java type of the desired components
        role - a non-unique key for the desired components
        Returns:
        a Map of component descriptors keyed by role-hint
      • getComponentDescriptorList

        public java.util.List<ComponentDescriptor<?>> getComponentDescriptorList​(java.lang.String role)
        Description copied from interface: PlexusContainer
        Returns a List of ComponentDescriptors with the given role. Searches up the hierarchy until all are found, an empty List if none are found.
        Specified by:
        getComponentDescriptorList in interface PlexusContainer
        Parameters:
        role - a non-unique key for the desired components
        Returns:
        a List of component descriptors
      • getComponentDescriptorList

        public <T> java.util.List<ComponentDescriptor<T>> getComponentDescriptorList​(java.lang.Class<T> type,
                                                                                     java.lang.String role)
        Description copied from interface: PlexusContainer
        Returns a List of ComponentDescriptors with the given role. Searches up the hierarchy until all are found, an empty List if none are found.
        Specified by:
        getComponentDescriptorList in interface PlexusContainer
        Type Parameters:
        T - The type.
        Parameters:
        type - the Java type of the desired components
        role - a non-unique key for the desired components
        Returns:
        a List of component descriptors
      • release

        public void release​(java.lang.Object component)
                     throws ComponentLifecycleException
        Description copied from interface: PlexusContainer
        Releases the component from the container. This is dependent upon how the implementation manages the component, but usually enacts some standard lifecycle shutdown procedure on the component. In every case, the component is no longer accessible from the container (unless another is created).
        Specified by:
        release in interface PlexusContainer
        Parameters:
        component - the plexus component object to release
        Throws:
        ComponentLifecycleException - in case of an error.
      • dispose

        public void dispose()
        Description copied from interface: PlexusContainer
        Disposes of this container, which in turn disposes all of it's components. This container should also remove itself from the container hierarchy.
        Specified by:
        dispose in interface PlexusContainer
      • addContextValue

        public void addContextValue​(java.lang.Object key,
                                    java.lang.Object value)
        Description copied from interface: PlexusContainer
        Add a key/value pair to this container's Context.
        Specified by:
        addContextValue in interface PlexusContainer
        Parameters:
        key - any unique object valid to the Context's implementation
        value - any object valid to the Context's implementation
      • setClassWorld

        public void setClassWorld​(org.codehaus.plexus.classworlds.ClassWorld classWorld)
      • getContainerRealm

        public org.codehaus.plexus.classworlds.realm.ClassRealm getContainerRealm()
        Description copied from interface: PlexusContainer
        Returns the Classworld's ClassRealm of this Container, which acts as the default parent for all contained components.
        Specified by:
        getContainerRealm in interface PlexusContainer
        Returns:
        the ClassRealm of this Container
      • setContainerRealm

        public void setContainerRealm​(org.codehaus.plexus.classworlds.realm.ClassRealm containerRealm)
      • getContext

        public Context getContext()
        Description copied from interface: PlexusContainer
        Returns this container's context. A Context is a simple data store used to hold values which may alter the execution of the Container.
        Specified by:
        getContext in interface PlexusContainer
        Returns:
        this container's context.
      • getInterpolationConfigurationReader

        protected java.io.Reader getInterpolationConfigurationReader​(java.io.Reader reader)
      • registerComponentDiscoveryListener

        public void registerComponentDiscoveryListener​(ComponentDiscoveryListener listener)
        Description copied from interface: PlexusContainer
        Adds the listener to this container. ComponentDiscoveryListeners have the ability to respond to various ComponentDiscoverer events.
        Specified by:
        registerComponentDiscoveryListener in interface PlexusContainer
        Parameters:
        listener - A listener which responds to different ComponentDiscoveryEvents
      • getLookupRealm

        public org.codehaus.plexus.classworlds.realm.ClassRealm getLookupRealm​(java.lang.Object component)
        Utility method to get a default lookup realm for a component.
        Specified by:
        getLookupRealm in interface PlexusContainer
        Parameters:
        component - The component.
        Returns:
        ClassRealm