Solving a Plugin type framework in a different way

17 views
Skip to first unread message

heit...@gmail.com

unread,
Feb 26, 2013, 12:44:01 PM2/26/13
to pojosr-...@googlegroups.com
I have recently completed a web framework that supports the concept of Plugins, isolated from each other through the use of a custom classloader.  The classloader in question loads classes in a "local only" way, only delegating to the parent classloader for JRE, logging, and some J2EE classes.
This has worked mostly well, and I was pleased with the consistent success of the isolation....until today.  I've discovered that I am having problems with Annotation definitions for java.lang.reflect.Method.  It seems that Annotation definitions are cached after the first request to a particular Method instance, and thus custom annotations are "owned" by the first plugin that attempts to access them reflectively.  Amongst other things, this has prevented two plugins from playing well together when they both attempt to use Ibatis and various Ibatis related annotations.

One particular solution is to force class delegation to the parent classloader for custom annotations: this does not please me.

My question is, could such a classloader isolated framework be easily implemented using something like pojoSR?  I initially rejected osgi and being too massive a change within this organisation, but now I am living in dread of the next JRE/in house code "gotcha" to emerge from within this plugin framework.

Simply, I want to be able to 
1) define a plugin bundle (currently a zip containing implementations of a public API shared by all bundles and loaded by the parent classloader)
2) have interfaces discovered (currently done with an annotation scanner)
3) feel confident that no classloader leakage is likely to occur.

After seeing how Method.getAnnotation(..) and the underlying Annotation Parser works, I'm wondering how any framework can provide isolation for custom Annotations across bundles?

Any insight appreciated.
Reply all
Reply to author
Forward
0 new messages