• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extending RequestProcessor

 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic