File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Extending RequestProcessor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Extending RequestProcessor" Watch "Extending RequestProcessor" New topic
Author

Extending RequestProcessor

jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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

Joined: Dec 02, 2002
Posts: 37
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.


<a href="http://husted.com/struts/book.html" target="_blank" rel="nofollow">Struts in Action</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extending RequestProcessor