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 question
----------------\
Paul Sandoz
x38109
+33-4-76188109