users@jersey.java.net

Re: [Jersey] GrizzlyServerFactory ignores the path info from URI

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Thu, 05 Feb 2009 10:19:11 -0500

Salut,

delayed again...

Paul Sandoz wrote:
>
> On Feb 3, 2009, at 5:37 PM, Jeanfrancois Arcand wrote:
>
>> Salut,
>>
>> sorry for the delay.
>>
>> Paul Sandoz wrote:
>>> On Jan 30, 2009, at 6:42 PM, Jeanfrancois Arcand wrote:
>>>> Salut,
>>>>
>>>> Paul Sandoz wrote:
>>>>> On Jan 30, 2009, at 4:32 PM, Jeanfrancois Arcand wrote:
>>>>>> Salut,
>>>>>>
>>>>>> Paul Sandoz wrote:
>>>>>>> Hi Naresh,
>>>>>>> Yes, that is an issue. Do you want to have a go fixing it? IIRC i
>>>>>>> was not sure how to set this context for the embedded Grizzly,
>>>>>>> ideally it is something we inform Grizzly of rather than support
>>>>>>> it in the container, but we could the latter if necessary.
>>>>>>
>>>>>> OK keep me posted on that issue as I would like to fix it asap in
>>>>>> Grizzly. Can you point me to a uses case I can try?
>>>>>>
>>>>> Basically we need a way to set some base URI path, equivalent say
>>>>> to the context path of a servlet.
>>>>> Jersey has the following method:
>>>>> public static SelectorThread create(URI u, Adapter adapter) { ... }
>>>>> we want to set the path of 'u' to be the base path of the selector
>>>>> thread and for the Adapter to be able to get that vase path.
>>>>> I think i can implement it myself in the Jersey GrizzlyAdapter but
>>>>> i guess this is something that might be rather common.
>>>>
>>>> Would GrizzlyAdapter.setRootFolder does the trick? The API is
>>>> already there right now and used for servicing static resources.
>>>> Take a look and let me know if this is not enough.
>>> Does the root folder have to correspond to an existing folder in the
>>> file system?
>>
>> Yes.
>>
>>> Say i have a base URI:
>>> http://localhost/base
>>> and i set the root folder to "base".
>>> If i do a GET http://localhost will the adapter still be serviced?
>>
>> Yes.
>>
>>> Actually Naresh found the following method:
>>> StaticResourcesAdapter.setResourcesContextPath
>>> and from reading the JavaDoc it might do just what we require? Naresh
>>> is investigating.
>>
>> Let say the root folder is:
>>
>> /home/aaa/bbb
>>
>> By default, if you set
>>
>> setRootFolder("/home/aaa/bbb");
>>
>> Request in the form of:
>>
>> http://host/f.txt
>>
>> will be serviced from the above folder. Now if you call:
>>
>> setResourcesContextPath("ccc");
>>
>> Then
>>
>> http://host/f.txt --> return 404
>> http://host/ccc/f.txt --> return 200
>>
>
> Thanks, that helps. So it is setResourcesContextPath we require.
>
> Just Grizzly try to determine the media type and do stuff like last
> modified or etag stuff with static content?

Yes Grizzly is able to determine that information.

Thanks!

--Jeanfrancois

>
> Thanks,
> Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>