Package org.codehaus.plexus.component.configurator

Examples of org.codehaus.plexus.component.configurator.ComponentConfigurationException


            }

            if ( retValue == null )
            {
                // this is highly irregular
                throw new ComponentConfigurationException( "Configuration converter lookup failed for type: " + type );
            }

            converterMap.put( type, retValue );
        }
View Full Code Here


                                     ConfigurationListener listener )
        throws ComponentConfigurationException
    {
        if ( configuration.getChildCount() > 0 )
        {
            throw new ComponentConfigurationException( "When configuring a basic element the configuration cannot "
                + "contain any child elements. " + "Configuration element '" + configuration.getName() + "'." );
        }

        Object retValue = fromExpression( configuration, expressionEvaluator );

        if ( retValue instanceof String )
        {
            try
            {
                retValue = Enum.valueOf( type, (String) retValue );
            }
            catch ( RuntimeException e )
            {
                throw new ComponentConfigurationException( "Cannot assign value " + retValue + " to property "
                    + configuration.getName() + " of " + baseType.getName() + ": " + e.getMessage(), e );
            }
        }

        return retValue;
View Full Code Here

        try {
            return new URI(str);
        }
        catch (URISyntaxException e) {
            throw new ComponentConfigurationException("Unable to convert to URI: " + str, e);
        }
    }
View Full Code Here

        }

        // try setting field using value found with method
        // converter, if present.

        ComponentConfigurationException savedEx = null;

        if ( value != null )
        {
            try
            {
View Full Code Here

        {
            String msg =
                "Trying to convert the configuration element: '" + element
                    + "', missing child element 'name' for property.";

            throw new ComponentConfigurationException( msg );
        }

        Object value = fromExpression( property.getChild( "value" ), expressionEvaluator );

        if ( value == null )
View Full Code Here

                catch ( IllegalAccessException e )
                {
                    String msg = "An attempt to convert configuration entry " + configuration.getName() + "' into " +
                        type + " object failed: " + e.getMessage();

                    throw new ComponentConfigurationException( msg, e );
                }
                catch ( InstantiationException e )
                {
                    String msg = "An attempt to convert configuration entry " + configuration.getName() + "' into " +
                        type + " object failed: " + e.getMessage();

                    throw new ComponentConfigurationException( msg, e );
                }
            }
        }
        // now we have collection and we have to add some objects to it

        for ( int i = 0; i < configuration.getChildCount(); i++ )
        {
            PlexusConfiguration c = configuration.getChild( i );
            //Object o = null;

            String configEntry = c.getName();

            String name = fromXML( configEntry );

            Class childType = getClassForImplementationHint( null, c, classLoader );

            if ( childType == null && name.indexOf( '.' ) > 0 )
            {
                try
                {
                    childType = classLoader.loadClass( name );
                }
                catch ( ClassNotFoundException e )
                {
                    // not found, continue processing
                }
            }

            if ( childType == null )
            {
                // Some classloaders don't create Package objects for classes
                // so we have to resort to slicing up the class name

                String baseTypeName = baseType.getName();

                int lastDot = baseTypeName.lastIndexOf( '.' );

                String className;

                if ( lastDot == -1 )
                {
                    className = name;
                }
                else
                {
                    String basePackage = baseTypeName.substring( 0, lastDot );

                    className = basePackage + "." + StringUtils.capitalizeFirstLetter( name );
                }

                try
                {
                    childType = classLoader.loadClass( className );
                }
                catch ( ClassNotFoundException e )
                {
                    if ( c.getChildCount() == 0 )
                    {
                        // If no children, try a String.
                        // TODO: If we had generics we could try that instead - or could the component descriptor list an impl?
                        childType = String.class;
                    }
                    else
                    {
                        throw new ComponentConfigurationException( "Error loading class '" + className + "'", e );
                    }
                }
            }

            ConfigurationConverter converter = converterLookup.lookupConverterForType( childType );
View Full Code Here

        {
            return values.toArray( (Object[]) Array.newInstance( type.getComponentType(), 0 ) );
        }
        catch ( ArrayStoreException e )
        {
            throw new ComponentConfigurationException( "Cannot assign configuration values to array of type "
                + type.getComponentType().getName() + ": " + values );
        }
    }
View Full Code Here

            catch ( ClassNotFoundException e )
            {
                String msg = "ClassNotFoundException: Class name which was explicitly given in configuration using"
                    + " 'implementation' attribute: '" + implementation + "' cannot be loaded";

                throw new ComponentConfigurationException( msg, e );
            }
            catch ( UnsupportedClassVersionError e )
            {
                String msg = "UnsupportedClassVersionError: Class name which was explicitly given in configuration"
                    + " using 'implementation' attribute: '" + implementation + "' cannot be loaded";

                throw new ComponentConfigurationException( msg, e );
            }
            catch ( LinkageError e )
            {
                String msg = "LinkageError: Class name which was explicitly given in configuration using"
                    + " 'implementation' attribute: '" + implementation + "' cannot be loaded";

                throw new ComponentConfigurationException( msg, e );
            }
        }

        return retValue;
    }
View Full Code Here

        {
            retValue = classLoader.loadClass( classname );
        }
        catch ( ClassNotFoundException e )
        {
            throw new ComponentConfigurationException( "Error loading class '" + classname + "'", e );
        }

        return retValue;
    }
View Full Code Here

            return retValue;
        }
        catch ( IllegalAccessException e )
        {
            throw new ComponentConfigurationException( "Class '" + clazz.getName() + "' cannot be instantiated", e );
        }
        catch ( InstantiationException e )
        {
            throw new ComponentConfigurationException( "Class '" + clazz.getName() + "' cannot be instantiated", e );
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.component.configurator.ComponentConfigurationException

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.