Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Plugin initialization
Plugin initialization [message #305239] Tue, 27 June 2006 07:32 Go to next message
Manuel Selva is currently offline Manuel SelvaFriend
Messages: 189
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi all,

I am writing an application dispatched into several plugins. In these
plugins there is one called "A" wich depends(there is a dependency into
the manifest file) on an other called "B". When "A" is started, "A" have
to register some listeners on "B" ("B" will be able to communicate with
"A" without dependency on it). My problem is the following one :

"A" is started only after "B" and the code into the plugin "A" is only
called by "B" with the listeners mechanism so "A" will never be notified.
Is there a way (for example in the start method of plugin B) to initialize
my listeners on A without creating the following dependency: B depends on
A. (My application can't have such a dependency because it is introducing
cycle due to other plugins)

Thanks

Manu


Re: Plugin initialization [message #305243 is a reply to message #305239] Tue, 27 June 2006 10:41 Go to previous messageGo to next message
Barthelemy Dagenais is currently offline Barthelemy DagenaisFriend
Messages: 14
Registered: July 2009
Junior Member
I'm sure there are better solutions, but I see two options here:

1- Do not use LazyStart (not recommended...): your plug-in will be initialized
when Eclipse starts, so A will be able to register to B.

2- Use extension points (I think this is exactly what you want).

a) B declares an extension point (with an attribute class that must implements
your listener interface).

b) A declares an extension and provides the listener class.

c) When B is created (say, when the start method is called in the plug-in
activator), it goes through the plug-in registry and creates listeners from
registered extensions.

With this solution, you have lazy plug-in loading, plus A depends on B, but B
does not statically depend on A (you do not need to put A in the plug-in
dependencies).

Barthelemy

Manu wrote:
> Hi all,
>
> I am writing an application dispatched into several plugins. In these
> plugins there is one called "A" wich depends(there is a dependency into
> the manifest file) on an other called "B". When "A" is started, "A" have
> to register some listeners on "B" ("B" will be able to communicate with
> "A" without dependency on it). My problem is the following one :
>
> "A" is started only after "B" and the code into the plugin "A" is only
> called by "B" with the listeners mechanism so "A" will never be
> notified. Is there a way (for example in the start method of plugin B)
> to initialize my listeners on A without creating the following
> dependency: B depends on A. (My application can't have such a dependency
> because it is introducing cycle due to other plugins)
>
> Thanks
>
> Manu
>
Re: Plugin initialization [message #305245 is a reply to message #305243] Tue, 27 June 2006 11:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

Barthelemy Dagenais wrote:
> I'm sure there are better solutions, but I see two options here:
>
> 1- Do not use LazyStart (not recommended...): your plug-in will be
> initialized when Eclipse starts, so A will be able to register to B.

This is incorrect if you want automatic Plugin activation when your
Plugin is called you will have to specify LazyStart else your bundle
/plugin will only be activated when it is being manually activated.
What you are referring to is the Startup Extensionpoint.

Regards
Stefan
Re: Plugin initialization [message #305246 is a reply to message #305243] Tue, 27 June 2006 11:12 Go to previous messageGo to next message
Manuel Selva is currently offline Manuel SelvaFriend
Messages: 189
Registered: July 2009
Location: Grenoble, France
Senior Member
Thanks you very much Barthelemy,

I still have a last question: does the fact of declaring an exstension
point that will be only extended into my application is in the Eclipse
philosophy ??

Thanks again

Manu


Re: Plugin initialization [message #305247 is a reply to message #305246] Tue, 27 June 2006 12:13 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Manu wrote:
> Thanks you very much Barthelemy,
>
> I still have a last question: does the fact of declaring an exstension
> point that will be only extended into my application is in the Eclipse
> philosophy ??

That would be fine ...

The extension points are very useful for handling decoupled registration
in a lazy-loading environment.

ex: your plugin B defines the extension point, and reads it when it
starts up. When plugin B has something to say, it can request plugin A
hand over a listener (in IConfigurationElement terms, it's an executable
extension), which both provides the class and causes plugin A to be started.

And all the while, plugin A depends on plugin B.

Later,
PW


Re: Plugin initialization [message #305248 is a reply to message #305246] Tue, 27 June 2006 12:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

Manu wrote:

> Thanks you very much Barthelemy,
>
> I still have a last question: does the fact of declaring an exstension
> point that will be only extended into my application is in the Eclipse
> philosophy ??
>
> Thanks again
>
> Manu

Extention points are between plugins not applications. Thus, if one plugin
requires some facilities provided by another, extention point is the proper
Eclipse way. Even if there is only a single plugin. But even with an
extention point, there will still be a dependency. One plugin will have to
define the extension point and another plugin will implement it or call
upon it.

Two plugins will not interoperate without a dependency in at least one
direction.



--
Respectfully,

CL Gilbert
"Verily, verily, I say unto you, He that entereth not by the door() into the
sheepfold{}, but climbeth up some other *way, the same is a thief and a
robber."
Re: Plugin initialization [message #305249 is a reply to message #305248] Tue, 27 June 2006 13:56 Go to previous messageGo to next message
Manuel Selva is currently offline Manuel SelvaFriend
Messages: 189
Registered: July 2009
Location: Grenoble, France
Senior Member
In wich way the dependency is when B defines an extension point and A
extends it ??

Is it dangerous to have bi-directional dependency ? One static into the
dependencies of the plugin.xml and the other by extending an exstension
point?


Thanks

Manu


Re: Plugin initialization [message #305252 is a reply to message #305249] Tue, 27 June 2006 14:07 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

see my earlier reply

PW


Re: Plugin initialization [message #305264 is a reply to message #305249] Tue, 27 June 2006 18:18 Go to previous message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

Manu wrote:

> In wich way the dependency is when B defines an extension point and A
> extends it ??
>

A depends on B.

B will ask eclipse architecture for all implementors of the extension point.
Then B will 'instantiate' the implementation it gets back from eclipse.
Then b uses it.

> Is it dangerous to have bi-directional dependency ? One static into the
> dependencies of the plugin.xml and the other by extending an exstension
> point?
>
>
> Thanks
>
> Manu

No, don't need any bi-directional dependencies. If you have those then you
probably need to refactor your plugin responsibilities.



--
Respectfully,

CL Gilbert
"Verily, verily, I say unto you, He that entereth not by the door() into the
sheepfold{}, but climbeth up some other *way, the same is a thief and a
robber."
Previous Topic:mulit line TextCellEditor
Next Topic:SWT Application on PocketPC Windows Mobile 2003
Goto Forum:
  


Current Time: Sat Aug 17 08:14:54 GMT 2024

Powered by FUDForum. Page generated in 0.04307 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top