org.codehaus.plexus.interpolation.StringSearchInterpolator Java Examples

The following examples show how to use org.codehaus.plexus.interpolation.StringSearchInterpolator. 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: DataStoreSupport.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Interpolate configuration attributes when starting the data store.
 */
private Map<String, String> interpolatedAttributes() throws Exception {
  Map<String, String> attributes = configuration.getAttributes();

  Interpolator interpolator = new StringSearchInterpolator();
  interpolator.addValueSource(new SingleResponseValueSource("storeName", storeName));
  interpolator.addValueSource(new MapBasedValueSource(attributes));
  interpolator.addValueSource(new MapBasedValueSource(System.getProperties()));
  interpolator.addValueSource(new EnvarBasedValueSource());

  return attributes.entrySet().stream().collect(toMap(Entry::getKey, entry -> {
    try {
      return interpolator.interpolate(entry.getValue());
    }
    catch (InterpolationException e) {
      throw new IllegalArgumentException(e);
    }
  }));
}
 
Example #2
Source File: GolangGetMojo.java    From mvn-golang with Apache License 2.0 5 votes vote down vote up
@Nonnull
private String interpolate(@Nonnull final String str) throws IOException, InterpolationException {
  Interpolator interpolator = new StringSearchInterpolator();
  interpolator.addValueSource(new MapBasedValueSource(this.getProject().getProperties()));
  interpolator.addValueSource(new MapBasedValueSource(System.getProperties()));
  interpolator.addValueSource(new EnvarBasedValueSource());
  return interpolator.interpolate(str);
}
 
Example #3
Source File: ConfigurationBuilder.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private void interpolate() throws Exception {
  Interpolator interpolator = new StringSearchInterpolator();
  interpolator.addValueSource(new MapBasedValueSource(properties));
  interpolator.addValueSource(new MapBasedValueSource(System.getProperties()));
  interpolator.addValueSource(new EnvarBasedValueSource());

  for (Entry<String, String> entry : properties.entrySet()) {
    properties.put(entry.getKey(), interpolator.interpolate(entry.getValue()));
  }
}