Marc Hadley wrote:
> We decided that the default lifecycle for a resource class would be
> per-request but didn't rule out others. Another obvious candidate is a
> per-application singleton and, while its possible for resource class
> methods to defer to an application-managed singleton, I think it would
> be worth going the extra-mile to offer that option in the API. I propose
> to add a @Scope annotation as follows:
>
> @Target({ElementType.TYPE})
> public @interface Scope {
> public enum Lifecycle {REQUEST, APPLICATION};
>
> public Lifecycle value() default Lifecycle.REQUEST;
> }
>
> Omission of the annotation would be equivalent to inclusion with a value
> of REQUEST.
>
> A root resource class annotated with @Scope(APPLICATION) would be
> required to a have a zero argument constructor and be thread-safe. The
> JSR 311 implementation would only ever instantiate a single instance per
> application and re-use that for all requests.
>
Just it clarify for those that have not read the terminology section of
the latest specification draft:
Resource class: A Java class that uses JAX-RS annotations to
implement a corresponding Web resource, see chapter
2.
Root resource class: A resource class annotated with @UriTemplate. Root
resource classes provide the roots of the resource
class tree and provide access to sub-resources, see
chapter 2.
Paul.
> Thoughts ?
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109