On Sun, 8 Jul 2001, Jonathan Asbell wrote:

> Craig could you explain a little more about ........" to *modify* what
> happens next?  For example, let's say you wanted to implement "is the user
> logged on?" checking as an event listener.  How would the listener indicate
> back to the framework that the request should be redirected to the logon
> page?......"
> 
> I dont understand the problem completely
> 

Sure.

Typically (or at least from what I've seen), event listeners in Java are
notified about things that happen, but cannot directly affect the control
flow of what will happen next (with the possible exception of
VetoableChangeListener that allows a listener to "veto" a change to a
particular property).  Notification is very useful, but it's not
sufficient to meet all the needs.

My example use case was a typical scenario where notification is
insufficient.  Let's say we want to take advantage of the fact that all
requests flow through the controller, and implement "is the user currently
logged on" checking.  If the user is *not* currently logged on, he or she
should be redirected to the login page, instead of executing the action
that would normally be executed.

In Struts 1.0, you could implement this by extending ActionServlet and
override, say, processActionPerform() to add your check.  That's certainly
feasible, but it requires an understanding of the internals of
ActionServlet.

In the spirit of the "extensions" or "services framework" idea, we've been
talking about the idea of adding event listeners dynamically, based on
configuration information in struts-config.xml.  That part is pretty
straightforward, but I still cannot use an event listener to implement the
"is the user currently logged on" check, because listeners cannot change
the control flow.

It seems to me that we want to look at the basic processing done by
ActionServlet for each request as a sort of "workflow" of prebuilt tasks,
and allow you to dynamically plug in extensions or services *anywhere* in
the flow.  And, the configuration mechanism (or workflow script) needs to
support conditional logic so that a particular extension can say things
like "we are through processing this request now, so the rest of the
standard processing should be skipped".

I've been spending some airplane time writing down an approach to this --
it's almost ready to be proposed to STRUTS-DEV for consideration.  It just
seems to me that, since we're considering some pretty radical surgery on
ActionServlet, that we should implement something more powerful than just
an event notification gadget.

Craig

Reply via email to