public void configureComponent( Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener ) throws ComponentConfigurationException { if ( !( component instanceof MapOrientedComponent ) ) { throw new ComponentConfigurationException( "This configurator can only process implementations of " + MapOrientedComponent.class.getName() ); } MapConverter converter = new MapConverter(); Map context = (Map) converter.fromConfiguration( converterLookup, configuration, null, null, containerRealm, expressionEvaluator, listener ); ( (MapOrientedComponent) component ).setComponentConfiguration( context ); }
Map context = (Map) converter.fromConfiguration(converterLookup, configuration, null,
public void configureComponent( Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener ) throws ComponentConfigurationException { if ( !( component instanceof MapOrientedComponent ) ) { throw new ComponentConfigurationException( "This configurator can only process implementations of " + MapOrientedComponent.class.getName() ); } MapConverter converter = new MapConverter(); Map context = (Map) converter.fromConfiguration( converterLookup, configuration, null, null, containerRealm, expressionEvaluator, listener ); ( (MapOrientedComponent) component ).setComponentConfiguration( context ); }
@Override public void configureComponent( final Object component, final PlexusConfiguration configuration, final ExpressionEvaluator evaluator, final ClassRealm realm, final ConfigurationListener listener ) throws ComponentConfigurationException { if ( component instanceof MapOrientedComponent ) { ( (MapOrientedComponent) component ).setComponentConfiguration( /* <--- */(Map<?, ?>) new MapConverter().fromConfiguration( converterLookup, configuration, Map.class, component.getClass(), realm, evaluator, listener ) ); } else { throw new ComponentConfigurationException( "Component does not implement " + MapOrientedComponent.class ); } } }
Map context = (Map) converter.fromConfiguration(converterLookup, configuration, null,
public Object fromConfiguration( final ConverterLookup lookup, final PlexusConfiguration configuration, final Class<?> type, final Type[] typeArguments, final Class<?> enclosingType, final ClassLoader loader, final ExpressionEvaluator evaluator, final ConfigurationListener listener ) throws ComponentConfigurationException { final Object value = fromExpression( configuration, evaluator, type ); if ( null != value ) { return value; } try { final Map<Object, Object> map = instantiateMap( configuration, type, loader ); final Class<?> elementType = findElementType( typeArguments ); if ( Object.class == elementType || String.class == elementType ) { for ( int i = 0, size = configuration.getChildCount(); i < size; i++ ) { final PlexusConfiguration element = configuration.getChild( i ); map.put( element.getName(), fromExpression( element, evaluator ) ); } return map; } // handle maps with complex element types... final ConfigurationConverter converter = lookup.lookupConverterForType( elementType ); for ( int i = 0, size = configuration.getChildCount(); i < size; i++ ) { Object elementValue; final PlexusConfiguration element = configuration.getChild( i );