There's a bug (ROL-893) that highlights a fundamental problem in the
coding of the TopicTagPlugin, but also perhaps an issue in the plugin
interface and its instantiation model, which is what I wanted to discuss.
Going back in the SVN history, it appears that the instantiation model
hasn't changed since 1.2, but I think it must have changed not long
before that.
The presence of init(RollerRequest rreq, VelocityContext ctx) in the
PagePlugin interface suggests that plugin instances should not be shared
across RollerRequests. I'm pretty sure this was the case in some prior
version. That is, I believe that the PageHelper was creating new
instances of each plugin class prior to calling init, and this is also
suggested by some of the variable names in PageHelper (which refer to
classes rather than instances).
However, now it appears (unless I am totally confused in my reading of
the code) that instances are created only once at servlet context
initialization, while the init() is still called per request. So if a
plugin happens to use init() to set up some member values, it can cause
unpredictable behavior now because the instance is shared. I believe
this is causing ROL-893, and it means a bit of rewrite and possibly a
decrease in the functionality of the TopicTagPlugin (with respect to
using user-specific bookmarks to allow defining alternate tag sites).
I'm pretty sure I understood the instantiation model when I originally
wrote the plugin, and it was safe when I originally wrote it, but now it
is very unsafe. Did this behavior change around 1.1 - 1.2? Or am I
confused? Does anyone else get what I'm talking about with the
expectation that having the current request and velocity context in the
init() call suggests to the implementor that it wou't be shared?
--a.
- PagePlugin instantiation model Anil Gangolli
-