In this step the Popcorn Vendor bundle is created that imports the package
containing the VendorService interface and registers an
implementation of the service with the OSGi framework. This step is
very similar to the previous step where we created the Hotdog Vendor
bundle.
org.eclipse.soda.sat.tutorial.vendor.popcorn that is
targeted for the standard OSGi framework.
org.eclipse.soda.sat.tutorial.vendor.popcorn, making it
match the name of the plug-in project.
Popcorn 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.popcorn.
PopcornVendor that
implements the VendorService interface as follows:
package org.eclipse.soda.sat.tutorial.vendor.popcorn;
import org.eclipse.soda.sat.tutorial.vendor.service.VendorService;
public class PopcornVendor extends Object implements VendorService {
public String getName() {
return "Orville Redenbacher"; //$NON-NLS-1$
}
public String sell() {
return "popcorn"; //$NON-NLS-1$
}
}
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.popcorn and then
choose File > New >
Bundle Activator
and then expand Service Activator Toolkit.
org.eclipse.soda.sat.tutorial.vendor.popcorn.bundle and the
Name field should have been set to Activator. Click
the Next button.
VendorService. The interface
VendorService should now appear in the
Exported Service list.
org.eclipse.soda.sat.tutorial.vendor.popcorn.PopcornVendor.
package org.eclipse.soda.sat.tutorial.vendor.popcorn.bundle;
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(); //$NON-NLS-1$
}
private void addExportedVendorService() {
VendorService service = new PopcornVendor();
addExportedService(VendorService.SERVICE_NAME, service, null);
}
protected void deactivate() {
LogUtility.logInfo("The Popcorn 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.popcorn.bundle.Activator Bundle-ManifestVersion: 2 Bundle-Name: Popcorn Vendor Bundle-SymbolicName: org.eclipse.soda.sat.tutorial.vendor.popcorn 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, 2008 IBM Corporation and others. All Rights Reserved.