In this step the Hotdog Vendor bundle is updated to export an
implementation of the VendorService with a property that
describes its spiciness.
org.eclipse.soda.sat.tutorial.vendor.hotdog project.
package org.eclipse.soda.sat.tutorial.vendor.hotdog.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.hotdog.HotdogVendor;
import org.eclipse.soda.sat.tutorial.vendor.service.VendorService;
public class Activator extends BaseBundleActivator {
protected void activate() {
LogUtility.logInfo("The Hotdog Vendor bundle has been activated"); //$NON-NLS-1$
addExportedVendorService();
}
private void addExportedVendorService() {
VendorService service = new HotdogVendor();
Dictionary properties = new Hashtable(11);
properties.put(VendorService.SPICINESS_PROPERTY, new Integer(10));
addExportedService(VendorService.SERVICE_NAME, service, properties);
}
protected void deactivate() {
LogUtility.logInfo("The Hotdog Vendor bundle has been deactivated"); //$NON-NLS-1$
}
}
addExportedVendorService() methods 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(10).
SPICINESS_PROPERTY in the
service interface, in this case VendorService, is a useful
technique since it defines a common property key that can be used by all
bundles that implement the interface and register a service.
System.setProperty(String, String),
registered service properties are instances of Object not
just a String.
Copyright © 2001, 2008 IBM Corporation and others. All Rights Reserved.