|
(no subject) [message #703769 is a reply to message #702624] |
Wed, 27 July 2011 22:03 |
Wim Jongman Messages: 423 Registered: July 2009 |
Senior Member |
|
|
Hi,
Yes classloader tricks are a no-go in OSGi/RCP.
Your binaries are not visible but I am guessing that your graps can come and
go. I think you should look at OSGi dynamic services or at Extension Points.
Basically, a graph bundle should register itself through an OSGi service or
an Extension point where it can be picked up by the VM plugin.
Again, do not fiddle with the classloader.
Regards,
Wim
> Hey there,
>
> I'm facing a problem concerning dynamic class loading. I have a file
Algorithm.java (pastebin . com/ CdGXdPFw) which is compiled by an instance of
the javax.tools.JavaCompiler API. After that it's supposed to be loaded and a
new instance is supposed to be created. All this takes place in a RCP
project, let's call it VM.
> The algorithm needs (as you can see in the source code) some datatypes from
other plugins, let's call one of these other plugins "graph". However, the
graph-plugin must not appear in the required-plugins section of VM's
MAINFEST.MF.
> This is where my problem lies:
> I try to create an instance of Algorithm using this code:
>
> algoInst = (AbstractAlgo) algoClass.getConstructors()[0].newInstance();
>
> But it gives me class loading errors: pastebin . com/ k18gcpKS
>
> So i tried to created a URLClassLoader with the URL to the Graph package et
voila, this works:
>
loader.loadClass("de.unisiegen.informatik.bs.alvis.graph.datatypes.PCGraph"));
>
> Even when I tried to call newInstance like this:
> algoInst = (AbstractAlgo) Class.forName(algoClass.getName(), false,
loader).getConstructors()[0].newInstance();
>
> it does not work, although this loader is able to load PCGraph...
>
> How do I get the instance of Algorithm using this class loader? I'm
probably missing some RCP/ClassLoading-Basics here and need another pair of
eyes...
>
> Thanks for your help!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03714 seconds