package com.kuebler.osgi.ds.equinox;

import java.io.IOException;
import java.util.Dictionary;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;

import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;

/**
 *
 * Add additional information to augment a property for the application being debugged
 *
 */
@Component
public class EquinoxAppConfigurator {

	@Activate
	public void activate() throws IOException {
		ConfigurationAdmin configurationAdmin = _configAdmin.get();
		Configuration configuration = configurationAdmin.getConfiguration(EquinoxSCR.class.getName());
		Dictionary<String, Object> properties = configuration.getProperties();
		Properties properties2 = System.getProperties();
		configuration.update(properties);
	}

	
	private AtomicReference<ConfigurationAdmin> _configAdmin = new AtomicReference<ConfigurationAdmin>();

	  /**
	   * OSGi bind method
	   * @param name
	   */
	  @Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC)
	  public void bindConfigAdmin(ConfigurationAdmin configAdmin) {
	    _configAdmin.set(configAdmin);
	  }

	  /**
	   * OSGi unbind method
	   * @param name
	   */
	  public void unbindConfigAdmin(ConfigurationAdmin name) {
	    _configAdmin.compareAndSet(name, null);
	  }}

@@ -88,24 +88,53 @@
 ictionary;%0D%0A
+import java.util.Hashtable;%0D%0A
 import java.
@@ -1029,90 +1029,324 @@
 s = 
-configuration.getProperties();%0D%0A%09%09Properties properties2 = System.getProperties();
+new Hashtable%3C%3E();%0D%0A%09%09String application = System.getProperty(%22eclipse.application%22);%0D%0A%09%09String product = System.getProperty(%22eclipse.product%22);%0D%0A%09%09%0D%0A%09%09if(application != null) %7B%0D%0A%09%09%09properties.put(%22eclipse.application%22, application);%0D%0A%09%09%7D%0D%0A%09%09if(product != null) %7B%0D%0A%09%09%09properties.put(%22eclipse.product%22, product);%0D%0A%09%09%7D
 %0D%0A%09%09

read application name