Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Plugin Class in M9
Plugin Class in M9 [message #243942] Sun, 23 May 2004 08:15 Go to next message
Eclipse UserFriend
Hello,

Since I update from M8 to M9 my own Plugin doesn't really work fine and
many methods were marked as deprecated. So I decided to solve these
deprecates and switch to OSGi Plugin.

I created a MANIFEST.MF file with the Plug-in Manifest Editor. Then I
removed the XyzPlugin(IPluginDescriptor descriptor) constructor from my
Plugin class so that only the default constructor is left over.

Now the problem is that by calling the getDefault() method the singleton
instance field within the plugin class isn’t initialized, due to the
fact that the default constructor wasn’t called.

My question is when should the singleton instance be initialized? By
calling the getDefault() method or will it triggered by a callback
method of the osgi framework?

Thx
Ingo
Re: Plugin Class in M9 [message #243947 is a reply to message #243942] Sun, 23 May 2004 08:31 Go to previous messageGo to next message
Eclipse UserFriend
Hallo Ingo,

I also "healed" my former usage of the now deprecated methods, but
this didn't involve building a manifest file.

Regarding the getDefault() call. I do just assign this to a static
variable in the constructor of my plugin and return this reference when
getDefault() is called. Eclipse takes care of just instantiating the
plug-in once.

Having said that, it didn't work on the first try and my plug-in has
been instantiated over and over again, but after using a fresh
runtime-workspace the problem didn't occur again.

Cheers,
Mariano

Ingo Düppe wrote:

> Hello,
>
> Since I update from M8 to M9 my own Plugin doesn't really work fine and
> many methods were marked as deprecated. So I decided to solve these
> deprecates and switch to OSGi Plugin.
>
> I created a MANIFEST.MF file with the Plug-in Manifest Editor. Then I
> removed the XyzPlugin(IPluginDescriptor descriptor) constructor from my
> Plugin class so that only the default constructor is left over.
>
> Now the problem is that by calling the getDefault() method the singleton
> instance field within the plugin class isn’t initialized, due to the
> fact that the default constructor wasn’t called.
>
> My question is when should the singleton instance be initialized? By
> calling the getDefault() method or will it triggered by a callback
> method of the osgi framework?
>
> Thx
> Ingo
>
>
Re: Plugin Class in M9 [message #243951 is a reply to message #243947] Sun, 23 May 2004 08:47 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mariano,

I guess I know how it should work.

If your plugin class have the now deprecated constructor with the
IPluginDescriptor parameter then this constructor will be called before
accessing your plugin. But your constructor is still deprecated.

My problem with the manifest.mf file was that the Bundle-Activator
doesn't point to my plugin class. After correcting this it works fine.

But I am still not sure, how the lifecyle of the plugin should look like.

So any further hints would be wonderfull.

Thx

Ingo



Mariano Kamp wrote:
> Hallo Ingo,
>
> I also "healed" my former usage of the now deprecated methods, but
> this didn't involve building a manifest file.
>
> Regarding the getDefault() call. I do just assign this to a static
> variable in the constructor of my plugin and return this reference when
> getDefault() is called. Eclipse takes care of just instantiating the
> plug-in once.
>
> Having said that, it didn't work on the first try and my plug-in has
> been instantiated over and over again, but after using a fresh
> runtime-workspace the problem didn't occur again.
>
> Cheers,
> Mariano
>
> Ingo Düppe wrote:
>
>> Hello,
>>
>> Since I update from M8 to M9 my own Plugin doesn't really work fine
>> and many methods were marked as deprecated. So I decided to solve
>> these deprecates and switch to OSGi Plugin.
>>
>> I created a MANIFEST.MF file with the Plug-in Manifest Editor. Then I
>> removed the XyzPlugin(IPluginDescriptor descriptor) constructor from
>> my Plugin class so that only the default constructor is left over.
>>
>> Now the problem is that by calling the getDefault() method the
>> singleton instance field within the plugin class isn’t initialized,
>> due to the fact that the default constructor wasn’t called.
>>
>> My question is when should the singleton instance be initialized? By
>> calling the getDefault() method or will it triggered by a callback
>> method of the osgi framework?
>>
>> Thx
>> Ingo
>>
>>
Re: Plugin Class in M9 [message #243966 is a reply to message #243951] Sun, 23 May 2004 12:41 Go to previous messageGo to next message
Eclipse UserFriend
You try set start and stop method like :
public void start(BundleContext context) throws Exception {
super.start(context);
}

public void stop(BundleContext context) throws Exception {
super.stop(context);
}

regards
Haris Peco
Ingo Düppe wrote:

> Hi Mariano,
>
> I guess I know how it should work.
>
> If your plugin class have the now deprecated constructor with the
> IPluginDescriptor parameter then this constructor will be called before
> accessing your plugin. But your constructor is still deprecated.
>
> My problem with the manifest.mf file was that the Bundle-Activator
> doesn't point to my plugin class. After correcting this it works fine.
>
> But I am still not sure, how the lifecyle of the plugin should look like.
>
> So any further hints would be wonderfull.
>
> Thx
>
> Ingo
>
>
>
> Mariano Kamp wrote:
>> Hallo Ingo,
>>
>> I also "healed" my former usage of the now deprecated methods, but
>> this didn't involve building a manifest file.
>>
>> Regarding the getDefault() call. I do just assign this to a static
>> variable in the constructor of my plugin and return this reference when
>> getDefault() is called. Eclipse takes care of just instantiating the
>> plug-in once.
>>
>> Having said that, it didn't work on the first try and my plug-in has
>> been instantiated over and over again, but after using a fresh
>> runtime-workspace the problem didn't occur again.
>>
>> Cheers,
>> Mariano
>>
>> Ingo Düppe wrote:
>>
>>> Hello,
>>>
>>> Since I update from M8 to M9 my own Plugin doesn't really work fine
>>> and many methods were marked as deprecated. So I decided to solve
>>> these deprecates and switch to OSGi Plugin.
>>>
>>> I created a MANIFEST.MF file with the Plug-in Manifest Editor. Then I
>>> removed the XyzPlugin(IPluginDescriptor descriptor) constructor from
>>> my Plugin class so that only the default constructor is left over.
>>>
>>> Now the problem is that by calling the getDefault() method the
>>> singleton instance field within the plugin class isn’t initialized,
>>> due to the fact that the default constructor wasn’t called.
>>>
>>> My question is when should the singleton instance be initialized? By
>>> calling the getDefault() method or will it triggered by a callback
>>> method of the osgi framework?
>>>
>>> Thx
>>> Ingo
>>>
>>>
Re: Plugin Class in M9 [message #243992 is a reply to message #243966] Sun, 23 May 2004 12:13 Go to previous messageGo to next message
Eclipse UserFriend
Yes I known, but as long you do not add something new you can use the
default implementation of the AbstractUIPlugin.

According to
http://dev.eclipse.org/viewcvs/index.cgi/platform-core-home/ runtime/adoption.html?rev=1.6
the Plugin should be implemented as a Singleton, but how do I get a
reference of a Bundle object to get i.e. the SymbolicName

regards
Ingo

snpe wrote:

> You try set start and stop method like :
> public void start(BundleContext context) throws Exception {
> super.start(context);
> }
>
> public void stop(BundleContext context) throws Exception {
> super.stop(context);
> }
>
> regards
> Haris Peco
> Ingo Düppe wrote:
>
Re: Plugin Class in M9 [message #244001 is a reply to message #243992] Sun, 23 May 2004 14:47 Go to previous messageGo to next message
Eclipse UserFriend
Platform.getBundle(). ...
Ingo Düppe wrote:

> Yes I known, but as long you do not add something new you can use the
> default implementation of the AbstractUIPlugin.
>
> According to
>
http://dev.eclipse.org/viewcvs/index.cgi/platform-core-home/ runtime/adoption.html?rev=1.6
> the Plugin should be implemented as a Singleton, but how do I get a
> reference of a Bundle object to get i.e. the SymbolicName
>
> regards
> Ingo
>
> snpe wrote:
>
>> You try set start and stop method like :
>> public void start(BundleContext context) throws Exception {
>> super.start(context);
>> }
>>
>> public void stop(BundleContext context) throws Exception {
>> super.stop(context);
>> }
>>
>> regards
>> Haris Peco
>> Ingo Düppe wrote:
>>
Re: Plugin Class in M9 [message #244007 is a reply to message #243951] Sun, 23 May 2004 13:06 Go to previous messageGo to next message
Eclipse UserFriend
Hallo Ingo,


> If your plugin class have the now deprecated constructor with the
> IPluginDescriptor parameter then this constructor will be called before
> accessing your plugin. But your constructor is still deprecated.
Nope, I removed the constructor completely and have a default (no-arg)
constructor now.
I didn't read the adoption guide yet (my bad), but I guess, as the
BundleContext is now passed into the stop() method there is no further
need for the plugin Descriptor. I relied on the javadocs and the result
seems to work for me (tm).

My new constructor just looks like this:

public PepeMaxPlugin() {
super();
plugin = this;
}

I also had to change the startup()/shutdown() method and use
start()/stop() instead, but for the caller this is just mechanics, no
change in semantics.

FWIW you can see the working code here:
http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/pepemax/pepe max/org.jabberstudio.pepemax.core/src/org/jabberstudio/pepem ax/internal/core/PepeMaxPlugin.java?view=markup
or
http://tinyurl.com/37fy9

Btw. I am also accessing the symbolicName like this:
getBundle().getSymbolicName()

> But I am still not sure, how the lifecyle of the plugin should look like.
What lifecycle do you mean?
There is one instance, the constructor is called, start() is called and
eventually stop(). Above mentioned code is also a Singleton. Regarding
your issue, see my getModelInternally() or getDefault() method.

I am not sure, if I understood you correctly. If my post doesn't answer
your question, please rephrase your question.

Btw. I didn't create any manifest file. If PDE didn't create one without
telling me, it works without having one.

Cheers,
Mariano

>
> Thx
>
> Ingo
>
>
>
> Mariano Kamp wrote:
>
>> Hallo Ingo,
>>
>> I also "healed" my former usage of the now deprecated methods, but
>> this didn't involve building a manifest file.
>>
>> Regarding the getDefault() call. I do just assign this to a static
>> variable in the constructor of my plugin and return this reference
>> when getDefault() is called. Eclipse takes care of just instantiating
>> the plug-in once.
>>
>> Having said that, it didn't work on the first try and my plug-in has
>> been instantiated over and over again, but after using a fresh
>> runtime-workspace the problem didn't occur again.
>>
>> Cheers,
>> Mariano
>>
>> Ingo Düppe wrote:
>>
>>> Hello,
>>>
>>> Since I update from M8 to M9 my own Plugin doesn't really work fine
>>> and many methods were marked as deprecated. So I decided to solve
>>> these deprecates and switch to OSGi Plugin.
>>>
>>> I created a MANIFEST.MF file with the Plug-in Manifest Editor. Then I
>>> removed the XyzPlugin(IPluginDescriptor descriptor) constructor from
>>> my Plugin class so that only the default constructor is left over.
>>>
>>> Now the problem is that by calling the getDefault() method the
>>> singleton instance field within the plugin class isn’t initialized,
>>> due to the fact that the default constructor wasn’t called.
>>>
>>> My question is when should the singleton instance be initialized? By
>>> calling the getDefault() method or will it triggered by a callback
>>> method of the osgi framework?
>>>
>>> Thx
>>> Ingo
>>>
>>>
Re: Plugin Class in M9 [message #244012 is a reply to message #243942] Sun, 23 May 2004 13:44 Go to previous messageGo to next message
Eclipse UserFriend
Ingo Düppe schrieb:
> Now the problem is that by calling the getDefault() method the singleton
> instance field within the plugin class isn’t initialized, due to the
> fact that the default constructor wasn’t called.

Did you remove the org.eclipse.runtime.compatibility plugin from the
list of dependencies and added org.eclipse.runtime instead?

I had the same problem (not called constructor) because I forgot to
change thiose dependencies after removing the IPluginDescriptor from the
constructor.

Ciao, Michael.
Re: Plugin Class in M9 [message #244017 is a reply to message #244012] Sun, 23 May 2004 13:52 Go to previous messageGo to next message
Eclipse UserFriend
Oops!
Damn' good. I removed the compatibility jar after I ran in some problem.
I don't remember what it was exactly, but I believe that there was an
error message indicating that I have to remove the jar. ... Or, I was
just incredible smart and came up with the solution myself ;-) lol, no
way ...

Cheers,
Mariano

Michael Keppler wrote:

> Ingo Düppe schrieb:
>
>> Now the problem is that by calling the getDefault() method the
>> singleton instance field within the plugin class isn’t initialized,
>> due to the fact that the default constructor wasn’t called.
>
>
> Did you remove the org.eclipse.runtime.compatibility plugin from the
> list of dependencies and added org.eclipse.runtime instead?
>
> I had the same problem (not called constructor) because I forgot to
> change thiose dependencies after removing the IPluginDescriptor from the
> constructor.
>
> Ciao, Michael.
Re: Plugin Class in M9 [message #244022 is a reply to message #244017] Sun, 23 May 2004 14:11 Go to previous messageGo to next message
Eclipse UserFriend
I found the source I was using. It was again the javadocs ...


The MyPlugin(IPluginDescriptor descriptor) constructor is called only
for plug-ins which explicitly require the
org.eclipse.core.runtime.compatibility plug-in (or, as in this case,
subclasses which might).



Mariano Kamp wrote:

> Oops!
> Damn' good. I removed the compatibility jar after I ran in some problem.
> I don't remember what it was exactly, but I believe that there was an
> error message indicating that I have to remove the jar. ... Or, I was
> just incredible smart and came up with the solution myself ;-) lol, no
> way ...
>
> Cheers,
> Mariano
>
> Michael Keppler wrote:
>
>> Ingo Düppe schrieb:
>>
>>> Now the problem is that by calling the getDefault() method the
>>> singleton instance field within the plugin class isn’t initialized,
>>> due to the fact that the default constructor wasn’t called.
>>
>>
>>
>> Did you remove the org.eclipse.runtime.compatibility plugin from the
>> list of dependencies and added org.eclipse.runtime instead?
>>
>> I had the same problem (not called constructor) because I forgot to
>> change thiose dependencies after removing the IPluginDescriptor from
>> the constructor.
>>
>> Ciao, Michael.
Re: Plugin Class in M9 [message #244066 is a reply to message #244012] Sun, 23 May 2004 16:57 Go to previous message
Eclipse UserFriend
Fine that was the missing thing. Thx alot. Now the constructor is called.

Regards
Ingo

Michael Keppler wrote:

> Ingo Düppe schrieb:
>
>> Now the problem is that by calling the getDefault() method the
>> singleton instance field within the plugin class isn’t initialized,
>> due to the fact that the default constructor wasn’t called.
>
>
> Did you remove the org.eclipse.runtime.compatibility plugin from the
> list of dependencies and added org.eclipse.runtime instead?
>
> I had the same problem (not called constructor) because I forgot to
> change thiose dependencies after removing the IPluginDescriptor from the
> constructor.
>
> Ciao, Michael.
Previous Topic:QuickFix colors (M9)
Next Topic:Vertical toolbar in RCP
Goto Forum:
  


Current Time: Sun Nov 09 16:15:19 EST 2025

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

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

Back to the top