users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 02 Jul 2008 08:24:42 +0200

On Jul 1, 2008, at 7:18 PM, Arul Dhesiaseelan wrote:

> Thanks Marc. It works.
>

A tip: creating a Client instance is expensive. If that is an issue
for you create one instance and reuse it. Client and WebResource are
thread-safe, so you can also reuse an instance of WebResource.

Paul.


> I was using the example just for illustration.
>
> -Arul
>
> Marc Hadley wrote:
>> 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.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>> ________________________________
>> Scanned by MessageLabs for Flux
>> ________________________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>