Package org.codehaus.plexus.component.repository

Examples of org.codehaus.plexus.component.repository.ComponentDescriptor


        if ( componentDescriptors != null )
        {
            for ( Iterator i = componentDescriptors.iterator(); i.hasNext(); )
            {
                ComponentDescriptor descriptor = (ComponentDescriptor) i.next();

                String roleHint = descriptor.getRoleHint();

                Object component = lookup( role, roleHint, realm );

                components.add( component );
            }
View Full Code Here


        return getComponentDescriptor( role, hint, getLookupRealm() );
    }

    public ComponentDescriptor getComponentDescriptor( String role, String hint, ClassRealm classRealm )
    {
        ComponentDescriptor result = componentRepository.getComponentDescriptor( role, hint, classRealm );

        ClassRealm tmpRealm = classRealm.getParentRealm();

        while ( result == null && tmpRealm != null )
        {
View Full Code Here

    {
        if ( object instanceof LogEnabled )
        {
            LoggerManager loggerManager = componentManager.getContainer().getLoggerManager();

            ComponentDescriptor descriptor = componentManager.getComponentDescriptor();
            loggerManager.returnComponentLogger( descriptor.getRole(), descriptor.getRoleHint() );
        }
    }
View Full Code Here

    {
        if ( object instanceof LogEnabled )
        {
            LoggerManager loggerManager = componentManager.getContainer().getLoggerManager();

            ComponentDescriptor descriptor = componentManager.getComponentDescriptor();

            Logger logger = loggerManager.getLoggerForComponent( descriptor.getRole(), descriptor.getRoleHint() );

            ( (LogEnabled) object ).enableLogging( logger );
        }
    }
View Full Code Here

                if ( componentDescriptors != null )
                {
                    for ( Iterator k = componentDescriptors.iterator(); k.hasNext(); )
                    {
                        ComponentDescriptor componentDescriptor = (ComponentDescriptor) k.next();

                        componentDescriptor.setComponentSetDescriptor( componentSet );

                        // If the user has already defined a component descriptor for this particular
                        // component then do not let the discovered component descriptor override
                        // the user defined one.

                        // Use the parent realm to search for the original descriptor. It won't
                        // be in the current realm (yet).
                        ComponentDescriptor orig = container.getComponentDescriptor(
                            componentDescriptor.getRole(),
                            componentDescriptor.getRoleHint(),
                            realm );

                        // System.out.println("Found new descriptor: " + componentDescriptor.getHumanReadableKey() + "
                        // realm="+ componentDescriptor.getRealmId() );
                        // System.out.println(" Existing descriptor: " + (orig == null ? "none":
                        // orig.getHumanReadableKey() + " realm= " + orig.getRealmId() ) );

                        if ( orig == null )
                        {
                            container.addComponentDescriptor( componentDescriptor );

                            // We only want to add components that have not yet been
                            // discovered in a parent realm. We don't quite have fine
                            // grained control over this right now but this is for
                            // dynamic additions which are only happening from maven
                            // at the moment. And plugins have a parent realm and
                            // a grand parent realm so if the component has been
                            // discovered it's most likely in those realms.

                            // I actually need to keep track of what realm a component
                            // was discovered in so that i can accurately search the
                            // parents.

                            discoveredComponentDescriptors.add( componentDescriptor );
                        }
                        else if ( override )
                        {
                            if ( orig.getRealmId() != null
                                && !orig.getRealmId().equals( componentDescriptor.getRealmId() ) )
                            {
                                if ( container.getLogger().isDebugEnabled() )
                                {
                                    container.getLogger().debug(
                                        "Duplicate component found, merging:" + "\n  Original: " + orig.getRealmId()
                                            + ": " + orig.getRole() + " [" + orig.getRoleHint() + "] impl="
                                            + orig.getImplementation() + "\n  Config: " + orig.getConfiguration()
                                            + "\n  New:      " + componentDescriptor.getRealmId() + ": "
                                            + componentDescriptor.getRole() + " [" + orig.getRoleHint() + "] impl="
                                            + componentDescriptor.getImplementation() + "\n  Config: "
                                            + orig.getConfiguration() );
                                }
                                PlexusComponentDescriptorMerger.merge( componentDescriptor, orig );
                            }
                            else if ( orig.getRealmId() != null
                                && orig.getRealmId().equals( componentDescriptor.getRealmId() ) )
                            {
                                // two decls for the same component in the same realm.
                                // Use classpath order - first one wins.

                                if ( container.getLogger().isDebugEnabled() )
                                {
                                    container.getLogger().debug(
                                        "Duplicate component found, not replacing:" + "\n  Original: "
                                            + orig.getRealmId() + ": " + orig.getRole() + " [" + orig.getRoleHint()
                                            + "] impl=" + orig.getImplementation() + "\n  Config: "
                                            + orig.getConfiguration() + "\n  New:      "
                                            + componentDescriptor.getRealmId() + ": " + componentDescriptor.getRole()
                                            + " [" + orig.getRoleHint() + "] impl="
                                            + componentDescriptor.getImplementation() + "\n  Config: "
                                            + orig.getConfiguration() );
                                }
                            }
                        }
                    }
                }
View Full Code Here

                "This is highly irregular, your plexus JAR is most likely corrupt.";

            throw new ContainerInitializationException( msg );
        }

        ComponentDescriptor componentDescriptor = new ComponentDescriptor();

        componentDescriptor.setRole( role );

        componentDescriptor.setImplementation( implementation );

        componentDescriptor.setRealmId( container.getContainerRealm().getId() );

        PlexusConfiguration configuration = new XmlPlexusConfiguration( "containerConfiguration" );

        configuration.addChild( c );

        try
        {
            configurator.configureComponent( container, configuration, container.getContainerRealm() );
        }
        catch ( ComponentConfigurationException e )
        {
            // TODO: don't like rewrapping the same exception, but better than polluting this all through the config code
            String message = "Error configuring component: " + componentDescriptor.getHumanReadableKey();
            throw new ContainerInitializationException( message, e );
        }

        return componentDescriptor;
    }
View Full Code Here

        // component manager manager to create a component manager for us. Also if we are reloading
        // components then we'll also get a new component manager.

        if ( container.isReloadingEnabled() || componentManager == null )
        {
            ComponentDescriptor descriptor = container.getComponentRepository().getComponentDescriptor( componentRole,
                                                                                                        roleHint,
                                                                                                        realm );

            if ( descriptor == null )
            {
View Full Code Here

        if ( componentDescriptors != null )
        {
            for ( Iterator i = componentDescriptors.iterator(); i.hasNext(); )
            {
                ComponentDescriptor descriptor = (ComponentDescriptor) i.next();

                String roleHint = descriptor.getRoleHint();

                Object component = lookup( role, roleHint, realm );

                components.add( component );
            }
View Full Code Here

            for ( int i = 0; i < componentConfigurations.length; i++ )
            {
                PlexusConfiguration componentConfiguration = componentConfigurations[i];

                ComponentDescriptor componentDescriptor = null;

                try
                {
                    componentDescriptor = PlexusTools.buildComponentDescriptor( componentConfiguration );
                }
                catch ( PlexusConfigurationException e )
                {
                    throw new PlexusConfigurationException( "Cannot build component descriptor from resource found in:\n" +
                                         Arrays.asList( classRealm.getURLs() ), e );
                }

                componentDescriptor.setComponentType( "plexus" );

                componentDescriptor.setRealmId( classRealm.getId() );

                componentDescriptors.add( componentDescriptor );
            }

            componentSetDescriptor.setComponents( componentDescriptors );
View Full Code Here

        for ( int i = 0; i < componentConfigurations.length; i++ )
        {
            PlexusConfiguration componentConfiguration = componentConfigurations[i];

            ComponentDescriptor componentDescriptor;

            try
            {
                componentDescriptor = PlexusTools.buildComponentDescriptor( componentConfiguration );
            }
            catch ( PlexusConfigurationException e )
            {
                throw new PlexusConfigurationException( "Cannot process component descriptor: " + source, e );
            }

            componentDescriptor.setComponentType( "plexus" );

            componentDescriptors.add( componentDescriptor );
        }

        componentSetDescriptor.setComponents( componentDescriptors );
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.component.repository.ComponentDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.