avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <pe...@apache.org>
Subject Re: Basic questions
Date Mon, 13 May 2002 11:15:54 GMT
On Sat, 11 May 2002 09:41, Pete Carapetyan wrote:
> Peter, I would be interested in knowing more about your use of  Struts
> with Avalon. Did you use Struts as an Avalon component, or did you use
> it outside the container? If you used it as a component, did you have to
> refactor it?  Struts is my first order of business as far as
> implementing Avalon,

Actually there was very little intergation between Avalon and struts. I reused 
the struts configuration file to set up the actions and mapping etc. I also 
used the default struts logging that just printed out to console (or was it 
to the servlet log file?).

I could have redirected all my logging to one place and wrote a custom servlet 
like ActionServlet but it was easier (and faster to develop) if I didn't. For 
a larger product I would have tried to centralize logging and configuration 
but in my case I didn't. 

Anyways my basic actions looks something like the following. (Note I still 
haven't looked at my old code so the exact signatures may be off but you 
should get the idea).

public class MyAction extends BaseAction
  public ActionForward execute( ... )
    final ComponentManager cm =        

   SomeComponent sc = (SomeComponent)cm.lookup( SomeComponent.ROLE );
   if( sc.doSomething() )
      return ActionForward(...);
     return ActionError(...) 

Then I had another servlet that on startup would put the ComponentManager in 
the servlet context.

> Peter Donald wrote:
> >On Sat, 11 May 2002 07:37, Leo Simons wrote:
> >>>7. Anybody  can provide  a real  working example  of the Struts +
> >>>Framework combination?
> >>
> >>Struts is a pragmatically developed framework where the developers chose
> >>to work with a fundamentally crappy idea (JSP) because it is in
> >>widespread use (this is a big assumption :).
> Is it jsps that are crappy per se, or just the fact that they can be,
> and are often, abused? 

Both. JSP compilers have never made it easy to locate source of errors and 
generally the compile cycle is way longer than it needs to be. Combine that 
with the fact that taglibs require way too much configuration IMHO and are 
painful to write leads to lots of scriptlets and uglies. Add to the fact that 
you basically require programmers to write the pages and it adds up to 

Recently with JSTL and enough prepackaged taglibs, the negatives can be 
reduced significantly but you still basically require programmers to manage 

Personally I still prefer templating engines but when more stuff gets 
standardized in JSPs and they becomes less painful to use maybe this will 
change ;)

> >I pretty much put all biz logic in Avalon components, placed these
> > components in ServletSession via startup servlets and then had each
> > Action retrieve the required components/services from ServletSession and
> > work from there. Each action basically called some avalon components then
> > stuffed the results back in a Velocity context and that was it.
> Ouch. All in the session? Hmm. I prefer keeping the key in the session,
> and everything else possible in the persistence layer. Scalability could
> be a bit of a problem, otherwise.

Theres only 3-4 objects I put in the ServletSession. These servlets are either 
another directory service (like ComponentManager) or act as facades onto 
complex buisness logic.

While this approach is a little less type safe and relies on order of loadup 
of servlets and when stuff gets put in the session it seems to be the "J2EE" 
way :)


Peter Donald

To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

View raw message