• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Extending RequestProcessor

 
Chicken Farmer ()
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
 
Author
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.
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic