Step 3: Updating the Popcorn Vendor Bundle to Export a Service with Registered Properties

In this step the Popcorn Vendor bundle is updated to export an implementation of the VendorService with a service property that describes its spiciness.

  1. In the Package Explorer find the org.eclipse.soda.sat.tutorial.vendor.popcorn project.
  2. Find the bundle activator and update it as follows. The updates are highlighted in bold.
    package org.eclipse.soda.sat.tutorial.vendor.popcorn.bundle;
    
    import java.util.Dictionary;
    import java.util.Hashtable;
    
    import org.eclipse.soda.sat.core.framework.BaseBundleActivator;
    import org.eclipse.soda.sat.core.util.LogUtility;
    import org.eclipse.soda.sat.tutorial.vendor.popcorn.PopcornVendor;
    import org.eclipse.soda.sat.tutorial.vendor.service.VendorService;
    
    public class Activator extends BaseBundleActivator {
      protected void activate() {
        LogUtility.logInfo("The Popcorn Vendor bundle has been activated");  //$NON-NLS-1$
        addExportedVendorService();
      }
    
      private void addExportedVendorService() {
        VendorService service = new PopcornVendor();
        Dictionary properties = new Hashtable(11);
        properties.put(VendorService.SPICINESS_PROPERTY, new Integer(3));
        addExportedService(VendorService.SERVICE_NAME, service, properties);		
      }
    
      protected void deactivate() {
        LogUtility.logInfo("The Popcorn Vendor bundle has been deactivated");  //$NON-NLS-1$
      }
    }
  3. As you can see, the addExportedVendorService() method has been updated to create a Dictionary of properties that is passed to the addExportedService(String, Object, Dictionary) method when the VendorService is exported. In this case the single property key VendorService.SPICINESS_PROPERTY is registered with the value new Integer(3).