knime-ip / knip-scijava

KNIP - SciJava Commands Plugin
2 stars 3 forks source link

ResourceAwareClassLoader #3

Closed Squareys closed 9 years ago

Squareys commented 9 years ago

@dietzc I just merged 239f6b2c06d42d2732d723f07814afc9f9c4eb03 into my changes and noticed it kinda breaks my code for scripting: Before this commit, all bundles on the classpath were found and urls were added. Now it's only the bundles required by org.knime.knip.scijava.core, which is not alot:

Is this exactly how you intended ResourceAwareClassLoader to work? Otherwise I would try to get the previous functionality back in a similarly clean way.

Squareys commented 9 years ago

FrameworkUtil.getBundle(aClass).getBundleContext().getBundles() could possibly do the job.

Returns a list of all installed bundles.

This method returns a list of all bundles installed in the OSGi environment at the time of the call to this method. However, since the Framework is a very dynamic environment, bundles can be installed or uninstalled at anytime.

Could also be overkill, though. I would suggest adding at least the current bundle itself and also make the class whose bundle requirements are parsed optionally specifiable in the constructor.

Squareys commented 9 years ago

I would suggest [...] make the class whose bundle requirements are parsed optionally specifiable in the constructor

It seems as if that does the job.

Squareys commented 9 years ago

This should be fixed now. I added some javadoc aswell. Just in case others depend on ResourceAwareClassManager, the old constructor is now deprecated and delegates to the new constructor.

@dietzc Maybe you could have a quick look at this. Also, some cleanup is left to do: I believe ResourceAwareClassManager is a duplicate of a class that already exists somewhere else. It would be nice, if that would be a dependency to org.knime.knip.scijava.core instead.

dietzc commented 9 years ago

I am not sure which class you mean. However, the Plugin using the the RACL should only get the resources from the classes which are dependencies of the Plugin for registered buddies, as it wont be able to use other classes anyway. The resources of the Plugin itself are discovered anyway. So I dont really understand what you try to achieve?! Maybe you need something else?!

Squareys commented 9 years ago

Yeah, sorry, I tried to find the class myself and couldn't find it. I guess I was hallucinating.

The issue was, that not the resources of the plugin using the RACL were gathered, but only the resources of the plugin which contains the RACL.

But, as I mentioned already, it's fixed (1e1cd03).