Home > eclipse rcp > Understanding basic concepts in eclipse

Understanding basic concepts in eclipse

In my earlier post i have introduced you to eclipse.Now, before we start using eclipse api’s we need to understand some very basic key concepts in eclipse architecture.In this post i am going to have a walk through of the basic key concepts in eclipse plugin architecture.

Plugin:

The first and the most basic thing of eclipse is nothing but a plugin. A plugin is nothing but  an individual runnable component  which may be plugged into or may  have pluggable components for another runnable component to get plugged in for running it.For more detailed reference you can refer here.

A simple plugin.xml will look as shown below.

In the above shown plugin.xml , it defines a perspective and a view which are there in the plugin. You can notice here that the terms extension point and extension is mentioned in the file. The next thing we are going to see is about extension and extension points.

Extension & Extension Points:

The next basic things in eclipse are nothing but extension and extension points.

An extension is nothing but a pluggable component defined in a plugin.In real life scenario you can imagine an extension as a memory card. So to read a memory card you need a card reader, right?

the card reader slot is nothing but the extension point. An extension point defines some rules (as there in real life scenarios) for it and whichever extensions which are having compliance to those rules can be plugged in to it. Extension and extension points is the basic way of how pulgins are interacting between each other. So you can understand from here that the “extensions” have the functionality written in them, if any other plugin wants to use the similar functionality it can be plugged into it and can be used.

In the above plugin.xml shown it uses two extensions

1)  org.eclipse.ui.perspectives

2)  org.eclipse.ui.views

LifeCycle of a plugin:

The Life cycle of a plugin is controlled by a class called “Activator.java” which will be created by eclipse itself when a plugin is created. A sample activator class will look look this.

The start method is called whenever the plugin is getting loaded.

When does a plugin gets started?

Eclipse by default follows lazy loading concept, i.e a plugin will be loaded only if one of its class is getting called. We can override this lazy loading option also so that the plugin gets loaded whenever your application is loaded.

There are three scenarios a plugin will be activated.

  • If your plugin has an executable extension, and if another plugin is using/running  it, that time your  plugin will be automatically loaded.
  • If your  plugin exports any of its libraries (JAR files),  another plugin can reference and instantiate your plugin  classes directly. Loading a class belonging to your plugin causes it to be started automatically.
  • A plugin can be activated explicitly, using the API method Platform.getPlugin(). This method returns a fully initialized plugin instance.

For more details please refer here.

Advertisements
Categories: eclipse rcp
  1. October 8, 2012 at 8:32 am

    Wohh just what I was looking for, thank you for posting.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: