public void notifyFieldChangeUsingSetter( String fieldName, Object value, Object target ) { delegate.notifyFieldChangeUsingSetter( fieldName, value, target ); if ( mojo == target ) { notify( fieldName, value ); } }
public void notifyFieldChangeUsingReflection( String fieldName, Object value, Object target ) { delegate.notifyFieldChangeUsingReflection( fieldName, value, target ); if ( mojo == target ) { notify( fieldName, value ); } }
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { List<String> compileClasspathElements; try { //noinspection unchecked compileClasspathElements = (List<String>) expressionEvaluator.evaluate("${project.compileClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException("There was a problem evaluating: ${project.compileClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildURLs(compileClasspathElements); for (URL url : urls) { containerRealm.addURL(url); } }
private URL[] buildURLs(List<String> runtimeClasspathElements) throws ComponentConfigurationException { // Add the projects classes and dependencies List<URL> urls = new ArrayList<URL>(runtimeClasspathElements.size()); for (String element : runtimeClasspathElements) { try { final URL url = new File(element).toURI().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); } } // Add the plugin's dependencies (so Trove stuff works if Trove isn't on return urls.toArray(new URL[urls.size()]); }
ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter(); converter.processConfiguration( converterLookup, request.getBean(), classLoader, plexusConfig, evaluator ); throw new BeanConfigurationException( e.getMessage(), e );
protected Object instantiateObject( Class clazz ) throws ComponentConfigurationException { Object retValue; try { retValue = clazz.newInstance(); return retValue; } catch ( IllegalAccessException e ) { throw new ComponentConfigurationException( "Class '" + clazz.getName() + "' cannot be instantiated", e ); } catch ( InstantiationException e ) { throw new ComponentConfigurationException( "Class '" + clazz.getName() + "' cannot be instantiated", e ); } }
private void setValueUsingField( Object value ) throws ComponentConfigurationException { try { boolean wasAccessible = field.isAccessible(); if ( !wasAccessible ) { field.setAccessible( true ); } if ( listener != null ) { listener.notifyFieldChangeUsingReflection( fieldName, value, object ); } field.set( object, value ); if ( !wasAccessible ) { field.setAccessible( false ); } } catch ( IllegalAccessException e ) { throw new ComponentConfigurationException( "Cannot access field: " + field, e ); } catch ( IllegalArgumentException e ) { throw new ComponentConfigurationException( "Cannot assign value '" + value + "' (type: " + value.getClass() + ") to " + field, e ); } }
public ConfigurationConverter lookupConverterForType( Class<?> type ) throws ComponentConfigurationException { ConfigurationConverter retValue = converterMap.get( type ); if ( retValue == null ) { if ( customConverters != null ) { retValue = findConverterForType( customConverters, type ); } if ( retValue == null ) { retValue = findConverterForType( converters, type ); } if ( retValue == null ) { // this is highly irregular throw new ComponentConfigurationException( "Configuration converter lookup failed for type: " + type ); } converterMap.put( type, retValue ); } return retValue; }
"Configuring mojo '" + mojoDescriptor.getId() + "' with " + configuratorId + " configurator -->" ); configurator.configureComponent( mojo, configuration, expressionEvaluator, pluginRealm, validator ); if ( e.getFailedConfiguration() != null ) message += " for parameter " + e.getFailedConfiguration().getName(); message += ": " + e.getMessage();
/** * Configure the mojo with the given plexus configuration * * @param mojo * @param pluginConfiguration * @return a Mojo instance * @throws Exception */ protected Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration ) throws Exception { validateContainerStatus(); ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub(); configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() ); return mojo; }
public void configureComponent( Object component, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm ) throws ComponentConfigurationException { configureComponent( component, configuration, expressionEvaluator, containerRealm, null ); }
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { List<String> runtimeClasspathElements; try { // noinspection unchecked runtimeClasspathElements = (List<String>) expressionEvaluator .evaluate("${project.runtimeClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException( "There was a problem evaluating: ${project.runtimeClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildURLs(runtimeClasspathElements); for (URL url : urls) { containerRealm.addConstituent(url); } }
private URL[] buildURLs(List<String> runtimeClasspathElements) throws ComponentConfigurationException { // Add the projects classes and dependencies List<URL> urls = new ArrayList<URL>(runtimeClasspathElements.size()); for (String element : runtimeClasspathElements) { try { final URL url = new File(element).toURI().toURL(); urls.add(url); } catch (MalformedURLException e) { throw new ComponentConfigurationException("Unable to access project dependency: " + element, e); } } // Add the plugin's dependencies (so Trove stuff works if Trove isn't on return urls.toArray(new URL[urls.size()]); }
value = expressionEvaluator.evaluate( expression ); throw new ComponentConfigurationException( configuration, msg, e );
public Object fromString(final String str) throws ComponentConfigurationException { assert str != null; try { return new URI(str); } catch (URISyntaxException e) { throw new ComponentConfigurationException("Unable to convert to URI: " + str, e); } } }
private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { List<String> compileClasspathElements; try { //noinspection unchecked compileClasspathElements = (List<String>) expressionEvaluator.evaluate("${project.compileClasspathElements}"); } catch (ExpressionEvaluationException e) { throw new ComponentConfigurationException("There was a problem evaluating: ${project.compileClasspathElements}", e); } // Add the project dependencies to the ClassRealm final URL[] urls = buildURLs(compileClasspathElements); for (URL url : urls) { containerRealm.addConstituent(url); } }
public Object fromString( String str ) throws ComponentConfigurationException { try { return new URL( str ); } catch ( MalformedURLException e ) { throw new ComponentConfigurationException( "Unable to convert '" + str + "' to an URL", e ); } } }
public Object fromString( String str ) throws ComponentConfigurationException { try { return Class.forName( str ); } catch ( ClassNotFoundException e ) { throw new ComponentConfigurationException( "Unable to find class in conversion", e ); } } }
public Object fromString( String str ) throws ComponentConfigurationException { try { return Integer.valueOf( str ); } catch ( NumberFormatException e ) { throw new ComponentConfigurationException( "Not a number: '" + str + "'", e ); } }
protected Class loadClass( String classname, ClassLoader classLoader ) throws ComponentConfigurationException { Class retValue; try { retValue = classLoader.loadClass( classname ); } catch ( ClassNotFoundException e ) { throw new ComponentConfigurationException( "Error loading class '" + classname + "'", e ); } return retValue; }