org.codehaus.plexus.component.configurator.ConfigurationListener Java Examples

The following examples show how to use org.codehaus.plexus.component.configurator.ConfigurationListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionallyConfigurableComponentConverter.java    From jdmn with Apache License 2.0 5 votes vote down vote up
@Override
public Object fromConfiguration(ConverterLookup lookup, PlexusConfiguration configuration, Class<?> type,
                                Class<?> enclosingType, ClassLoader loader, ExpressionEvaluator evaluator,
                                ConfigurationListener listener) throws ComponentConfigurationException {

    OptionallyConfigurableMojoComponent component;

    if (configuration == null) {
        throw new ComponentConfigurationException("Cannot instantiate component from null configuration");
    }

    // Instantiate the type as defined in Mojo configuration
    try {
        component = (OptionallyConfigurableMojoComponent)type.newInstance();
    }
    catch (InstantiationException | IllegalAccessException ex) {
        throw new ComponentConfigurationException(String.format(
                "Cannot instantiate configurable component type \"%s\" (%s)", type.getName(), ex.getMessage()), ex);
    }

    if (component == null) {
        throw new ComponentConfigurationException(String.format(
                "Failed to instantiate new configurable component type \"%s\"", type.getName()));
    }

    // Verify that we are deserializing the expected content type
    if (!configuration.getName().equals(component.getElementName())) {
        throw new ComponentConfigurationException(String.format(
                "Invalid component element \"%s\"; component definition accepts only \"%s\" elements", configuration.getName(), component.getElementName()));
    }

    // Deserialize from either simple or compound data depending on structure of the input configuration
    if (configuration.getChildCount() == 0) {
        return configureSimpleComponent(component, configuration);
    }
    else {
        return configureCompoundComponent(component, configuration);
    }
}
 
Example #2
Source File: DMNMojoComponentConfigurator.java    From jdmn with Apache License 2.0 5 votes vote down vote up
@Override
public void configureComponent(final Object component, final PlexusConfiguration configuration,
                               final ExpressionEvaluator evaluator, final ClassRealm realm,
                               final ConfigurationListener listener) throws ComponentConfigurationException {

    // Register custom type conversion for optionally-configurable types, i.e. those which can be specified as a
    // simple string or as a components with a name and configuration
    converterLookup.registerConverter(new OptionallyConfigurableComponentConverter());

    super.configureComponent(component, configuration, evaluator, realm, listener);
}
 
Example #3
Source File: IncludeProjectDependenciesComponentConfigurator.java    From incubator-hivemall with Apache License 2.0 5 votes vote down vote up
public void configureComponent(final Object component, final PlexusConfiguration configuration,
        final ExpressionEvaluator expressionEvaluator, final ClassRealm containerRealm,
        final ConfigurationListener listener) throws ComponentConfigurationException {
    addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm);

    converterLookup.registerConverter(new ClassRealmConverter(containerRealm));

    ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();

    converter.processConfiguration(converterLookup, component, containerRealm.getClassLoader(),
        configuration, expressionEvaluator, listener);
}
 
Example #4
Source File: IncludeProjectDependenciesComponentConfigurator.java    From protostuff-compiler with Apache License 2.0 5 votes vote down vote up
@Override
public void configureComponent(Object component, PlexusConfiguration configuration,
                               ExpressionEvaluator evaluator, ClassRealm realm, ConfigurationListener listener) throws ComponentConfigurationException {
    addProjectDependenciesToClassRealm(evaluator, realm);
    converterLookup.registerConverter(new ClassRealmConverter(realm));
    ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
    converter.processConfiguration(converterLookup, component, realm.getParentClassLoader(), configuration,
            evaluator, listener);
}
 
Example #5
Source File: IncludeProjectDependenciesComponentConfigurator.java    From protostuff with Apache License 2.0 5 votes vote down vote up
public void configureComponent(Object component, PlexusConfiguration configuration,
        ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm,
        ConfigurationListener listener)
        throws ComponentConfigurationException
{

    addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm);
    converterLookup.registerConverter(new ClassRealmConverter(containerRealm));
    ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
    converter.processConfiguration(converterLookup, component, containerRealm.getClassLoader(), configuration,
            expressionEvaluator, listener);
}
 
Example #6
Source File: MojoConfigurator.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void configureComponent(final Object mojoInstance, //
    final PlexusConfiguration pluginConfigurationFromMaven, //
    final ExpressionEvaluator evaluator, //
    final ClassRealm realm, //
    final ConfigurationListener listener) throws ComponentConfigurationException {

  super.configureComponent(mojoInstance, pluginConfigurationFromMaven, evaluator, realm, listener);
}
 
Example #7
Source File: IncludeProjectDependenciesComponentConfigurator.java    From swagger-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void configureComponent(Object component, PlexusConfiguration configuration,
                               ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm,
                               ConfigurationListener listener)
        throws ComponentConfigurationException {
    addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm);

    ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
    converter.processConfiguration(converterLookup, component, containerRealm.getClassLoader(), configuration,
            expressionEvaluator, listener);
}