Peter Liu wrote:
> Hi Paul,
>
> Thanks for the explanation. BTW, has this been implemented in the trunk so
> we can try it out?
>
Yes (although @SubResources has not been removed yet), you are already
using (and have been since the first release) sub-resource locators for
some things :-)
Paul.
> Peter
>
> Paul Sandoz wrote:
>> Peter Liu wrote:
>>> Hi,
>>>
>>> In the upcoming 0.2 release, @SubResource annotation will be removed.
>>> What is the replacement for it and could you provide some code snippet
>>> that demonstrate the new approach?
>>>
>>
>> Sure.
>>
>> Before:
>>
>> @UriTemplate("/a")
>> @SubResources(MySubResource.class)
>> class MyResource {
>> }
>>
>> @UriTemplate("b")
>> class MySubResource {
>> }
>>
>>
>> After:
>>
>> @UriTemplate("a")
>> class MyResource {
>>
>> // sub-locator method
>> @UriTemplate("b")
>> public getMySubResource(...) {
>> // Life-cycle is per-request
>> return new MySubResource(...);
>> }
>> }
>>
>> class MySubResource {
>> public MySubResource(...) { ... }
>> }
>>
>>
>> Points of note:
>>
>> - Removed the requirement that root resource classes have a URI template
>> that starts with a '/'. Now any resource class annotated with a URI
>> template is a root resource class and the URI template is relative to
>> the base URI of deployment.
>>
>> - MySubResource can still be root resource class but when used as part
>> of a sub-locator method the URI template on the class will be ignored.
>>
>> - Injection currently does not work on objects returned by sub-locator
>> methods (i.e. the same as it is today). The EG is having discussions
>> on life-cycle and injection. Until these discussions reach a
>> satisfactory conclusion we cannot do anything about this issue.
>>
>> Paul.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109