if ( parameters != null )
{
for ( int j = 0; j < parameters.size(); j++ )
{
Parameter parameter = (Parameter) parameters.get( j );
String expression = parameter.getExpression();
if ( StringUtils.isNotEmpty( expression ) && expression.startsWith( "${component." ) )
{
// treat it as a component...a requirement, in other words.
// remove "component." plus expression delimiters
String role = expression.substring( "${component.".length(), expression.length() - 1 );
String roleHint = null;
int posRoleHintSeparator;
if ( ( posRoleHintSeparator = role.indexOf( "#" ) ) > 0 )
{
roleHint = role.substring( posRoleHintSeparator + 1 );
role = role.substring( 0, posRoleHintSeparator );
}
// TODO: remove deprecated expression
requirements.put( parameter.getName(), new Requirement( role, roleHint ) );
}
else if ( parameter.getRequirement() != null )
{
requirements.put( parameter.getName(), parameter.getRequirement() );
}
else
{
// treat it as a normal parameter.
w.startElement( "parameter" );
element( w, "name", parameter.getName() );
if ( parameter.getAlias() != null )
{
element( w, "alias", parameter.getAlias() );
}
element( w, "type", parameter.getType() );
if ( parameter.getDeprecated() != null )
{
element( w, "deprecated", parameter.getDeprecated() );
}
element( w, "required", Boolean.toString( parameter.isRequired() ) );
element( w, "editable", Boolean.toString( parameter.isEditable() ) );
element( w, "description", parameter.getDescription() );
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) ||
StringUtils.isNotEmpty( parameter.getExpression() ) )
{
configuration.add( parameter );
}
w.endElement();
}
}
}
w.endElement();
// ----------------------------------------------------------------------
// Coinfiguration
// ----------------------------------------------------------------------
if ( !configuration.isEmpty() )
{
w.startElement( "configuration" );
for ( Iterator i = configuration.iterator(); i.hasNext(); )
{
Parameter parameter = (Parameter) i.next();
w.startElement( parameter.getName() );
String type = parameter.getType();
if ( type != null )
{
w.addAttribute( "implementation", type );
}
if ( parameter.getDefaultValue() != null )
{
w.addAttribute( "default-value", parameter.getDefaultValue() );
}
if ( parameter.getExpression() != null )
{
w.writeText( parameter.getExpression() );
}
w.endElement();
}