[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: How can I pre-req an Optional plugin?
|
I was wondering what you cast the newly created instance of "foo" to. If you
don't have any compile time dependencies on "foo", it looks to me as if "foo"
should actually plugin into an extension point that plugin B should define.
Sorry Peter, but the classloader thing just looks a bit hacky.
Thomas
Peter Amhof wrote:
> 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.
> >
> >