Package org.codehaus.plexus.component.factory

Examples of org.codehaus.plexus.component.factory.ComponentInstantiationException


        {
            msg = "Could not instantiate component: " + componentDescriptor.getHumanReadableKey() + " realm: "
                + componentClassRealm.getId();
        }

        return new ComponentInstantiationException( msg, e );
    }
View Full Code Here


            String message = "Creation circularity: ";
            for ( ComponentDescriptor<?> componentDescriptor : circularity )
            {
                message += "\n\t[" + componentDescriptor.getRole() + ", " + componentDescriptor.getRoleHint() + "]";
            }
            throw new ComponentInstantiationException( message );
        }
        stack.add( descriptor );
        try
        {
            if (listener != null) {
View Full Code Here

            {
                realm.loadClass( descriptor.getImplementation() );
            }
            catch ( ClassNotFoundException e )
            {
                throw new ComponentInstantiationException( "Could not load implementation class for component "
                    + descriptor.getHumanReadableKey() + " from class realm " + realm, e );
            }
            catch ( LinkageError e )
            {
                throw new ComponentInstantiationException( "Could not load implementation class for component "
                    + descriptor.getHumanReadableKey() + " from class realm " + realm, e );
            }
        }

        ObjectRecipe recipe = new ObjectRecipe( implClass,
                factoryMethod,
                constructorArgNames,
                constructorArgTypes);
        recipe.allow(Option.FIELD_INJECTION);
        recipe.allow(Option.PRIVATE_PROPERTIES);

        // MapOrientedComponents don't get normal injection
        if (!MapOrientedComponent.class.isAssignableFrom( implClass )) {
            for (ComponentRequirement requirement : descriptor.getRequirements() ) {
                String name = requirement.getFieldName();
                RequirementRecipe requirementRecipe = new RequirementRecipe(descriptor, requirement, getContainer(), name == null);

                if (name != null) {
                    recipe.setProperty(name, requirementRecipe);
                } else {
                    recipe.setAutoMatchProperty(requirement.getRole(), requirementRecipe);
                }
            }

            // add configuration data
            if (shouldConfigure(descriptor )) {
                PlexusConfiguration configuration = descriptor.getConfiguration();
                if (configuration != null) {
                    for (String name : configuration.getAttributeNames()) {
                        String value;
                        try {
                            value = configuration.getAttribute(name);
                        } catch (PlexusConfigurationException e) {
                            throw new ComponentInstantiationException("Error getting value for attribute " + name, e);
                        }
                        name = fromXML(name);
                        recipe.setProperty(name, value);
                    }
                    for (PlexusConfiguration child : configuration.getChildren()) {
View Full Code Here

                    component = method.invoke( componentFactory, new Object[]{componentDescriptor, cr, container} );
                }
                catch ( Exception mnfe )
                {
                    throw new ComponentInstantiationException(
                        "Unable to create component as factory '" + componentFactoryId + "' could not be found", e );
                }
            }
        }
        catch ( UndefinedComponentFactoryException e )
        {
            throw new ComponentInstantiationException(
                "Unable to create component as factory '" + componentFactoryId + "' could not be found", e );
        }

        return component;
    }
View Full Code Here

            int modifiers = implementationClass.getModifiers();

            if ( Modifier.isInterface( modifiers ) )
            {
                throw new ComponentInstantiationException(
                    "Cannot instantiate implementation '" + implementation + "' because the class is a interface." );
            }

            if ( Modifier.isAbstract( modifiers ) )
            {
                throw new ComponentInstantiationException(
                    "Cannot instantiate implementation '" + implementation + "' because the class is abstract." );
            }

            Object instance = implementationClass.newInstance();
View Full Code Here

        {
            msg = "Could not instantiate component: " + componentDescriptor.getHumanReadableKey() + " realm: "
                + componentClassRealm.getId();
        }

        return new ComponentInstantiationException( msg, e );
    }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.component.factory.ComponentInstantiationException

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.