Package org.codehaus.plexus.component.configurator

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


                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


                                     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 );
View Full Code Here

                {
                    parameters.put( param.getName(), param.getValue() );
                }
                catch ( PlexusConfigurationException ex )
                {
                    throw new ComponentConfigurationException( ex );
                }
            }
            map.put( type, parameters );
        }
View Full Code Here

            methodConfigure.invoke( componentConfigurator, wagon, plexusConf, realm );
        }
        catch ( Exception e )
        {
            throw new ComponentConfigurationException(
                "Failed to configure wagon component for a Maven2 use " + e.getMessage(), e );
        }
    }
View Full Code Here

        }

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

        return retValue;
    }
View Full Code Here

        {
            return new URL( str );
        }
        catch ( MalformedURLException e )
        {
            throw new ComponentConfigurationException( "Unable to convert '" + str + "' to an URL", e );
        }
    }
View Full Code Here

        {
            return Class.forName( str );
        }
        catch ( ClassNotFoundException e )
        {
            throw new ComponentConfigurationException( "Unable to find class in conversion", e );
        }
    }
View Full Code Here

            }
            catch ( ExpressionEvaluationException e )
            {
                String msg = "Error evaluating the expression '" + value + "' for configuration value '" +
                    configuration.getName() + "'";
                throw new ComponentConfigurationException( configuration, msg, e );
            }
        }

        if ( v == null )
        {
            value = configuration.getAttribute( "default-value", null );

            if ( value != null && value.length() > 0 )
            {
                try
                {
                    if ( expressionEvaluator instanceof TypeAwareExpressionEvaluator )
                    {
                        v = ( (TypeAwareExpressionEvaluator) expressionEvaluator ).evaluate( value, type );
                    }
                    else
                    {
                        v = expressionEvaluator.evaluate( value );
                    }
                }
                catch ( ExpressionEvaluationException e )
                {
                    String msg = "Error evaluating the expression '" + value + "' for configuration value '" +
                        configuration.getName() + "'";
                    throw new ComponentConfigurationException( configuration, msg, e );
                }
            }
        }

        /*
 
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, type );
View Full Code Here

        {
            return Integer.valueOf( str );
        }
        catch ( NumberFormatException e )
        {
            throw new ComponentConfigurationException(
                "Not a number: '" + str + "'", 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.