Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » calling an activator class from a contributor plugin
calling an activator class from a contributor plugin [message #93091] Thu, 26 July 2007 16:25 Go to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Hello!

I have following case: two bundles - a core and a contributor. The core
bundle consists of several classes that are used in the contributor's
manifest and the contributor doesn't contain any classes at all.

For the contributor I want to use a class from the core bundle, that
extends AbstractUIPlugin class. This class is *not* the activator for
the "core" plug-in, as far as core is concerned, this is just another
class. In the "contributor" plug-ins, I specify this class as the
activator (the contributor has "core" plug-in as a dependency).

The problem is that a start(BundleContext context) of that activator
class is not being called. As I mentioned already the contributor bundle
doesn't contain any classes itself, so no classes being loaded, and the
activator doesn't get loaded. Is there a way to overcome this issue and
make the activator to start, or this might be a bug ?

Anton
Re: calling an activator class from a contributor plugin [message #93121 is a reply to message #93091] Thu, 26 July 2007 17:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jacek.pospychala.pl.ibm.com

Anoton,
it's by design, that bundle doesn't start as long as it's not needed. If
you wish to start it immediately after equinox launch, you may add it to
osgi.bundles in configuration/config.ini

Anton Arhipov wrote:
> Hello!
>
> I have following case: two bundles - a core and a contributor. The
> core bundle consists of several classes that are used in the
> contributor's manifest and the contributor doesn't contain any classes
> at all.
>
> For the contributor I want to use a class from the core bundle, that
> extends AbstractUIPlugin class. This class is *not* the activator for
> the "core" plug-in, as far as core is concerned, this is just another
> class. In the "contributor" plug-ins, I specify this class as the
> activator (the contributor has "core" plug-in as a dependency).
>
> The problem is that a start(BundleContext context) of that activator
> class is not being called. As I mentioned already the contributor
> bundle doesn't contain any classes itself, so no classes being loaded,
> and the activator doesn't get loaded. Is there a way to overcome this
> issue and make the activator to start, or this might be a bug ?
>
> Anton
Re: calling an activator class from a contributor plugin [message #93134 is a reply to message #93121] Thu, 26 July 2007 18:25 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Jacek Pospychala wrote:
> Anoton,
> it's by design, that bundle doesn't start as long as it's not needed. If
> you wish to start it immediately after equinox launch, you may add it to
> osgi.bundles in configuration/config.ini

Thx Jacek. This could be an option. However, the contributor should have
been activated since I have an actionSet defined in the plugin.xml for
the contributor bundle:

say, foo.bar.Action extends IobjectActionDelegate is in core bundle. And
in contributor i use it for actionSet declaration. the same way I have a
foo.bar.Activator that implements BundleActivator (in core) which is
used by the contributor, like Bundle-Activator: foo.bar.Activator






>
> Anton Arhipov wrote:
>> Hello!
>>
>> I have following case: two bundles - a core and a contributor. The
>> core bundle consists of several classes that are used in the
>> contributor's manifest and the contributor doesn't contain any classes
>> at all.
>>
>> For the contributor I want to use a class from the core bundle, that
>> extends AbstractUIPlugin class. This class is *not* the activator for
>> the "core" plug-in, as far as core is concerned, this is just another
>> class. In the "contributor" plug-ins, I specify this class as the
>> activator (the contributor has "core" plug-in as a dependency).
>>
>> The problem is that a start(BundleContext context) of that activator
>> class is not being called. As I mentioned already the contributor
>> bundle doesn't contain any classes itself, so no classes being loaded,
>> and the activator doesn't get loaded. Is there a way to overcome this
>> issue and make the activator to start, or this might be a bug ?
>>
>> Anton
Re: calling an activator class from a contributor plugin [message #93375 is a reply to message #93134] Tue, 31 July 2007 17:24 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Anton Arhipov wrote:
>
> Thx Jacek. This could be an option. However, the contributor should have
> been activated since I have an actionSet defined in the plugin.xml for
> the contributor bundle:
>
> say, foo.bar.Action extends IobjectActionDelegate is in core bundle. And
> in contributor i use it for actionSet declaration. the same way I have a
> foo.bar.Activator that implements BundleActivator (in core) which is
> used by the contributor, like Bundle-Activator: foo.bar.Activator


Except AFAIK lazy instantiation applies to class loading. When eclipse
tries to instantiate your actionSet it'll load foo.bar.Action and that
will trigger/make sure the core bundle is active. It doesn't care that
the actionSet definition came from the contributor bundle.

I don't believe there is any intrinsic eclipse mechanism to start a
bundle with no classes to load, unless you track it down and do it
manually or (as previously mentioned) include it in the osgi.bundles
property. But in either case, you have to be careful that any framework
the contributor needs is available when its bundle starts.

Later,
PW


Re: calling an activator class from a contributor plugin [message #93404 is a reply to message #93375] Tue, 31 July 2007 18:07 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Paul is correct. A bundle will not get lazily started unless it's
classloader actually defines a "trigger" class. In this case you do not
actually load any classes from the contributing bundle so it does not
get activated.

If you must get your bundle activated then you could extend
foo.bar.Action and do not override any methods and then use that class
in your plugin.xml instead. But why do you need to have your bundle
started at all? Can you get by without a bundle activator?

Tom
Re: calling an activator class from a contributor plugin [message #93642 is a reply to message #93404] Wed, 01 August 2007 15:43 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Hi Tom!

Thx for the comprehensive explanation! :)

To answer your question why do I need this feature. I'm working on my
Google Summer of Code project for adding the ability to write eclipse
plug-ins in scripting languages (e.g Groovy). And the idea behind is to
provide a helper plug-in which could be used as a service provider for
the scripts. So the contributor bundle will not include *any* classes -
only the scripts.

I have succeeded to add this feature for the extensions mechanism. But
it would be nice to be able do all the same things in Groovy as you may
do in Java. That is why I'm struggling for the activator case.

Anton

Tom Watson wrote:
> Paul is correct. A bundle will not get lazily started unless it's
> classloader actually defines a "trigger" class. In this case you do not
> actually load any classes from the contributing bundle so it does not
> get activated.
>
> If you must get your bundle activated then you could extend
> foo.bar.Action and do not override any methods and then use that class
> in your plugin.xml instead. But why do you need to have your bundle
> started at all? Can you get by without a bundle activator?
>
> Tom
>
>
Re: calling an activator class from a contributor plugin [message #93745 is a reply to message #93642] Wed, 01 August 2007 19:56 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Anton Arhipov wrote:
> Hi Tom!
>
> Thx for the comprehensive explanation! :)
>
> To answer your question why do I need this feature. I'm working on my
> Google Summer of Code project for adding the ability to write eclipse
> plug-ins in scripting languages (e.g Groovy). And the idea behind is to
> provide a helper plug-in which could be used as a service provider for
> the scripts. So the contributor bundle will not include *any* classes -
> only the scripts.

When you say groovy scripts are these compiled scripts (into java
bytecode) or the raw text files scripts which get compile on the fly at
runtime? If they are compiled scripts then the bundle will have class
files, right? If you compile them at runtime then what classloader do
you use to define the class?

>
> I have succeeded to add this feature for the extensions mechanism. But
> it would be nice to be able do all the same things in Groovy as you may
> do in Java. That is why I'm struggling for the activator case.
>
> Anton

Cool!! Can I have a look at your project? Is it available to the
public? I need a better understanding of the environment to suggest a
possible solution.

Tom
Re: calling an activator class from a contributor plugin [message #93775 is a reply to message #93404] Wed, 01 August 2007 20:10 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
> If you must get your bundle activated then you could extend
> foo.bar.Action and do not override any methods and then use that class
> in your plugin.xml instead. But why do you need to have your bundle
> started at all? Can you get by without a bundle activator?

I have 2 plug-ins here:
http://eclipse-incub.svn.sourceforge.net/viewvc/eclipse-incu b/scripting_plugins/

org.eclipse.soc.scripting.plugin - is the "core" plug-in, and
org.eclipse.soc.scripting.contributor - is the client, which doesn't
include any classes but uses the classes provided by the "core"

Say, a client code requires some initialization to be done. So if the
client plug-in doesn't load any classes, then it will not be initialized
And the only functionality that will be available for the scripts is the
one that can be implemented in the extensions.


Anton
Re: calling an activator class from a contributor plugin [message #93790 is a reply to message #93745] Wed, 01 August 2007 20:16 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
> When you say groovy scripts are these compiled scripts (into java
> bytecode) or the raw text files scripts which get compile on the fly at
> runtime? If they are compiled scripts then the bundle will have class
> files, right? If you compile them at runtime then what classloader do
> you use to define the class?

They are just text files, and not compiled. I use JSR 223 for this purpose.


> Cool!! Can I have a look at your project? Is it available to the
> public? I need a better understanding of the environment to suggest a
> possible solution.

sure

$ svn co
http://eclipse-incub.svn.sourceforge.net/svnroot/eclipse-inc ub/script
ing_plugins scripting_plugins
Re: calling an activator class from a contributor plugin [message #93832 is a reply to message #93775] Wed, 01 August 2007 20:45 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Anton Arhipov wrote:

> I have 2 plug-ins here:
> http://eclipse-incub.svn.sourceforge.net/viewvc/eclipse-incu b/scripting_plugins/
>

I'm not having any luck connecting to this SVN server to checkout the
projects in Eclipse. I'm currently using the polarion svn plugins for
eclipse and they seem to work fine with other servers. I get a "301
Moved" error saying that the site has moved? Interestingly I can browse
to the URL with a browser fine. Any clue what is going on?

Tom
Re: calling an activator class from a contributor plugin [message #93847 is a reply to message #93832] Wed, 01 August 2007 20:59 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Tom Watson wrote:
> Anton Arhipov wrote:
>
>> I have 2 plug-ins here:
>> http://eclipse-incub.svn.sourceforge.net/viewvc/eclipse-incu b/scripting_plugins/
>>
>
> I'm not having any luck connecting to this SVN server to checkout the
> projects in Eclipse. I'm currently using the polarion svn plugins for
> eclipse and they seem to work fine with other servers. I get a "301
> Moved" error saying that the site has moved? Interestingly I can browse
> to the URL with a browser fine. Any clue what is going on?
>
> Tom

hmm.. i'm using command-line, that is why it works for me

but here's the svn information: http://sourceforge.net/svn/?group_id=166155


you just have to use http instead of https.
Re: calling an activator class from a contributor plugin [message #93921 is a reply to message #93832] Thu, 02 August 2007 16:55 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
> I'm not having any luck connecting to this SVN server to checkout the
> projects in Eclipse. I'm currently using the polarion svn plugins for
> eclipse and they seem to work fine with other servers. I get a "301
> Moved" error saying that the site has moved? Interestingly I can browse
> to the URL with a browser fine. Any clue what is going on?
>
> Tom

Hi Tom!
have you succeeded in downloading the code? if not I can zip it and
upload to any ftp if u like.
Re: calling an activator class from a contributor plugin [message #93951 is a reply to message #93775] Thu, 02 August 2007 17:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

That's the same behaviour for Java code, though. Doesn't really matter whether it's compiled or not.

You still get a hit when something starts up; Eclipse delays that as long as possible. What kind of initialization are you trying to do?

Alex.
Re: calling an activator class from a contributor plugin [message #93966 is a reply to message #93951] Thu, 02 August 2007 18:06 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Alex Blewitt wrote:
> That's the same behaviour for Java code, though. Doesn't really matter whether it's compiled or not.
>
> You still get a hit when something starts up; Eclipse delays that as long as possible. What kind of initialization are you trying to do?

I would like to reimplement the example from the Contributing to Eclipse
book, a JUnit support plugin, which uses a bundle activator to process
extension-points.

I'd say that it is not the matter of what initialization I would like to
do, but it is the matter of what could be possible to do with this
script plug-in.

Anton
Re: calling an activator class from a contributor plugin [message #93995 is a reply to message #93966] Thu, 02 August 2007 22:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Yeah, but the view is only activated when it's shown. For the server case, it's run via a separate Java process with an -application; and that's consulted from the extension registry to start the bundle that contains that extension point. The startup is triggered by the update.configurator and the core runtime, and they're started by entries in the osgi.bundles property of the configuration.ini

The point is that the default behaviour for bundles is for them not to be started unless absolutely necessary. If you want to do something else then you've got to explicitly start it via the osgi.bundles, or implement a command line application which will cause that bundle to be started.

However, which one is right for you very much depends on what you want the bundle to do -- if you don't know the answer to that question, then you can't really solve the problem you're trying to.

Alex.
Re: calling an activator class from a contributor plugin [message #94053 is a reply to message #93995] Fri, 03 August 2007 09:58 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Say, a I would like to process and register the extension-point elements.
How would you do that without a bundle activator? Ok, it is possible that
one will implement the logic in an action delegate class, but it is quite
odd.

I would like to enable the base for an activation facility, i.e. if a
script contributor (for whatever reason) wants to have an activator, then
he/she will declare the proxy provided by my plug-in and provide the
script name as a parameter. Then the proxy (read facade) will delegate the
function calls to the script.

Here's a blog entry by Wayne B. about the principle:
http://dev.eclipse.org/blogs/wayne/2007/07/26/making-eclipse -plug-ins-using-jruby-or-groovy/
Re: calling an activator class from a contributor plugin [message #94067 is a reply to message #94053] Fri, 03 August 2007 11:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

I am unable to help you further. You wish for something to be running before something is running to be able to run it, and I can't seem to convince you that something needs to be running before something can run the thing that you want to run; yet, you insist that you want to be able to run things that aren't running by something that's also not running.

Good luck, and I hope you find your way out of your paradox.

Alex.
Re: calling an activator class from a contributor plugin [message #94124 is a reply to message #93921] Mon, 06 August 2007 16:32 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
> Hi Tom!
> have you succeeded in downloading the code? if not I can zip it and
> upload to any ftp if u like.

Yup, I used
https://eclipse-incub.svn.sourceforge.net/svnroot/eclipse-in cub as the
SVN URL. I have not looked into the code yet. I will try to today.

Tom
Re: calling an activator class from a contributor plugin [message #94137 is a reply to message #94067] Mon, 06 August 2007 17:04 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Wow, I go away for a few days and this thread turned a little ugly :(

Lets get back on track. Anton is trying to enable groovy code to
contribute to an extension point just like normal java code would. This
sounds pretty cool.

The issue that has come up is that we are not dealing with real classes
from the contributing bundle. Instead the contributing bundle only has
groovy scripts. The way this bundle contributes to an extension point
is by using a class
(org.eclipse.soc.scripting.core.ScriptExtensionProxy) from a shared
scripting bundle (org.eclipse.soc.scripting.plugin) with something like
this ...

<view
class=" org.eclipse.soc.scripting.core.ScriptExtensionProxy:org.ecli pse.ui.IViewPart/view.groovy "
id="org.eclipse.soc.scripting.views.DemoView"
name="Demo View">
</view>

In this case org.eclipse.soc.scripting.core.ScriptExtensionProxy
implements IExecutableExtension and IExecutableExtensionFactory. The
extra data "org.eclipse.ui.IViewPart/view.groovy" is passed to the
IExecutableExtension.setInitializationData so that it knows what script
to load and what type of object it should return as a proxy from
IExecutableExtensionFactory.create.

As you can see only script resources are loaded from the contributing
bundle to contribute an extension. So when the extension is used to
display the view the contributing bundle will *not* get lazily activated
even if it has the Eclipse-LazyStart: true header. This is because we
never actually loaded a class from the contributing bundle. The lazy
activation policy in OSGi only activates bundles when the first class is
loaded from the bundle.

I see a couple of options with the current strategy

1) Have ScriptExtensionProxy activate the contributing bundle using a
transient flag when it creates a proxy (i.e. call
Bundle.start(Bundle.START_TRANSIENT)). This would take extra work for
ScriptExtensionProxy because it should probably read the
Eclipse-LazyStart and/or the new Bundle-ActivationPolicy from OSGi R4.1
specification to verify the bundle is actually lazy activated.

2) Make ScriptExtensionProxy abstract and force contributing groovy
bundles to extend it with a real class which exists in the contributing
bundle. Then when the extension is constructed it will automatically
activate the bundle if it has a lazy activation policy.

Anton, when you run a groovy script do you "compile" the groovy code
down to java byte code or do you interpret the script directly with the
ScriptExecutor? The reason I ask is it seems like there will be issues
if the script has external dependencies. Do you have ideas around how
these dependencies would get loaded and resolved?

Tom
Re: calling an activator class from a contributor plugin [message #94323 is a reply to message #94137] Mon, 06 August 2007 20:14 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
Hi!

> Anton, when you run a groovy script do you "compile" the groovy code
> down to java byte code or do you interpret the script directly with the
> ScriptExecutor? The reason I ask is it seems like there will be issues
> if the script has external dependencies. Do you have ideas around how
> these dependencies would get loaded and resolved?
>
I do not compile the script, it is being interpreted. ScriptExecutor
evaluates the script via javax.script API.

I have to make a note here about groovy. This plug-in wasn't intended to
be just for groovy but for jruby (and any other jsr223 capable scripting
language) as well. It is just groovy that I prefer the most :)

The external dependencies are successfully loaded if they are specified
in plugin.xml and if I specify the import statement in the script, I
have tested that.

> 1) Have ScriptExtensionProxy activate the contributing bundle using a
> transient flag when it creates a proxy (i.e. call
> Bundle.start(Bundle.START_TRANSIENT)). This would take extra work for
> ScriptExtensionProxy because it should probably read the
> Eclipse-LazyStart and/or the new Bundle-ActivationPolicy from OSGi R4.1
> specification to verify the bundle is actually lazy activated.
should i somehow lookup for the Bundle instance and call start() in it?


> 2) Make ScriptExtensionProxy abstract and force contributing groovy
> bundles to extend it with a real class which exists in the contributing
> bundle. Then when the extension is constructed it will automatically
> activate the bundle if it has a lazy activation policy.
I wouldn't like the client bundle to have any Java classes as it will
diminish the idea of having 100% scripting plug-in.


> Tom
Re: calling an activator class from a contributor plugin [message #94335 is a reply to message #94323] Mon, 06 August 2007 21:36 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
>> 1) Have ScriptExtensionProxy activate the contributing bundle using a
>> transient flag when it creates a proxy (i.e. call
>> Bundle.start(Bundle.START_TRANSIENT)). This would take extra work for
>> ScriptExtensionProxy because it should probably read the
>> Eclipse-LazyStart and/or the new Bundle-ActivationPolicy from OSGi
>> R4.1 specification to verify the bundle is actually lazy activated.
> should i somehow lookup for the Bundle instance and call start() in it?

Yes, you already get the contributing bundle in
Util.getInitializationData. This is the Bundle you search the script
for with Bundle.findEnties. That bundle object should be the bundle
used to activate the bundle. Do not simply call
contributingBundle.start(). That will persistently start you bundle
each time eclipse is started, instead call call
contributingBundle.start(Bundle.START_TRANSIENT).

A couple of things I noticed.

It is more safe to get the contributing bundle with the following code
in an OSGi environment.

if (contributor instanceof RegistryContributor) {
BundleContext context = getBundleContext();
try {
long id =
Long.parseLong(((RegistryContributor) contributor).getActualId());
return context.getBundle(id);
} catch (NumberFormatException e) {
// try using the name of the contributor below
}
}

Currently the extension registry only understands singleton bundles so
the contributor name is always going to be unique within a framework.
But we would like to loosen this restriction in the future. With the
code above you can use the RegistryContributor SPI to get the real
bundle ID of the contributor.

In you call to Bundle.findEntries, why do you pass true to recurse into
subdirectories? Doesn't this prevent the same file name to exist in
different directories?

>
>
>> 2) Make ScriptExtensionProxy abstract and force contributing groovy
>> bundles to extend it with a real class which exists in the
>> contributing bundle. Then when the extension is constructed it will
>> automatically activate the bundle if it has a lazy activation policy.
> I wouldn't like the client bundle to have any Java classes as it will
> diminish the idea of having 100% scripting plug-in.

If the bundle is not going to have any java code at all then how are you
going to implement a BundleActivator in groovy? When a bundle is
activated its BundleActivator is called. But the framework currently
only understands how to load a bundle activator if it is a java Class
that implements BundleActivator. We can work to figure out how to
activate a bundle that you load a script from, but I don't think it is
going to be very interesting to activate a bundle that has no
BundleActivator class.

I'm a groovy novice, but I played with both scala and groovy to write
OSGi bundles. In both of these cases I used some Eclipse tools that
compiled the script files into real java classes. Lets call this the
pre-compiled approach. Basically I had a library bundle that exported a
bunch of packages that the precompiled groovy code depended on. Then
the groovy bundle would require the groovy library bundle. To the OSGi
Framework the code all looks like normal javacode so everything works
well in that environment.

It may be interesting is to see if the same approach can be done but
instead compile the scripts into java bytecode at runtime. There are
some hooks in Equinox that allow you to hook into the classloader. Have
you considered trying to plugin to the classloader to compile and load
groovy bytecode on the fly? If you could do that then the plugin.xml
could just reference the classname of the compiled groovy code, not sure
if that is a reliable class name or not.

That approach could work for groovy and scala where the language can be
compiled into bytecode, but last I checked JRuby does not have an option
to compile ruby scripts to java bytecode.

Tom
Re: calling an activator class from a contributor plugin [message #94341 is a reply to message #94335] Tue, 07 August 2007 09:10 Go to previous messageGo to next message
Anton Arhipov is currently offline Anton ArhipovFriend
Messages: 15
Registered: July 2009
Junior Member
> It is more safe to get the contributing bundle with the following code
> in an OSGi environment.

> if (contributor instanceof RegistryContributor) {
> BundleContext context = getBundleContext();
> try {
> long id =
> Long.parseLong(((RegistryContributor) contributor).getActualId());
> return context.getBundle(id);
> } catch (NumberFormatException e) {
> // try using the name of the contributor below
> }
> }

> Currently the extension registry only understands singleton bundles so
> the contributor name is always going to be unique within a framework.
> But we would like to loosen this restriction in the future. With the
> code above you can use the RegistryContributor SPI to get the real
> bundle ID of the contributor.

Tried that, nice, thanks for the notice!


> In you call to Bundle.findEntries, why do you pass true to recurse into
> subdirectories? Doesn't this prevent the same file name to exist in
> different directories?

I did not think about it, to be honest. I should use 'false' indeed.

> If the bundle is not going to have any java code at all then how are you
> going to implement a BundleActivator in groovy? When a bundle is
> activated its BundleActivator is called. But the framework currently
> only understands how to load a bundle activator if it is a java Class
> that implements BundleActivator. We can work to figure out how to
> activate a bundle that you load a script from, but I don't think it is
> going to be very interesting to activate a bundle that has no
> BundleActivator class.

I'm going to provide a facade BundleActivator in which run() method I will
delegate the call to a activator.groovy run() function.
For now I will just presume that a user will have to create an activator.*
script to be able to use the activator. I agree it is not the best
solution but at the moment it is just a proof of the concept. So far I
have only the proxy for extension, and the activator facade that will be
required for using the plugin to write bundles using the scripting
languages.

> I'm a groovy novice, but I played with both scala and groovy to write
> OSGi bundles. In both of these cases I used some Eclipse tools that
> compiled the script files into real java classes. Lets call this the
> pre-compiled approach. Basically I had a library bundle that exported a
> bunch of packages that the precompiled groovy code depended on. Then
> the groovy bundle would require the groovy library bundle. To the OSGi
> Framework the code all looks like normal javacode so everything works
> well in that environment.

This is something that James Ervin described here. Compiling the scripts
into class files and just referring to them in the plugin.xml.
http://iacobus.blogspot.com/2007/03/add-groovy-to-your-eclip se-plugin.html

I didn't want to precompile anything as I wanted to make it more "generic"
in sense of non-compilable scripts. That is why I just evaluate the
scripts and not compile them to bytecode.

> It may be interesting is to see if the same approach can be done but
> instead compile the scripts into java bytecode at runtime. There are
> some hooks in Equinox that allow you to hook into the classloader. Have
> you considered trying to plugin to the classloader to compile and load
> groovy bytecode on the fly? If you could do that then the plugin.xml
> could just reference the classname of the compiled groovy code, not sure
> if that is a reliable class name or not.

This is interesting. I think I will investigate it more a bit later.
But the pitfall is that you couldn't rely on the style in which the
scripts is written, e.g the script might not have any classes defined - it
might containt only functions and then the class name would have name like
"Script1" or something... even if the script name is action.groovy
So you cannot be sure about the name of the compiled class.

> That approach could work for groovy and scala where the language can be
> compiled into bytecode, but last I checked JRuby does not have an option
> to compile ruby scripts to java bytecode.

There isn't a separate jruby->bytecode compiler, but actually the bytecode
is being run in the JVM so it is being generated at the runtime when one
runs "jruby filename". AFAIK jruby uses ASM to generate the bytecode on
the fly.
Re: calling an activator class from a contributor plugin [message #94349 is a reply to message #94341] Tue, 07 August 2007 13:21 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Anton,

I will be interested to see the progress you make. Please report back
to the newsgroup any other issues you have. Also consider posting to
the equinox-dev mailing list once you have something stable that you
would like more folks to try out.

Thanks.

Tom.
Previous Topic:Any plans to support plugin Apects with Eclipse 3.3?
Next Topic:Add statusline to view
Goto Forum:
  


Current Time: Wed Apr 24 23:54:08 GMT 2024

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

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

Back to the top