users@jersey.java.net

Re: [Jersey] Looking for example of Search interface

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 16 Jul 2008 11:30:53 -0400

Assuming the query is supplied as query parameters you can write
something like this:

@Path("search")
@Produces("application/xml") // or something else
public class SearchResource {

   @Context UriInfo uriInfo;

   @GET
   public List<Result> search() {
     MultivaluedMap<String, String> queryParams =
uriInfo.getQueryParameters();
     // key is query parameter name, value is List<String> of values
     // process query, return result
   }
}

You also need to write a MessageBodyWriter for List<Result> or return
one of the supported standard return types like String or a JAXB bean.

HTH,
Marc.

On Jul 16, 2008, at 11:08 AM, Farrukh Najmi wrote:

>
> Dear colleagues,
>
> I am re-familiarizing myself with JSR 311 and Jersey to see if it
> provides value in implementing my RESTFul server.
>
> I have an existing service that supports an arbitrary number of
> search queries. Each search query supports arbitrary set of
> parameters that are supplied to the search action as name / value
> pairs. The supported set of querys and their parameters
> may be updated dynamically at any time.
>
> Conceptually my search interface maps to the following Java Interface:
>
> interface SearchInterface {
> List search(String queryId, Map<String, String> queryParametersMap);
> }
>
> I would appreciate any advice on whether jersey is a good fit for
> this and if so, some guidance on how to go about implementing such
> an interface to my service using Jersey. Any pointers to similar
> examples would be great too. Thanks for your help.
>
> --
> Regards,
> Farrukh Najmi
>
> Web: http://www.wellfleetsoftware.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.