The plug-in manifest file
Install an Eclipse plug-in in a subdirectory of the $INSTALL_DIR/eclipse
/plugins directory. The plug-in manifest file, plugin.xml, describes the plug‑in activation framework to the Eclipse run-time environment.
Eclipse uses a lazy loading implementation, which means it does not load and activate a plug-in until it is needed. At run time, Eclipse scans the subdirectories in $INSTALL_DIR/eclipse/plugins, parses the contents of each plug-in manifest file, and caches the information in the plug-in registry. If the Eclipse run time requires an extension, Eclipse loads the plug-in, using the registry information to instantiate the plug-in objects. The run-time environment for the BIRT Report Engine functions in a similar way.
The plug-in manifest file declares the required plug-in code and extension points to the plug-in registry. The plug-in run-time class provides the code segment. By lazily loading this code segment, the run-time environment minimizes start-up time and conserves memory resources.
The plug-in manifest file, plugin.xml, has the following structure:
*<plugin> is the root element.
*<extension> specifies extension points, related elements, and attributes that define the processing capabilities of the plug-in component.
Listing 22‑2 shows the contents of the plug-in manifest file, org.eclipse.birt
.sample.reportitem.rotatedlabel/plugin.xml. This file describes the required classes and extension points for the BIRT report item extension sample, rotated label, found in the Third Edition (published 2011):
http://www.actuate.com/birt/contributions
Listing 22‑2 Sample plug-in manifest file
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
id="rotatedLabel"
name="Rotated Label Extension"
point="org.eclipse.birt.report.designer.ui.reportitemUI">
<reportItemLabelUI
class="org.eclipse.birt.sample.reportitem.rotatedlabel
.RotatedLabelUI"/>
<model extensionName="RotatedLabel"/>
<palette icon="icons/rotatedlabel.jpg"/>
<editor
canResize="true"
showInDesigner="true"
showInMasterPage="true"/>
<outline icon="icons/rotatedlabel.jpg"/>
</extension>
<extension
id="rotatedLabel"
name="Rotated Label Extension"
point="org.eclipse.birt.report.model.reportItemModel">
<reportItem
class="org.eclipse.birt.sample.reportitem
.rotatedlabel.RotatedLabelItemFactoryImpl"
extensionName="RotatedLabel">
<property
defaultDisplayName="Display Text"
defaultValue="Rotated Label"
name="displayText"
type="string"/>
<property
defaultDisplayName="Rotation Angle"
defaultValue="-45"
name="rotationAngle"
type="string"/>
</reportItem>
</extension>
<extension
id="rotatedLabel"
name="Rotated Label Extension
point="org.eclipse.birt.report.engine
.reportitemPresentation">
<reportItem
class="org.eclipse.birt.sample.reportitem.rotatedlabel
.RotatedLabelPresentationImpl"
name="RotatedLabel"/>
</extension>
<extension
point="org.eclipse.birt.report.designer.ui
.elementAdapters">
<adaptable
class="org.eclipse.birt.report.model.api
.ExtendedItemHandle">
<adapter
factory="org.eclipse.birt.sample.reportitem
.rotatedlabel.views.RotatedLabelPageGeneratorFactory"
id="ReportDesign.AttributeView
.RotatedLabelPageGenerator"
priority="1"
singleton="false"
type="org.eclipse.birt.report.designer.ui.views
.IPageGenerator">
<enablement>
<test
forcePluginActivation="true"
property="ExtendItemHandle.extensionName"
value="RotatedLabel">
</test>
</enablement>
</adapter>
</adaptable>
</extension>
</plugin>
The plug-in run-time class
A plug-in runs within an instance of a plug-in run-time class. A plug-in run‑time class extends org.eclipse.core.runtime.Plugin, the abstract superclass for all plug‑in run-time class implementations. The Plugin run‑time class defines the methods for starting, managing, and stopping a plug-in instance.
The Plugin run-time class typically contains a reference to an Open Services Gateway Initiative (OSGi) resource bundle that manages the execution context. Plugin implements the interface, org.osgi.framework.BundleActivator, which installs, starts, stops, and uninstalls the OSGi resource bundle. The OSGi resource bundle implements a service registry to support the following services:
*Installing and uninstalling the resource bundle
*Subscribing to an event
*Registering a service object
*Retrieving a service reference
The OSGi platform provides a secure, managed, extensible Java framework for downloading, deploying, and managing service applications. For more information about the OSGi platform, visit the OSGi Alliance website at
http://www.osgi.org/.
Listing 22‑3 is a code example showing the life cycle and resource bundle methods for the report item plug-in, rotated label.
Listing 22‑3 Sample code for the rotated label report item plug-in
package org.eclipse.birt.sample.reportitem.rotatedlabel;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class RotatedLabelPlugin extends Plugin {
// The Plugin ID
public final static String PLUGIN_ID =
"org.eclipse.birt.sample.reportitem.rotatedlabel";
//The shared instance.
private static RotatedLabelPlugin plugin;
/**
* The constructor.
*/
public RotatedLabelPlugin( ) {
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance.
*/
public static RotatedLabelPlugin getDefault() {
return plugin;
}
 
}