Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » When is a dependent Plugin started?
When is a dependent Plugin started? [message #293986] Thu, 03 November 2005 14:00 Go to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

I'm kind of getting confused with the way OSGI or Eclipse handles
activation of plugins (Bundles).

I have three plugins
Plugin A provides a basic service which B and C depend on.
Plugin B dependts on Plugin A and Plugin C depends on Plugin B.
Plugin C provides the front end.
When Plugin C gets activated by displaying a view for example it
activates Plugin B but Pluginn A is not activated automatically. I have
to call the start method on the bundle for Plugin A manually in order to
activate it.

I thought that if Plugin C is activated it should activate B and A
respectivly since it depends on both. Is this not correct?

Hope that someone can clear up my confusion

Stefan
Re: When is a dependent Plugin started? [message #293988 is a reply to message #293986] Thu, 03 November 2005 14:18 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Stefan Langer wrote:
> When Plugin C gets activated by displaying a view for example it
> activates Plugin B but Pluginn A is not activated automatically. I have
> to call the start method on the bundle for Plugin A manually in order to
> activate it.

Because of lazy initialization, I don't think it will start plugin A
until the first call is made into the plugin A class loader.

B is up and running, but if C calls something on B that calls into A, A
should start up.

note: I'm pretty sure that's what's going on, but I have no proof :)

Later,
PW


Re: When is a dependent Plugin started? [message #293989 is a reply to message #293986] Thu, 03 November 2005 14:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Is there some code in your plugin's start method ? I hope you know that Eclipse does activate bundles in a lazy loaded fashion, exactly when it is needed (OSGi guys will be able to answer class-loading part very well). Generally you don't need to have any code in start method. If there isn't any code, then why does the order of loading matters ? I hope your application behavior should be transparent to plugin load-order.

Most of the code could be organized to lazy load.

Thanks
~Venkat
Re: When is a dependent Plugin started? [message #293990 is a reply to message #293989] Thu, 03 November 2005 14:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

I forgot to pay attention to the word "SERVICE" in your post. Does your plugin wish to start some service when Eclipse starts (I mean user's intervention, the service starts at Eclipse's start courtesy startup extension) ?

Dont mind ! Too many questions ;-)

Thanks
Venkat
Re: When is a dependent Plugin started? [message #293991 is a reply to message #293990] Thu, 03 November 2005 14:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

To clear things up.

In Plugin A I initialize a service class (simply creating an object) in
the start method.

In Plugin B I call into Plugin A when the user interacts with the plugin
by calling A.getDefault() which provides me with the singleton instance
of A which is at this time null because Plugin A wasn't activated yet.
To resolve the issue I wrote some code that checks if Plugin A was
started and if it wasn't I start it my self. Now A.getDefault() returns
a non null value.
I thought that when I call A.getDefault() than Plugin A should
automagically be activated and started which is obviously not the case
so my thinking is wrong.

Hope that clears things

Stefan

venkataramana wrote:
> I forgot to pay attention to the word "SERVICE" in your post. Does your plugin wish to start some service when Eclipse starts (I mean user's intervention, the service starts at Eclipse's start courtesy startup extension) ?
>
> Dont mind ! Too many questions ;-)
>
> Thanks
> Venkat
Re: When is a dependent Plugin started? [message #293995 is a reply to message #293991] Thu, 03 November 2005 15:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

If it is null, then you probably don't have

Eclipse-AutoStart: true

in your plugin A manifest. Depending on what settings you supplied in
the wizard when you created the plugin project for A this setting may
not of been set.

Stefan Langer wrote:
> To clear things up.
>
> In Plugin A I initialize a service class (simply creating an object) in
> the start method.
>
> In Plugin B I call into Plugin A when the user interacts with the plugin
> by calling A.getDefault() which provides me with the singleton instance
> of A which is at this time null because Plugin A wasn't activated yet.
> To resolve the issue I wrote some code that checks if Plugin A was
> started and if it wasn't I start it my self. Now A.getDefault() returns
> a non null value.
> I thought that when I call A.getDefault() than Plugin A should
> automagically be activated and started which is obviously not the case
> so my thinking is wrong.
>
> Hope that clears things
>
> Stefan
>
> venkataramana wrote:
>
>> I forgot to pay attention to the word "SERVICE" in your post. Does
>> your plugin wish to start some service when Eclipse starts (I mean
>> user's intervention, the service starts at Eclipse's start courtesy
>> startup extension) ?
>>
>> Dont mind ! Too many questions ;-)
>>
>> Thanks
>> Venkat

--
Thanks,
Rich Kulp
Re: When is a dependent Plugin started? [message #293998 is a reply to message #293995] Thu, 03 November 2005 15:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

but Eclipse-AutoStart: true will start the plugin always at startup.
Isn't this bad since it will provide a performance penalty even if the
plugin is not used?

Rich Kulp wrote:
> If it is null, then you probably don't have
>
> Eclipse-AutoStart: true
>
> in your plugin A manifest. Depending on what settings you supplied in
> the wizard when you created the plugin project for A this setting may
> not of been set.
>
> Stefan Langer wrote:
>
>> To clear things up.
>>
>> In Plugin A I initialize a service class (simply creating an object)
>> in the start method.
>>
>> In Plugin B I call into Plugin A when the user interacts with the
>> plugin by calling A.getDefault() which provides me with the singleton
>> instance of A which is at this time null because Plugin A wasn't
>> activated yet.
>> To resolve the issue I wrote some code that checks if Plugin A was
>> started and if it wasn't I start it my self. Now A.getDefault()
>> returns a non null value.
>> I thought that when I call A.getDefault() than Plugin A should
>> automagically be activated and started which is obviously not the case
>> so my thinking is wrong.
>>
>> Hope that clears things
>>
>> Stefan
>>
>> venkataramana wrote:
>>
>>> I forgot to pay attention to the word "SERVICE" in your post. Does
>>> your plugin wish to start some service when Eclipse starts (I mean
>>> user's intervention, the service starts at Eclipse's start courtesy
>>> startup extension) ?
>>>
>>> Dont mind ! Too many questions ;-)
>>>
>>> Thanks
>>> Venkat
>
>
Re: When is a dependent Plugin started? [message #294004 is a reply to message #293998] Thu, 03 November 2005 15:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

No, that's not what it means. It means start the plugin (i.e. call the
start method) the first time any class within the plugin is loaded.

To start at Eclipse startup you use the startup extension point.

--
Thanks,
Rich Kulp
Re: When is a dependent Plugin started? [message #294005 is a reply to message #293998] Thu, 03 November 2005 15:25 Go to previous messageGo to next message
Ricky is currently offline RickyFriend
Messages: 204
Registered: July 2009
Senior Member
> but Eclipse-AutoStart: true will start the plugin always at startup.
> Isn't this bad since it will provide a performance penalty even if the
> plugin is not used?

http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/misc/bundle_manifest.html
"""
The Eclipse-AutoStart Header

The Eclipse-AutoStart header is used to specify if a bundle should be
started automatically before the first class or resource is accessed from
that bundle. This feature allows Eclipse to activate bundles on demand the
first time they are needed. Using this model Eclipse can startup with as
few active bundles as possible.
"""

So there sould be no performance penalty.

Ricky
Re: When is a dependent Plugin started? [message #294007 is a reply to message #294004] Thu, 03 November 2005 15:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

Thanks for clearing that up. Now it makes sense. I deleted that entry
since I thought this will actually start the plugin at startup.

Thank you
Stefan

Rich Kulp wrote:
> No, that's not what it means. It means start the plugin (i.e. call the
> start method) the first time any class within the plugin is loaded.
>
> To start at Eclipse startup you use the startup extension point.
>
Re: When is a dependent Plugin started? [message #294020 is a reply to message #293991] Thu, 03 November 2005 16:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Now that things have been cleared with "Autostart", just a diversion ...

If Autostart="false", then the semantics of that is like Eclipse doesn't load classes part of that plugin if the plugin's state is not yet started. Probably that is required when user's intervention is necessary to start certain plugins which are rather resource-intensive/security-conscious/time-bound services/ etc., May be I need to have a glimpse at OSGi specification to understand the philosophy of bundles ;-)
Re: When is a dependent Plugin started? [message #294076 is a reply to message #293991] Thu, 03 November 2005 20:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

If you have autostart in your manifest, then your plugin will be started
anytime any class from it is used. That is, if you use any class type
defined in that plugin, when eclipse needs to load that class type,
first it will start your plugin.

If you do not have autostart in your manifest, the plugin will be
started only when you properly request it from the plugin registry.

You should not be asking for your plugin directly like you are actually.
You should expose the resources you want to expose through the
extension mechanism by declaring an extension point. Then Plugin B will
get the implementer of te extension point from the plugin registry.
This is the correct way.

What you are doing is subverting eclipse and subject to cause you some
serious problems in the future. Plus eclipse needs some work in this
area as its sorta 1/2 converted to osgi philosophy. There should not be
any static reference available ourside of the plugin itself anyway!
Especially if your plugin is not a singleton.

Anyway, if you put
Eclipse-AutoStart: true

in your manifest you should be ok with what you are doing for now. But
if you do th eproper thing and use the registry to expose a service,
then you wont need autostart for plugin A, but you wil probably need it
still for the main plugin B in this case.


Stefan Langer wrote:
> To clear things up.
>
> In Plugin A I initialize a service class (simply creating an object) in
> the start method.
>
> In Plugin B I call into Plugin A when the user interacts with the plugin
> by calling A.getDefault() which provides me with the singleton instance
> of A which is at this time null because Plugin A wasn't activated yet.
> To resolve the issue I wrote some code that checks if Plugin A was
> started and if it wasn't I start it my self. Now A.getDefault() returns
> a non null value.
> I thought that when I call A.getDefault() than Plugin A should
> automagically be activated and started which is obviously not the case
> so my thinking is wrong.
>

If you use auto start, as soon as the class in Plugin B is loaded that
contains the A type, plugin A will be loaded...

CL
Re: When is a dependent Plugin started? [message #294082 is a reply to message #294020] Thu, 03 November 2005 20:42 Go to previous messageGo to next message
Ricky is currently offline RickyFriend
Messages: 204
Registered: July 2009
Senior Member
> If Autostart="false", then the semantics of that is like Eclipse doesn't
> load classes part of that plugin if the plugin's state is not yet
> started.

I dont hope so. The export of classes should be independent of bundle
state (start/stop) as it is carried out (formally) by the PackageAdmin
within the system bundle. The spec says a package is exported the moment a
bundle is resolved. It is resolved when all dependencies are met. So my
strong hope is that a bundle object is created for every plugin and its
state is someday resolved. All packages are exported then and when someone
starts the bundle explicitly or implicity with Autostart: its Activator is
run.

I always interpreted the slogan: "a plugin is not loaded unless needed" as
the bundle activator is not instantiated unless started by someone. But
that there is a bundle object present for every plugin because otherwise
IMHO the spec is not followed.

Can anybody with intime equinox knowledge comfirm these thoughts?

Ricky
Re: When is a dependent Plugin started? [message #294112 is a reply to message #294082] Fri, 04 November 2005 05:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

Hmmm, lots of complex stuff has been put up by equinox. That makes me much more enthusiastic to skim OSGi spec and its adoption by eclipse.

Thanks Ricky anyways.
Venkat
Re: When is a dependent Plugin started? [message #294114 is a reply to message #294076] Fri, 04 November 2005 08:05 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

Now this brings me to a nice question. You are saying I should provide
extension points to plugin a to not have a static binding between Plugin
A, B and C.
In case of C and B, C provides the UI for B so C depends on B and its
internals anyway so what is the danger of coupling the two together?
In case of A, A provides a special service by loading some classes for B
and setting them up (IoC). Which classes to load it gets told by A. I
tried to provide an extension point but it doesn't work out properly
because B is not an extension to A but B needs A to do some work for it.
Of course I could move the loading code into B but then other plugins
that need the same functionality would have to provide the same code
again and this clearly violates DRY which in my opinion is worse than
coupling Plugin B to Plugin A which has a dependency anyway.

So please clarify why it is a bad idea to couple the two in this way and
how to provide an extension point for a plugin that is not an extension
but more like a service.

Stefan

CL [dnoyeb] Gilbert wrote:
> If you have autostart in your manifest, then your plugin will be started
> anytime any class from it is used. That is, if you use any class type
> defined in that plugin, when eclipse needs to load that class type,
> first it will start your plugin.
>
> If you do not have autostart in your manifest, the plugin will be
> started only when you properly request it from the plugin registry.
>
> You should not be asking for your plugin directly like you are actually.
> You should expose the resources you want to expose through the
> extension mechanism by declaring an extension point. Then Plugin B will
> get the implementer of te extension point from the plugin registry. This
> is the correct way.
>
> What you are doing is subverting eclipse and subject to cause you some
> serious problems in the future. Plus eclipse needs some work in this
> area as its sorta 1/2 converted to osgi philosophy. There should not be
> any static reference available ourside of the plugin itself anyway!
> Especially if your plugin is not a singleton.
>
> Anyway, if you put
> Eclipse-AutoStart: true
>
> in your manifest you should be ok with what you are doing for now. But
> if you do th eproper thing and use the registry to expose a service,
> then you wont need autostart for plugin A, but you wil probably need it
> still for the main plugin B in this case.
Previous Topic:Please help : building update site project
Next Topic:Examining an uncaught exception in the debugger?
Goto Forum:
  


Current Time: Thu Apr 25 14:39:22 GMT 2024

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

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

Back to the top