Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extending RequestProcessor

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a class called CeMORRequestProcessor that extends RequestProcessor, and overrides the init() method so that I can add a ServiceFactory to the context (probably would make more sense to extend ActionServlet instead, but according to what I've read about 1.1, RequestProcessor is the way to go).
I've placed the following controller mapping in struts-config.xml
<controller processorClass="businesstier.CeMORRequestProcessor"/>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
The Tiles stuff was there already.
If I take out the TilesRequestProcessor line, I get an error that the specified RequestProcessor isn't compatible with TilesRequestProcessor. This also happens if I have my processor listed after the tiles one. However, if I put it first, I don't get the incompatible error, but my RequestProcessor never gets initialized (the ServiceFactory is never placed in the context).
I put context.log(...) as the second line in my init method, but it never appears to get called.
Any idea what the heck I am doing wrong. At a loss here, and all the tutorials/books I've read through seem to state that this is all I need to do. However, they never override init, so that could be my problem.
Just trying to initialize my factory and stick it somewhere that all the actions have access to.
Thanks!
Jason
 
Ted Husted
Author
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you only need access to an init method, you can create an Action that extends the PlugIn interface, and register that in the struts-config. The RequestProcessor is really for processing requests at runtime. The PlugIn gives you access to the init and done methods. Tiles has confused this issue a bit, since it uses both.
HTH, Ted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic