Java Code Examples for org.codehaus.plexus.interpolation.StringSearchInterpolator

The following examples show how to use org.codehaus.plexus.interpolation.StringSearchInterpolator. These examples are extracted from open source projects. 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 Project: nexus-public   Source File: DataStoreSupport.java    License: 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 Project: mvn-golang   Source File: GolangGetMojo.java    License: 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 Project: nexus-public   Source File: ConfigurationBuilder.java    License: 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()));
  }
}