Leszek Gawron wrote:

The whole module idea is really great but (please correct me if I'm wrong):



<map:generate type="file" src="module:request:inputStream"/>


The o.a.c.components.modules.input.RequestModule provides this:

return ObjectModelHelper.getRequest(objectModel);

getRequest returns o.a.c.environment.Request which is an interface that is not
bound to http. You cannot reach the request's body from here.


You would appear to be right.

My answer is "lets add getInputStream to o.a.c.environment.request". After all, you've got stuff about cookies, sessions, hosts, etc, etc, which, whilst there's a level of abstraction there, it is still pretty HTTP focussed (which is fine). Adding this (and probably other similar ones) would help us in the direction of HTTP protocol independence. For example, the CLI doesn't work when some blocks are compiled in, because of their explicit HTTP references. If we redirected these via the Request interface, other environments could handle them as they wish, and we'd have greater environmental abstraction, which is a good thing.

Oh, and the above module:request:inputStream would work too!

To be able to read from input stream one has to do this:

HttpServletRequest request =    
 (HttpServletRequest) objectModel.get( HttpEnvironment.HTTP_REQUEST_OBJECT );
int contentLength = request.getContentLength();
PostInputStream stream = new PostInputStream(    request.getInputStream(),

                                               contentLength    );
InputSource     contentSource = new     InputSource( stream );
parser = ( DOMParser ) manager.lookup( DOMParser.ROLE );
return parser.parseDocument( contentSource );

How can I reach the XModuleSource from XSP? I need it for processing XML
document that is passed as request body (right now I use the code pasted
above).


Never used XSP, so I can't help here.

Regards, Upayavira




Reply via email to