Home » Eclipse Projects » Equinox » Question about host extension points under OSGI
Question about host extension points under OSGI [message #42935] |
Fri, 04 June 2004 20:29 |
Eclipse User |
|
|
|
Originally posted by: chaves.nospam.inf.ufsc.br
(this was originally posted to the equinox-dev@eclipse.org)
From: Scott Lewis <slewis@...>
Subject: [equinox-dev] Question about host extension points under OSGI
Greetings,
I'm not a regular reader of this list, but a casual scan of the archive
didn't find anything about this question, so I'm going to ask it of this
group. My apologies in advance if the answer is well-known.
I'm building some plugins that provide host extension points so that
other plugins can register themselves as 'providers' for some basic apis
provided by my plugins. In one of my plugin 'start(BundleContext)'
method, I define and call a routine called 'setupHostExtensionPoints()'
to configure host extension points, as per the article (Notes on Eclipse
Plugin Architecture):
http://www.eclipse.org/articles/Article-Plug-in-architecture /plugin_architecture.html
Within my setupHostExtensionPoints, I have a piece of code that looks
like this:
ClassLoader loader =
pluginDescriptor.getPlugin().getClass().getClassLoader();
This is used to get the classloader for the plugin (client) that is
going to be using this host extension point. Then this classloader is
passed to a piece of code so that a client plugin class can be loaded
(via the 'loader' classloader) for my (host) plugin...e.g.
Class nsClass = loader.loadClass(nsClassName);
Constructor cons = nsClass.getDeclaredConstructor(new
Class[] {
String.class,String.class,String.class,String.class,String.c lass});
Namespace ns = (Namespace) cons.newInstance(new Object[]
{nsName,nsInstantiatorClass,nsProtocol,nsVersion,nsData});
// Now add to namespaces known
IDFactory.addNamespace(ns);
In this way, client plugins can add support (i.e. their classes) for
entirely new namespaces to my 'identity' plugin.
So what's the problem? Well, the call to get the classloader (necessary
to be able to load classes from the *client plugin's* codebase) depends
upon the getting the IPluginDescriptor:
IPluginDescriptor pluginDescriptor =
extension.getDeclaringPluginDescriptor();
but this interface (IPluginDescriptor) and the method
(getDeclaringPluginDescriptor()) are both deprecated now, because of the
move to the OSGI plugin model...where references to plugins are not
passed around 'freely'. And there's no analog to 'getPlugin()' in the
IExtensionPoint interfaces/classes.
But I don't need a reference to the actual plugin instance...I just need
it's classloader. Is access to another bundle's classloader provided in
some other way? If so, what is that access? Is it considered protected
as well? If so, how do host extension point providers allow client
plugins to have *their* classes loaded/bound to those host extension
points?
Thanks for any info,
Scott
|
|
|
Re: Question about host extension points under OSGI [message #42966 is a reply to message #42935] |
Fri, 04 June 2004 20:33 |
Eclipse User |
|
|
|
Originally posted by: chaves.nospam.inf.ufsc.br
Check bug 65438 for a similar request:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=65438
But in your case, why can't you use
IConfigurationElement.createExecutableExtension?
Rafael
Rafael Chaves (on behalf of Scott Lewis wrote:
> (this was originally posted to the equinox-dev@eclipse.org)
> From: Scott Lewis <slewis@...>
> Subject: [equinox-dev] Question about host extension points under OSGI
> Greetings,
> I'm not a regular reader of this list, but a casual scan of the archive
> didn't find anything about this question, so I'm going to ask it of this
> group. My apologies in advance if the answer is well-known.
> I'm building some plugins that provide host extension points so that
> other plugins can register themselves as 'providers' for some basic apis
> provided by my plugins. In one of my plugin 'start(BundleContext)'
> method, I define and call a routine called 'setupHostExtensionPoints()'
> to configure host extension points, as per the article (Notes on Eclipse
> Plugin Architecture):
>
http://www.eclipse.org/articles/Article-Plug-in-architecture /plugin_architecture.html
> Within my setupHostExtensionPoints, I have a piece of code that looks
> like this:
> ClassLoader loader =
> pluginDescriptor.getPlugin().getClass().getClassLoader();
> This is used to get the classloader for the plugin (client) that is
> going to be using this host extension point. Then this classloader is
> passed to a piece of code so that a client plugin class can be loaded
> (via the 'loader' classloader) for my (host) plugin...e.g.
> Class nsClass = loader.loadClass(nsClassName);
> Constructor cons = nsClass.getDeclaredConstructor(new
> Class[] {
> String.class,String.class,String.class,String.class,String.c lass});
> Namespace ns = (Namespace) cons.newInstance(new Object[]
> {nsName,nsInstantiatorClass,nsProtocol,nsVersion,nsData});
> // Now add to namespaces known
> IDFactory.addNamespace(ns);
> In this way, client plugins can add support (i.e. their classes) for
> entirely new namespaces to my 'identity' plugin.
> So what's the problem? Well, the call to get the classloader (necessary
> to be able to load classes from the *client plugin's* codebase) depends
> upon the getting the IPluginDescriptor:
> IPluginDescriptor pluginDescriptor =
> extension.getDeclaringPluginDescriptor();
> but this interface (IPluginDescriptor) and the method
> (getDeclaringPluginDescriptor()) are both deprecated now, because of the
> move to the OSGI plugin model...where references to plugins are not
> passed around 'freely'. And there's no analog to 'getPlugin()' in the
> IExtensionPoint interfaces/classes.
> But I don't need a reference to the actual plugin instance...I just need
> it's classloader. Is access to another bundle's classloader provided in
> some other way? If so, what is that access? Is it considered protected
> as well? If so, how do host extension point providers allow client
> plugins to have *their* classes loaded/bound to those host extension
> points?
> Thanks for any info,
> Scott
|
|
|
Goto Forum:
Current Time: Sun May 05 01:57:35 GMT 2024
Powered by FUDForum. Page generated in 0.03203 seconds
|