This might seem outlandish but have you considered modeling a server
instead of a client? Then you can send request messages to it and get
back response messages.

   SolrSelectResponse response = server.select(selectOptions);


I like the model, but the I want to be able easily write a client for
a custom SolrRequestHandler.  The server model can't be tied directly
to update(), select(), ping() etc

right now I'm working with:

public interface SolrServer
{
 SolrResponse request(
        final String path,
        final METHOD method,
        final RequestParams params,
        final Collection<ContentStream> streams,
        final ResponseStreamProcessor processor ) ;
}

public interface ResponseStreamProcessor
{
 SolrResponse processResponseStream( InputStream body );
}

public interface SolrRequest
{
 SolrResponse process( SolrServer server ) ;
}

- - - - - - - - - -

This would be a sample 'ping' request:

public class SolrPing implements SolrRequest
{       
 public SolrResponse process(SolrServer server)  {
   return (SolrPingResponse)server.request(
     "/admin/ping", METHOD.GET, null, null, new ResponseStreamProcessor()  {
         public SolrResponse processResponseStream(InputStream body)  {
             // something real would actually process the body
             return new SolrPingResponse();
         }
        });
 }
}

And you can call it with:

 new SolrPing().process( server );

Reply via email to