talking about the URL structure made me realize that the Servlet should dicate the URL structure and the param parsing, but it should do it after giving the RequestParser a crack at any streams it wants (actually i think that may be a direct quote from JJ ... can't remember now) ... *BUT* the RequestParser may not want to provide a list of streams, untill the params have been parsed (if for example, one of the params is the name of a file)
so what if the interface for RequestParser looked like this... interface RequestParser { public init(NamedList nl); // the usual /** will be passed the raw input stream from the * HttpServletRequest, ... may need other HttpServletRequest info as * SolrParam (ie: method, content-type/content-length, ...but we use * a SolrParam instance instead of the HttpServletRequest to * maintain an abstraction. */ public Iterable<ContentStream> preProcess(SolrParam headers, InputStream s); /** garunteed that the second arg will be the result from * a previous call to preProcess, and that that Iterable from * preProcess will not have been inspected or touched in anyway, nor * will any refrences to it be maintained after this call. * this method is responsible for calling * request.setContentStreams(Iterable<ContentStreams) as it sees fit */ public void process(SolrRequest request, Iterable<ContentStream> i); } ...the idea being that many RequestParsers will choose to impliment one or both of those methods as a NOOP that just returns null but if they want to impliment both, they have the choice of obliterating the Iterable returned by preProcess and completely replacing it once they see the SolrParams in the request.... : specifically what i had in mind was something like this... : : class SolrUberServlet extends HttpServlet { : public service(HttpServletRequest req, HttpServletResponse response) { : SolrCore core = getCore(); : Solr(Query)Response solrRsp = new Solr(Query)Response(); : : // servlet specific method which does minimal inspection of : // req to determine the parser name : String p = pickRequestParser(req); : : // looks up a registered instance (from solrconfig.xml) : // matching that name : RequestParser solrParser = coreGetParserByName(p); : // let the parser preprocess the streams if it wants... Iterable<ContentStreams> s = solrParser.preprocess(req.getInputStream()) // build the request using servlet specific URL rules Solr(Query)Request solrReq = makeSolrRequest(req); // let the parser decide what to do with the existing streams, // or provide new ones solrParser.process(solrReq, s); : // does exactly what it does now: picks the RequestHandler to : // use based on the params, calls it's handleRequest method : core.execute(solrReq, solrRsp) : : // the rest of this is cut/paste from the current SolrServlet. : // use SolrParams to pick OutputWriter name, ask core for instance, : // have that writer write the results. : QueryResponseWriter responseWriter = core.getQueryResponseWriter(solrReq); : response.setContentType(responseWriter.getContentType(solrReq, solrRsp)); : PrintWriter out = response.getWriter(); : responseWriter.write(out, solrReq, solrRsp); : : } : } : : : -Hoss : -Hoss