users@jsr311.java.net

Re: Path annotations for class resources

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 28 Feb 2008 12:56:10 +0100

Bill Burke wrote:
>
>
> Sergey Beryozkin wrote:
>> Hi
>>
>> I have few questions about the @Path annotations
>>
>> 1. Is it a requirement that a root resource class is annotated with
>> @Path ?
>> Is it an error if a root resource is missing this annotation ? If not
>> then can a default value like "/" be used ?
>>
>
> @Path is not required.

That is not correct. It is a requirement for a *root resource class*, as
per section 1.5 Terminology.

A "/" can be used.

A "resource class" does not require a @Path on the class. If a root
resource class is used in the context of a resource class (namely an
instance is returned from a sub-resource locator method) then the @Path
on the class is ignored.

A "reource class" should have one or more of "resource methods",
"sub-resource locators" or "sub-resource methods".



> I think you either need a http method annotation
> and/or a path annotation someplace. "/" can be used as well.
>
>> The spec says that root resources are directly annotated with @Path
>> but no more information is given
>>

The spec does not yet specify how those root resource classes are
discovered. See also section 2.5, specifically step 1 and 1 (a).


>> 2. Can classes representing subresources locators be annotated with
>> @Path ?
>>
>
> Yes.
>

But the @Path on the class of the returned instance will not be
processed in this context. In this context what matters is the @Path on
the sub-resource locator method.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109