Search in sources :

Example 1 with ValueSource

use of org.codehaus.plexus.interpolation.ValueSource in project maven-plugins by apache.

the class GenerateApplicationXmlMojo method buildEnvEntries.

/**
     * Builds the env-entries based on the configuration.
     * 
     * @return a list of EnvEntry object(s)
     * @throws EarPluginException if the configuration is invalid
     */
private List<EnvEntry> buildEnvEntries() throws EarPluginException {
    final List<EnvEntry> result = new ArrayList<EnvEntry>();
    if (envEntries == null) {
        return result;
    }
    try {
        StringSearchInterpolator ssi = new StringSearchInterpolator();
        ValueSource vs = new MapBasedValueSource(project.getProperties());
        ssi.addValueSource(vs);
        final PlexusConfiguration[] allEnvEntries = envEntries.getChildren(EnvEntry.ENV_ENTRY);
        for (PlexusConfiguration envEntry : allEnvEntries) {
            // CHECKSTYLE_OFF: LineLength
            final String childDescription = interpolate(ssi, envEntry.getChild(EnvEntry.DESCRIPTION).getValue());
            final String childEnvEntryName = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_NAME).getValue());
            final String childEnvEntryType = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_TYPE).getValue());
            final String childEnvEntryValue = interpolate(ssi, envEntry.getChild(EnvEntry.ENV_ENTRY_VALUE).getValue());
            try {
                result.add(new EnvEntry(childDescription, childEnvEntryName, childEnvEntryType, childEnvEntryValue));
            } catch (IllegalArgumentException e) {
                throw new EarPluginException("Invalid env-entry [" + envEntry + "]", e);
            }
        }
        return result;
    } catch (InterpolationException e) {
        throw new EarPluginException("Interpolation exception:", e);
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) ValueSource(org.codehaus.plexus.interpolation.ValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource) ArrayList(java.util.ArrayList) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Example 2 with ValueSource

use of org.codehaus.plexus.interpolation.ValueSource in project maven-plugins by apache.

the class GenerateApplicationXmlMojo method buildEjbEntries.

/**
     * Builds the ejb-ref based on the configuration.
     * 
     * @return a list of EjbRef object(s)
     * @throws EarPluginException if the configuration is invalid
     */
private List<EjbRef> buildEjbEntries() throws EarPluginException {
    final List<EjbRef> result = new ArrayList<EjbRef>();
    if (ejbRefs == null) {
        return result;
    }
    try {
        StringSearchInterpolator ssi = new StringSearchInterpolator();
        ValueSource vs = new MapBasedValueSource(project.getProperties());
        ssi.addValueSource(vs);
        final PlexusConfiguration[] allEjbEntries = ejbRefs.getChildren(EjbRef.EJB_REF);
        for (PlexusConfiguration ejbEntry : allEjbEntries) {
            // CHECKSTYLE_OFF: LineLength
            final String childDescription = interpolate(ssi, ejbEntry.getChild(EnvEntry.DESCRIPTION).getValue());
            final String childEjbEntryName = interpolate(ssi, ejbEntry.getChild(EjbRef.EJB_NAME).getValue());
            final String childEjbEntryType = interpolate(ssi, ejbEntry.getChild(EjbRef.EJB_TYPE).getValue());
            final String childEjbLookupNameValue = interpolate(ssi, ejbEntry.getChild(EjbRef.EJB_LOOKUP_NAME).getValue());
            try {
                result.add(new EjbRef(childDescription, childEjbEntryName, childEjbEntryType, childEjbLookupNameValue));
            } catch (IllegalArgumentException e) {
                throw new EarPluginException("Invalid ejb-ref [" + ejbEntry + "]", e);
            }
        }
        return result;
    } catch (InterpolationException e) {
        throw new EarPluginException("Interpolation exception:", e);
    }
}
Also used : PlexusConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) ValueSource(org.codehaus.plexus.interpolation.ValueSource) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource) ArrayList(java.util.ArrayList) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) MapBasedValueSource(org.codehaus.plexus.interpolation.MapBasedValueSource)

Aggregations

ArrayList (java.util.ArrayList)2 PlexusConfiguration (org.codehaus.plexus.configuration.PlexusConfiguration)2 InterpolationException (org.codehaus.plexus.interpolation.InterpolationException)2 MapBasedValueSource (org.codehaus.plexus.interpolation.MapBasedValueSource)2 StringSearchInterpolator (org.codehaus.plexus.interpolation.StringSearchInterpolator)2 ValueSource (org.codehaus.plexus.interpolation.ValueSource)2