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()]); }
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()]); }
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 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); } }
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); } } }
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; }
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()]); }
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 ); } }
public ComponentValueSetter( String fieldName, Object object, ConverterLookup lookup, ConfigurationListener listener ) throws ComponentConfigurationException { this.fieldName = fieldName; this.object = object; this.lookup = lookup; this.listener = listener; if ( object == null ) { throw new ComponentConfigurationException( "Component is null" ); } initSetter(); initField(); if ( setter == null && field == null ) { throw new ComponentConfigurationException( "Cannot find setter nor field in " + object.getClass().getName() + " for '" + fieldName + "'" ); } if ( setterTypeConverter == null && fieldTypeConverter == null ) { throw new ComponentConfigurationException( "Cannot find converter for " + setterParamType.getName() + ( fieldType != null && !fieldType.equals( setterParamType ) ? " or " + fieldType.getName() : "" ) ); } }
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; }
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; }
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 addEntry( Properties properties, String element, PlexusConfiguration property, ExpressionEvaluator expressionEvaluator ) throws ComponentConfigurationException { Object name = fromExpression( property.getChild( "name" ), expressionEvaluator ); if ( name == null ) { String msg = "Trying to convert the configuration element: '" + element + "', missing child element 'name' for property."; throw new ComponentConfigurationException( msg ); } Object value = fromExpression( property.getChild( "value" ), expressionEvaluator ); if ( value == null ) { properties.setProperty( name.toString(), "" ); } else { properties.setProperty( name.toString(), value.toString() ); } }
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 ); }
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); } }
throw new ComponentConfigurationException( "When configuring a basic element the configuration cannot " + "contain any child elements. " + "Configuration element '" + configuration.getName() + "'." );