In this step the Hotdog Vendor bundle is created that imports the package
containing the VendorService interface and registers an
implementation of the service with the OSGi framework.
org.eclipse.soda.sat.tutorial.vendor.hotdog that is
targeted for the standard OSGi framework.
org.eclipse.soda.sat.tutorial.vendor.hotdog, making it
match the name of the plug-in project.
Hotdog Vendor.
Take care on the second page of the
wizard to uncheck the checkbox titled Generate an activator, a Java
class that controls the plug-in's life cycle since we do not want
the PDE to generate a bundle activator. We shall be using the SAT's
Bundle Activator Wizard to generate a bundle activator.
META-INF/MANIFEST.MF file using the
manifest editor. Turn to the Dependencies page and add the
bundle org.eclipse.soda.sat.tutorial.vendor.service to the
Automated Management of Dependencies list. Doing this will
result in the bundle appearing in the plug-in project's Plug-in
Dependencies.
Import-Package manifest header rather than the
Require-Bundle manifest header.
org.eclipse.soda.sat.tutorial.vendor.hotdog.
HotdogVendor that
implements the VendorService interface as follows:
package org.eclipse.soda.sat.tutorial.vendor.hotdog;
import org.eclipse.soda.sat.tutorial.vendor.service.VendorService;
public class HotdogVendor extends Object implements VendorService {
private String name;
public HotdogVendor(String name) {
super();
setName(name);
}
public String getName() {
return name;
}
public String sell() {
return "hotdog"; //$NON-NLS-1$
}
private void setName(String name) {
this.name = name;
}
}
org.eclipse.soda.sat.tutorial.vendor.service will now
appear in the Imported Packages list. This is the recommended
way to manage a bundle's dependencies.
org.eclipse.soda.sat.tutorial.vendor.hotdog and then
choose File > New > Other... and then expand
Service Activator Toolkit, select Bundle Activator and
click the Next button.
org.eclipse.soda.sat.tutorial.vendor.hotdog.bundle and the
Name field should have been set to Activator. Click
the Next button.
VendorService. The interface
org.eclipse.soda.sat.tutorial.vendor.service.VendorService
should now appear in the Exported Service list.
package org.eclipse.soda.sat.tutorial.vendor.hotdog.bundle;
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("Ball Park"); //$NON-NLS-1$
addExportedService(VendorService.SERVICE_NAME, service, null);
}
protected void deactivate() {
LogUtility.logInfo("The Hotdog Vendor bundle has been deactivated"); //$NON-NLS-1$
}
}
org.eclipse.soda.sat.core.framework will now
appear in the Imported Packages list.
META-INF/MANIFEST.MF file should be as
follows.
Manifest-Version: 1.0 Bundle-Activator: org.eclipse.soda.sat.tutorial.vendor.hotdog.bundle.Activator Bundle-ManifestVersion: 2 Bundle-Name: Hotdog Vendor Bundle-SymbolicName: org.eclipse.soda.sat.tutorial.vendor.hotdog Bundle-Version: 1.0.0 Import-Package: org.eclipse.soda.sat.core.framework, org.eclipse.soda.sat.core.util, org.eclipse.soda.sat.tutorial.vendor.service
Copyright © 2001, 2007 IBM Corporation and others. All Rights Reserved.