[go: up one dir, main page]

0% found this document useful (0 votes)
54 views27 pages

MT 07 Eclipse Plug in

The document discusses Eclipse plug-ins, including their structure, manifest files, dependencies, extensions, and development. Key points: - Plug-ins have a JAR file structure containing code, resources, and manifest files describing the plug-in. - The manifest files define the plug-in ID, version, dependencies, exported packages, and extensions. - Extensions allow plug-ins to

Uploaded by

lakshmiepathy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views27 pages

MT 07 Eclipse Plug in

The document discusses Eclipse plug-ins, including their structure, manifest files, dependencies, extensions, and development. Key points: - Plug-ins have a JAR file structure containing code, resources, and manifest files describing the plug-in. - The manifest files define the plug-in ID, version, dependencies, exported packages, and extensions. - Extensions allow plug-ins to

Uploaded by

lakshmiepathy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Eclipse Plug-ins

Instructor:Yongjie Zheng February 28, 2013

CS 490MT/5590MT Software Methods and Tools

Eclipse Plug-ins

Plug-in Structure

MANIFEST.MF and plugin.xml Plug-in declaration Plug-in runtime Plug-in dependencies Extensions and extension points

Plug-in Manifest

Activator or Plug-in Class Development of Plug-ins


2

Plug-in Structure

The installed Eclipse plug-ins can be found in the plugins directory of the Eclipse folder. The plug-in JAR name must be a concatenation of the plug-in identier, and underscore, and the plugin version in dot separated form. For example,

org.eclipse.ui_3.103.0.v20120521-2329.jar

Plug-in Structure, cont.

A plug-in JAR typically includes

Java class les: the implementation of the behavior of the plug-in. Icons and other resources META/MANIFEST.MF: a le describing the runtime aspects of the plug-in such as identier, version, and plug-in dependencies. plugin.xml: a le in XML format describing extensions and extension points.
4

Plug-in Structure, cont.

Eclipse plug-ins are loaded lazily on an as-needed basis, thus reducing both the startup time and the memory usage of Eclipse. On startup, plug-in loader scans the MANIFEST.MF and plugin.xml les for each plug-in and then builds a structure containing the information. The code of an Eclipse plug-in is loaded only when the plug-in is activated (i.e. its functionality is needed at runtime). Eclipse plug-ins are loaded but not unloaded (as of Eclipse 3.1).
5

Plug-in Manifest

There are two plug-in manifest les: META-INF/ MANIFEST.MF and plugin.xml, which dene how this plug-in relates to all the others in the system. Eclipse provides a plug-in manifest editor for developers to edit the information about

Plug-in declaration Plug-in runtime (e.g. Export-Package) Plug-in dependencies Extensions and extension points
6

Plug-in Declaration

Plug-in identier: uniquely identies the plug-in and is typically constructed using Java package naming conventions (e.g. edu.umkc.<projectName>). Plug-in version: three numbers separated by periods.

The rst number indicates the major version; the second number indicates the minor version; the third number indicates the service level. You can specify an optional qualier that can include alphanumeric characters. E.g. 1.0.0.beta At startup, if there are two plug-ins with the same identier, Eclipse will choose the latest by comparing the major version number rst, then the minor version number, and so on.
7

Plug-in Declaration, cont.

Plug-in name and provider: both are humanreadable text, can be anything, and are not required to be unique. Plug-in activator: every plug-in optionally can declare a class that represents the plug-in from a programmatic standpoint. This class is referred to as an Activator.

Plug-in Runtime

Bundle-Classpath: this property is usally omitted. Export-Package: a comma-separated list indicating which packages of the plug-in are accessible to other plug-ins.

All other packages will be hidden from clients at all times. This corresponds to the export property of the OSGi bundle, or the provided interface of a component (module) we discussed.
9

Plug-in Dependencies

The plug-in loader instantiates a separate class loader for each loaded plug-in, and uses Require-Bundle or Import-Package to determine which other plug-ins/ classes will be needed. Require-Bundle: species the names of the required plug-ins or bundles.

Can be seen as required service providers.

Import-Package: species the names of the packages that are required. Can be seen as required services. Not used as much as Require-Bundle.
10

Plug-in Dependencies, cont.

If a plug-in requires not just any version of another plug-in, select that plug-in in the Dependencies tab of the plug-in manifest editor and click the Properties... button. This opens the required plug-in properties dialog where you can specify an exact version or a range of versions.
11

Plug-in Dependencies, cont.

About Java Build Path and the Dependencies declaration.

Java build path species the compile-time classpath of a plug-in project. The dependency list species the runtime classpath of a plug-in project. Any changes to the dependency list will automatically be reected in the Java build path, but not the reverse. Edit the dependency list rather than the Java build path so that the two are automatically in sync. NoClassDefFoundError if they get out of sync.
12

Extensions and Extension Points

A plug-in declares extension points so that other plug-ins can extend the functionality of the original plug-in in a controlled manner. This mechanism provides a layer of separation so that the original plug-in does not need to know about the existence of the extending plug-ins. Plug-ins declare extension points and extensions as part of their plug-in manifest. - this approach allows Eclipse to load information about the extensions declared in various plug-ins without loading the plug-ins (code) themselves.
13

Extensions and Extension Points, cont.

One plug-in declares an extension point in its plugin manifest, exposing a minimal set of interfaces and related classes for others to use. Other plug-ins declare extensions to that extension point, implementing the appropriate interfaces and referencing or building on the classes provided.

14

Extensions and Extension Points, cont.

Each type of extension point may require different attributes to dene the extension. You can nd documentation for an existing Eclipse extension point in the Eclipse help (select Help > Help Contents, then in the Help dialog, select Platform Plug-in Developer Guid > Reference > Extension Points Reference) Note that to extend an extension point declared by another plug-in, you also need to include that plug-in in your dependency list.
15

Extensions and Extension Points, cont.

When dening an extension point in Eclipse, you need to specify

Extension Point ID: [the plug-ins id].[a local identier] (e.g. edu.umkc.myplugin.extpoint) Extension Point Name: human readable text. Extension Point Schema: this will be automatically populated once the above information is provided.

In addition, you can add more element/attribute to your extension point. At some point, you may need to create an attribute (e.g. named class) of the java type for a new element.
16

Plug-in Related APIs

org.eclipse.core.runtime.Platform

getBundle(String) - returns the bundle with the specied unique identier. getExtensionRegistry() - returns the extension registry of this platform. getState() getCongurationElementsFor (String extensionPointId) returns all conguration elements from all extensions congured into the identied extension point. getExtensionPoint (String extensionPointId)
17

Plug-ins and Bundles

Plug-in extension registry

Activator or Plug-in Class

Every plug-in optionally can have an Activator class. The Eclipse system always instantiates exactly one instance of an active plug-ins Activator class. Do not create instances of this class yourself. Startup and shutdown

The plug-in loader noties the activator when the plug-in is loaded via the start() method and when the plug-in shuts down via the stop() method. It is not recommend to override these two methods.
18

Development of Plug-ins

Plug-in Development Environment (PDE) Views Creating a Plug-in Project Launching the Runtime Workbench Installing plug-ins Existing Eclipse Plug-ins

19

PDE Views

In the Eclipse workbench, select Window > Show View > Other, and then expand Plug-in Development. The Plug-in Registration view: displays a tree view of all the installed plug-ins. The Plug-ins view: shows a list of external plug-ins and plug-in projects in the current workspace.

Double-clicking on a plug-in opens the plugin in an editor for viewing. Right click a plug-in, and there are several useful context menus: Add to Java Search, Open Dependencies, Import As, ...

The Plug-in Dependencies view


20

Creating a Plug-in Project

Use the New Project wizard provided by Eclipse

In Eclipse, select File > New > Plug-in Project

In general, there are two kinds of plug-ins Headless plug-ins: not contributing to the Eclipse UI Eclipse UI, or IDE based plug-ins
21

Creating a plug-in based on Eclipse Hello, World Command template.

22

Launching the Runtime Workbench

Once your plug-in project is nished, you can run it by selecting Run > Run As > Eclipse Application in the Eclipse workbench. A new Eclipse instance will be launched, and we call it the runtime workbench. Correspondingly, the original Eclipse instance is called the development workbench. By default, the runtime workbench will have all the development workbenchs plug-ins and the plug-in projects in your workspace installed.
23

Installing Plug-ins

Click on the plug-in project you want to deploy in the Eclipse workbench, and select File > Export > Plugin Development > Deployable plug-ins and fragments. In the next pane, select Directory and click Finish. A plug-in JAR le will be generated in the directory you specied.
24

Installing Plug-ins, cont.

Save the JAR le in the dropins directory of your Eclipse home folder. Restart your Eclipse, your plug-in will be installed. Alternatively, you can also deploy your developed plug-in by creating a Update Site. This is not covered in our class. In interested, please refer to our text book or some online tutorials.

25

Existing Eclipse Plug-ins

Core: a general low-level group of non-UI plug-ins comprising basic services such as extension processing, creating new extension points, and so on. SWT: a general library of UI widgets tightly integrated with the underlying operating system, but with an OS-independent API. JFace: a general library of traditional UI functionality built on top of SWT. Workbench UI: plug-ins providing UI behavior specic to the Eclipse IDE itself, such as editors, views, perspectives, actions, and preferences.
26

Reminder

We will have Lab #4 next Tuesday / Wednesday. Be prepared! Assignment 4 will be out after the lab.

27

You might also like