package eu.scasefp7.eclipse.services.nlp.provider;


//import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin;
//import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ExportRegistration;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import eu.scasefp7.eclipse.services.nlp.INLPService;

/**
 * @author emaorli
 *
 */
public class Activator implements BundleActivator {

    private ServiceRegistration<INLPService> nlpRegistration = null;
//    private ServiceRegistration<ContainerTypeDescription> containerRegistration = null;
    
	@Override
	public void start(BundleContext bundleContext) throws Exception {
//		// Register an instance of NLPServiceNamespace
//	    this.namespaceRegistration = bundleContext.registerService(Namespace.class, new NLPServiceNamespace(), null);
//        // Register an instance of TimezoneContainerTypeDescription (see class below)
//	    this.containerRegistration = bundleContext.registerService(ContainerTypeDescription.class, new NLPServiceContainerTypeDescription(), null);
	    
	    
	    // this.nlpRegistration = bundleContext.registerService(INLPService.class.getName(), new INLPService(), properties)
//	    RemoteServiceAdmin rsa = new RemoteServiceAdmin(bundleContext.getBundle());
//	    List<ExportRegistration> srs = rsa.getExportedRegistrations();
	}
	
	

	@Override
	public void stop(BundleContext bundleContext) throws Exception {
//	    this.namespaceRegistration.unregister();
//        this.containerRegistration.unregister();
	}
        
	
}

@@ -226,16 +226,258 @@
 ation;%0D%0A
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;%0D%0Aimport org.eclipse.core.runtime.preferences.IPreferencesService;%0D%0Aimport org.eclipse.ui.PlatformUI;%0D%0Aimport org.eclipse.ui.services.IServiceLocator;%0D%0A
 import o
@@ -657,16 +657,97 @@
 ervice;%0D
+%0Aimport eu.scasefp7.eclipse.services.nlp.provider.config.NLPServiceConfigurator;%0D
 %0A%0D%0A/**%0D%0A
@@ -900,16 +900,72 @@
  null;%0D%0A
+    private IPreferenceChangeListener listener = null;%0D%0A
 //    pr
@@ -1836,197 +1836,905 @@
 ;%0D%0A%09
-%7D%0D%0A%09%0D%0A%09%0D%0A%0D%0A%09@Override%0D%0A%09public void stop(BundleContext bundleContext) throws Exception %7B%0D%0A//%09    this.namespaceRegistration.unregister();%0D%0A//        this.containerRegistration.unregister();
+%0D%0A%09    %0D%0A%09    IServiceLocator serviceLocator = PlatformUI.getWorkbench();%0D%0A%09    IPreferencesService prefsService = (IPreferencesService) serviceLocator.getService(IPreferencesService.class);%0D%0A        %0D%0A%09    this.listener = new NLPServiceConfigurator();%0D%0A%09    prefsService.getRootNode().addPreferenceChangeListener(this.listener);%0D%0A%09    %0D%0A%09%7D%0D%0A%09%0D%0A%09%0D%0A%0D%0A%09@Override%0D%0A%09public void stop(BundleContext bundleContext) throws Exception %7B%0D%0A//%09    this.namespaceRegistration.unregister();%0D%0A//        this.containerRegistration.unregister();%0D%0A%09    %0D%0A%09    if(this.listener != null) %7B%0D%0A%09        IServiceLocator serviceLocator = PlatformUI.getWorkbench();%0D%0A%09        IPreferencesService prefsService = (IPreferencesService) serviceLocator.getService(IPreferencesService.class);%0D%0A%09        prefsService.getRootNode().removePreferenceChangeListener(this.listener);%0D%0A%09        this.listener = null;%0D%0A%09    %7D%0D%0A%09          
 %0D%0A%09%7D

Add prefs change listener