+ configuration.getName() + "'"; throw new ComponentConfigurationException( configuration, msg, e );
if ( e.getFailedConfiguration() != null ) message += " for parameter " + e.getFailedConfiguration().getName();
private Xpp3Dom toXpp3Dom(PlexusConfiguration config) { Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
public static Xpp3Dom convert( MojoDescriptor mojoDescriptor ) { Xpp3Dom dom = new Xpp3Dom( "configuration" ); PlexusConfiguration c = mojoDescriptor.getMojoConfiguration(); PlexusConfiguration[] ces = c.getChildren(); if ( ces != null ) { for ( PlexusConfiguration ce : ces ) { String value = ce.getValue( null ); String defaultValue = ce.getAttribute( "default-value", null ); if ( value != null || defaultValue != null ) { Xpp3Dom e = new Xpp3Dom( ce.getName() ); e.setValue( value ); if ( defaultValue != null ) { e.setAttribute( "default-value", defaultValue ); } dom.addChild( e ); } } } return dom; }
protected Object fromExpression( PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, Class type ) throws ComponentConfigurationException { Object v = fromExpression( configuration, expressionEvaluator ); if ( v != null ) { if ( !type.isAssignableFrom( v.getClass() ) ) { String msg = "Cannot assign configuration entry '" + configuration.getName() + "' to '" + type + "' from '" + configuration.getValue( null ) + "', which is of type " + v.getClass(); throw new ComponentConfigurationException( configuration, msg ); } } return v; }
private void displayTag( PlexusConfiguration c, Writer w, int depth ) throws IOException { String value = c.getValue( null ); if ( value != null ) { indent( depth, w ); w.write( '<' ); w.write( c.getName() ); attributes( c, w ); w.write( '>' ); w.write( c.getValue( null ) ); w.write( '<' ); w.write( '/' ); w.write( c.getName() ); w.write( '>' ); w.write( '\n' ); } else { indent( depth, w ); w.write( '<' ); w.write( c.getName() ); attributes( c, w ); w.write( '/' ); w.write( '>' ); w.write( "\n" ); } }
public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, 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; }
private void display( PlexusConfiguration c, Writer w, int depth ) throws IOException { int count = c.getChildCount(); if ( count == 0 ) { displayTag( c, w, depth ); } else { indent( depth, w ); w.write( '<' ); w.write( c.getName() ); attributes( c, w ); w.write( '>' ); w.write( '\n' ); for ( int i = 0; i < count; i++ ) { PlexusConfiguration child = c.getChild( i ); display( child, w, depth + 1 ); } indent( depth, w ); w.write( '<' ); w.write( '/' ); w.write( c.getName() ); w.write( '>' ); w.write( '\n' ); } }
private static void writeConfiguration( PrintStream out, PlexusConfiguration configuration, String indent ) throws PlexusConfigurationException { out.print( indent + "<" + configuration.getName() ); String[] atts = configuration.getAttributeNames(); if ( atts.length > 0 ) { for (String att : atts) { out.print("\n" + indent + " " + att + "='" + configuration.getAttribute(att) + "'"); } } PlexusConfiguration[] pc = configuration.getChildren(); if ( ( configuration.getValue() != null && configuration.getValue().trim().length() > 0 ) || pc.length > 0 ) { out.print( ">" + ( configuration.getValue() == null ? "" : configuration.getValue().trim() ) ); if ( pc.length > 0 ) { out.println(); for (PlexusConfiguration aPc : pc) { writeConfiguration(out, aPc, indent + " "); } out.print( indent ); } out.println( "</" + configuration.getName() + ">" ); } else { out.println( "/>" ); } }
public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, ConfigurationListener listener ) throws ComponentConfigurationException { Object retValueInterpolated = fromExpression( configuration, expressionEvaluator, type ); if ( retValueInterpolated != null ) { return retValueInterpolated; } String element = configuration.getName(); Properties retValue = new Properties(); PlexusConfiguration[] children = configuration.getChildren( "property" ); if ( children != null && children.length > 0 ) { for (PlexusConfiguration child : children) { addEntry(retValue, element, child, expressionEvaluator); } } return retValue; }
String configEntry = childConfiguration.getName();
public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, ConfigurationListener listener ) throws ComponentConfigurationException { Object retValue; String expression = configuration.getValue( null ); if ( expression == null ) { expression = configuration.getAttribute( "default-value", null ); } if ( expression == null ) { Map map = new TreeMap(); PlexusConfiguration[] children = configuration.getChildren(); for (PlexusConfiguration child : children) { String name = child.getName(); map.put(name, fromExpression(child, expressionEvaluator)); } retValue = map; } else { retValue = fromExpression( configuration, expressionEvaluator ); } return retValue; }
String msg = "An attempt to convert configuration entry " + configuration.getName() + "' into " + type + " object failed: " + e.getMessage(); String msg = "An attempt to convert configuration entry " + configuration.getName() + "' into " + type + " object failed: " + e.getMessage(); String configEntry = c.getName();
public void processConfiguration( ConverterLookup converterLookup, Object object, ClassLoader classLoader, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ConfigurationListener listener ) throws ComponentConfigurationException { int items = configuration.getChildCount(); for ( int i = 0; i < items; i++ ) { PlexusConfiguration childConfiguration = configuration.getChild( i ); String elementName = childConfiguration.getName(); ComponentValueSetter valueSetter = new ComponentValueSetter( fromXML( elementName ), object, converterLookup, listener ); valueSetter.configure( childConfiguration, classLoader, expressionEvaluator ); } } }
"contain any child elements. " + "Configuration element '" + configuration.getName() + "'." );
protected final static PlexusConfiguration csvToXml( final PlexusConfiguration configuration, final String csv ) { final PlexusConfiguration xml = new XmlPlexusConfiguration( configuration.getName() ); if ( csv.length() > 0 ) { for ( final String token : csv.split( ",", -1 ) ) { xml.addChild( "#", token ); } } return xml; }
String name = child.getName(); name = fromXML(name); if ( StringUtils.isNotEmpty( child.getValue( null ) ) )