users@jersey.java.net

Re: [Jersey] invoking resource methods using relative URI than absolute URI

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 01 Jul 2008 12:06:29 -0400

Take a look at the UriInfo interface and UriBuilder. Those allow you
to construct URIs to resource classes without having to hard code
anything. E.g.:

@Context UriInfo ui;
URI bURI = ui.getBaseUriBuilder().path(B.class).build();

BTW, try to avoid method names in URIs. URIs should be used to
identify resources, not methods.

Marc.

On Jul 1, 2008, at 11:57 AM, Arul Dhesiaseelan wrote:

> Hello,
>
> I have 2 resources: A & B
>
> I would like to invoke A.m1() from B.m1().
>
> I am currently using Jersey Client API in resource B to achieve this.
>
> Client c = Client.create();
> WebResource r = c.resource("http://localhost:8080/rest/A/m1");//
> c.resource("/rest/A/m1") ?
> String result = r.accept("text/plain").get(String.class);
>
> Is it possible to invoke the method using relative URI than using
> absolute URI?
>
> Thank you,
> Arul
>
>
>
> ---------------------------------------------------------------------
> 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.