/** * Create a copy of the configuration with a provided PID. * * @param aPid The pid of the configuration * @return A copy of this configuration with the given PID */ public Configuration copy(final String aPid) { final Configuration result = new Configuration(aPid); final Enumeration<String> keyEnum = this.getProperties().keys(); while (keyEnum.hasMoreElements()) { final String key = keyEnum.nextElement(); result.getProperties().put(key, this.getProperties().get(key)); } return result; }
/** * Resolve variables in the feature. * Variables are allowed in the values of framework properties and in the values of * configuration properties. * @param feature The feature * @param additionalVariables Optional additional variables */ public static void resolveVariables(final Feature feature, final Map<String,String> additionalVariables) { for(final Configuration cfg : feature.getConfigurations()) { final Set<String> keys = new HashSet<>(Collections.list(cfg.getProperties().keys())); for(final String key : keys) { final Object value = cfg.getProperties().get(key); cfg.getProperties().put(key, replaceVariables(value, additionalVariables, feature)); } } for(final Map.Entry<String, String> entry : feature.getFrameworkProperties().entrySet()) { // the value is always a string entry.setValue((String)replaceVariables(entry.getValue(), additionalVariables, feature)); } }
static void mergeConfigurations(final Configurations target, final Configurations source) { for(final Configuration cfg : source) { boolean found = false; for(final Configuration current : target) { if ( current.compareTo(cfg) == 0 ) { found = true; // merge / override properties final Enumeration<String> i = cfg.getProperties().keys(); while ( i.hasMoreElements() ) { final String key = i.nextElement(); current.getProperties().put(key, cfg.getProperties().get(key)); } break; } } if ( !found ) { final Configuration newCfg = cfg.copy(cfg.getPid()); target.add(newCfg); } } }
cfg.getProperties().put(Configuration.PROP_PREFIX + "content-path", contentPath); cfg.getProperties().put(Configuration.PROP_PREFIX + "content-package", packageArtifact.getId().toMvnId());
key = ".." + key.substring(1); newCfg.getProperties().put(key, value);
while ( keys.hasMoreElements() ) { String key = keys.nextElement(); Object val = cfg.getProperties().get(key);
while ( iter.hasNext() ) { final Configuration cfg = iter.next(); final String bundleId = (String)cfg.getProperties().get(Configuration.PROP_ARTIFACT_ID); if (bundleId != null) { final ArtifactId bundleArtifactId = ArtifactId.fromMvnId(bundleId); feature.getConfigurations().remove(found); } else { found.getProperties().remove(attr);