Hello,
I may be having a slow day today but I'm trying to figure out how to do
the following:
Very simple example: I have two root "resource" providers:
/headoffice
/branch
where:
GET on /headoffice returns a list of headoffice names
GET on /branchreturns a list of all branch names
I would like to use the BranchResource as a Sub Resource provider on
HeadOfficeResource for re-use and to offer calls like:
/headoffice/{id}/branch
/headoffice/{id}/branch/{id} etc...
So now the branch resource is providing information on the branch but scoped
for a specific headoffice (the headoffice 'id' would be used in DB queries
etc)
However Im not sure how to annotate the HeadOfficeResource to allow this
@Path("/headoffice")
public cleass HeadOfficeResource {
....
// ------------------------------------
// Sub Resources
@Path("{id}/branch") << ??
public BranchResource getBranchResource(); << ??
}
I know there is no injection done for sub resources so there is no way for
me to get access to this particular {id} so is it a case of supplying the
getBranchResource() with the id as a constructor param and using that with
the calls i.e.:
public BranchResource getBranchResource(@PathParam("id") final String
headOfficeId) {
return new BranchResource(headOfficeId);
}
Is there a better more JAX-RS/Jersey way of approaching this ?
I would like to avoid having GlobalBranchResource and
HeadOfficeSpecifcBranchResource ;-) if possible
Thanks in advance,
-A-
--
View this message in context: http://n2.nabble.com/Design-Question---Sub-Resources-tp2938738p2938738.html
Sent from the Jersey mailing list archive at Nabble.com.