[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: How can I pre-req an Optional plugin?
|
Randy,
Unfortunately in 1.0 plugin prereqs are hard. As you observed, if A is not
found, B is deactivated. This is a known problem that we tried to get fixed
for 1.0 but didn't make it. It is high on the list for 2.0.
The only way around this for now is to remove the prereq from B and use code
similar to Peter's suggestion below. The problem is that you then is how to
handle the resultant classes/objects. For somethings you will have to use
reflection. In some cases you may be able to declare a common superclass or
interface that A's classes extends/implements. If this type were accessible
to B, you could cast and use normal coding practices.
Jeff
"Peter Amhof" <peter_amhof@xxxxxxx> wrote in message
news:9nofko$b6t$1@xxxxxxxxxxxxxxxx
> I would do it like this:
>
> // first get plugin A by it's id (should be it's folder name?)
> Plugin aPlugin= org.eclipse.core.runtime.Platform.getPlugin(String
> pluginID);
> if (aPlugin == null) return; // plugin A not installed
> ClassLoader loader= aPlugin.getDescriptor().getPluginClassLoader();
> Class aClass= loader.loadClass(myClassName);
>
> mfg feser aka peter paul amhof
>
> "Randy Hudson" <none@xxxxxxx> schrieb im Newsbeitrag
> news:9noceg$9om$1@xxxxxxxxxxxxxxxx
> > How can I have Plugin B pre-req Plugin A, but also no care if Plugin A
is
> > not installed. For example, we are trying to dynamically find a class
by
> > using Class.forName("foo") to see if a class from Plugin A is around.
If
> it
> > is, great, and we will then instantiate that class foo. If not, we
don't
> > care.
> >
> > Currently Plugin B is getting deactiviated if Plugin A is not found.
> >
> >
>
>