dev@javaserverfaces.java.net

Re: Seeking Review 465-ManagedBeanAnnotations

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Thu, 06 Nov 2008 13:10:02 -0800

Jason Lee wrote:
> This looks pretty good to me. I do have a question, though: Why do
> only ViewScoped and NoneScoped specify @Retention? Unless I'm missing
> it, the others seem to lack that annotation.
That's a side effect of the diff.
>
> Also, what is the status of the discussion of multiple instances of a
> particular class in a managed bean, a la Seam's @Roles? Has that been
> resolved? It's a bit outside the scope (no pun intended) of this
> patch, but it brought the question to mind...
@ManagedBeans is present in the api. It supports this functionality.


>
> On Nov 5, 2008, at 1:49 PM, Ed Burns wrote:
>
>> https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=465
>>
>>
>> 465-ManagedBeanAnnotations
>>
>> Javadocs and small changes related to managed bean annotations
>>
>> M jsf-api/src/javax/faces/model/ApplicationScoped.java
>> M jsf-api/src/javax/faces/model/SessionScoped.java
>> M jsf-api/src/javax/faces/model/ManagedBean.java
>> M jsf-api/src/javax/faces/model/RequestScoped.java
>>
>> - Fix PENDING with spec language
>>
>> A jsf-api/src/javax/faces/model/ViewScoped.java
>>
>> - Unless someone can demonstrate otherwise, I believe we need scope
>> annotations for every specified value for managed-bean-scope.
>>
>> A jsf-api/src/javax/faces/model/NoneScoped.java
>> D jsf-api/src/javax/faces/model/UnScoped.java
>>
>> - I believe NoneScoped is more consistent than UnScoped.
>>
>> M
>> jsf-ri/src/com/sun/faces/application/annotation/ManagedBeanConfigHandler.java
>>
>>
>> - Suggested implementation changes
>>
>> I'll be checking in the javadoc only portion of these changes now but
>> will wait for review for the remainder.
>>
>> SECTION: Diffs
>>
>> Index: jsf-api/src/javax/faces/model/ApplicationScoped.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/ApplicationScoped.java (revision
>> 5688)
>> +++ jsf-api/src/javax/faces/model/ApplicationScoped.java (working
>> copy)
>> @@ -7,10 +7,12 @@
>> import java.lang.annotation.Inherited;
>>
>> /**
>> - * RELEASE_PENDING (edburns,rogerk) Please update the docs.
>> - * <p class="changed_added_2_0">The presence of this annotation
>> along with
>> - * {_at_link @ManagedBean} on a class indicates this managed bean is to be
>> - * <code>application</code> scoped.</p>
>> +
>> + * <p class="changed_added_2_0">When this annotation, along with {_at_link
>> + * ManagedBean} is found on a class, the runtime must act as if a
>> + *
>> <code>&lt;managed-bean-scope&lt;application&lt;managed-bean-scope&gt;</code>
>>
>> + * element was declared for the corresponding managed bean.</p>
>> +
>> *
>> * @since 2.0
>> */
>> @@ -18,4 +20,4 @@
>> @Target(ElementType.TYPE)
>> @Inherited
>> public @interface ApplicationScoped {
>> -}
>> \ No newline at end of file
>> +}
>> Index: jsf-api/src/javax/faces/model/ViewScoped.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/ViewScoped.java (revision 0)
>> +++ jsf-api/src/javax/faces/model/ViewScoped.java (revision 0)
>> @@ -0,0 +1,21 @@
>> +package javax.faces.model;
>> +
>> +import java.lang.annotation.Retention;
>> +import java.lang.annotation.RetentionPolicy;
>> +import java.lang.annotation.Target;
>> +import java.lang.annotation.ElementType;
>> +import java.lang.annotation.Inherited;
>> +
>> +/**
>> + * <p class="changed_added_2_0">When this annotation, along with {_at_link
>> + * ManagedBean} is found on a class, the runtime must act as if a
>> + *
>> <code>&lt;managed-bean-scope&lt;view&lt;managed-bean-scope&gt;</code>
>> + * element was declared for the corresponding managed bean.</p>
>> + *
>> + * @since 2.0
>> + */
>> +_at_Retention(RetentionPolicy.RUNTIME)
>> +_at_Target(ElementType.TYPE)
>> +_at_Inherited
>> +public @interface ViewScoped {
>> +}
>> Index: jsf-api/src/javax/faces/model/UnScoped.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/UnScoped.java (revision 5688)
>> +++ jsf-api/src/javax/faces/model/UnScoped.java (working copy)
>> @@ -1,21 +0,0 @@
>> -package javax.faces.model;
>> -
>> -import java.lang.annotation.Retention;
>> -import java.lang.annotation.RetentionPolicy;
>> -import java.lang.annotation.Target;
>> -import java.lang.annotation.ElementType;
>> -import java.lang.annotation.Inherited;
>> -
>> -/**
>> - * RELEASE_PENDING (edburns,rogerk) Please update the docs.
>> - * <p class="changed_added_2_0">The presence of this annotation
>> along with
>> - * {_at_link @ManagedBean} on a class indicates this managed bean is to be
>> - * <code>none</code> scoped.</p>
>> - *
>> - * @since 2.0
>> - */
>> -_at_Retention(RetentionPolicy.RUNTIME)
>> -_at_Target(ElementType.TYPE)
>> -_at_Inherited
>> -public @interface UnScoped {
>> -}
>> \ No newline at end of file
>> Index: jsf-api/src/javax/faces/model/SessionScoped.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/SessionScoped.java (revision 5688)
>> +++ jsf-api/src/javax/faces/model/SessionScoped.java (working copy)
>> @@ -7,10 +7,10 @@
>> import java.lang.annotation.Inherited;
>>
>> /**
>> - * RELEASE_PENDING (edburns,rogerk) Please update the docs.
>> - * <p class="changed_added_2_0">The presence of this annotation
>> along with
>> - * {_at_link @ManagedBean} on a class indicates this managed bean is to be
>> - * <code>session</code> scoped.</p>
>> + * <p class="changed_added_2_0">When this annotation, along with {_at_link
>> + * ManagedBean} is found on a class, the runtime must act as if a
>> + *
>> <code>&lt;managed-bean-scope&lt;session&lt;managed-bean-scope&gt;</code>
>> + * element was declared for the corresponding managed bean.</p>
>> *
>> * @since 2.0
>> */
>> @@ -18,4 +18,4 @@
>> @Target(ElementType.TYPE)
>> @Inherited
>> public @interface SessionScoped {
>> -}
>> \ No newline at end of file
>> +}
>> Index: jsf-api/src/javax/faces/model/ManagedBean.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/ManagedBean.java (revision 5688)
>> +++ jsf-api/src/javax/faces/model/ManagedBean.java (working copy)
>> @@ -67,13 +67,13 @@
>> * <em>managed-bean-name</em> is taken to be <code>Bean</code>. The
>> * fully qualified class name of the class to which this annotation is
>> * attached is taken to be the <em>managed-bean-class</em>.</p>
>> - *
>> - * // RELEASE_PENDING (edburns,rogerk) docs
>> - * <p>The scope of the managed bean declared using one of {_at_link
>> RequestScoped},
>> - * {_at_link SessionScoped}, {_at_link ApplicationScoped}, or {_at_link
>> UnScoped} annotations.
>> - * If the scope annotations are omitted, the bean is assumed to be
>> <code>request</code>
>> - * scoped.</p>
>> - *
>> +
>> + * <p>The scope of the managed bean is declared using one of {_at_link
>> + * NoneScoped}, {_at_link RequestScoped}, {_at_link ViewScoped}, {_at_link
>> + * SessionScoped}, {_at_link ApplicationScoped} annotations. If the scope
>> + * annotations are omitted, the bean must be handled as if the {_at_link
>> + * RequestScoped} annotation is present.</p>
>> +
>> * <p>
>> * If the value of the {_at_link #eager} attribute is
>> * <code>true</code>, the runtime must instantiate this class when the
>> Index: jsf-api/src/javax/faces/model/RequestScoped.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/RequestScoped.java (revision 5688)
>> +++ jsf-api/src/javax/faces/model/RequestScoped.java (working copy)
>> @@ -7,10 +7,10 @@
>> import java.lang.annotation.Inherited;
>>
>> /**
>> - * RELEASE_PENDING (edburns,rogerk) Please update the docs.
>> - * <p class="changed_added_2_0">The presence of this annotation
>> along with
>> - * {_at_link @ManagedBean} on a class indicates this managed bean is to be
>> - * <code>request</code> scoped.</p>
>> + * <p class="changed_added_2_0">When this annotation, along with {_at_link
>> + * ManagedBean} is found on a class, the runtime must act as if a
>> + *
>> <code>&lt;managed-bean-scope&lt;request&lt;managed-bean-scope&gt;</code>
>> + * element was declared for the corresponding managed bean.</p>
>> *
>> * @since 2.0
>> */
>> Index: jsf-api/src/javax/faces/model/NoneScoped.java
>> ===================================================================
>> --- jsf-api/src/javax/faces/model/NoneScoped.java (revision 0)
>> +++ jsf-api/src/javax/faces/model/NoneScoped.java (revision 0)
>> @@ -0,0 +1,21 @@
>> +package javax.faces.model;
>> +
>> +import java.lang.annotation.Retention;
>> +import java.lang.annotation.RetentionPolicy;
>> +import java.lang.annotation.Target;
>> +import java.lang.annotation.ElementType;
>> +import java.lang.annotation.Inherited;
>> +
>> +/**
>> + * <p class="changed_added_2_0">When this annotation, along with {_at_link
>> + * ManagedBean} is found on a class, the runtime must act as if a
>> + *
>> <code>&lt;managed-bean-scope&lt;none&lt;managed-bean-scope&gt;</code>
>> + * element was declared for the corresponding managed bean.</p>
>> + *
>> + * @since 2.0
>> + */
>> +_at_Retention(RetentionPolicy.RUNTIME)
>> +_at_Target(ElementType.TYPE)
>> +_at_Inherited
>> +public @interface NoneScoped {
>> +}
>>
>> Index:
>> jsf-ri/src/com/sun/faces/application/annotation/ManagedBeanConfigHandler.java
>>
>> ===================================================================
>> ---
>> jsf-ri/src/com/sun/faces/application/annotation/ManagedBeanConfigHandler.java
>> (revision 5688)
>> +++
>> jsf-ri/src/com/sun/faces/application/annotation/ManagedBeanConfigHandler.java
>> (working copy)
>> @@ -49,9 +49,10 @@
>> import javax.faces.model.ManagedBeans;
>> import javax.faces.model.ManagedProperty;
>> import javax.faces.model.RequestScoped;
>> +import javax.faces.model.ViewScoped;
>> import javax.faces.model.SessionScoped;
>> import javax.faces.model.ApplicationScoped;
>> -import javax.faces.model.UnScoped;
>> +import javax.faces.model.NoneScoped;
>> import javax.faces.context.FacesContext;
>>
>> import com.sun.faces.application.ApplicationAssociate;
>> @@ -68,9 +69,10 @@
>>
>> private static final Class<?>[] SCOPES = {
>> RequestScoped.class,
>> + ViewScoped.class,
>> SessionScoped.class,
>> ApplicationScoped.class,
>> - UnScoped.class
>> + NoneScoped.class
>> };
>>
>> private static final Collection<Class<? extends Annotation>>
>> HANDLES;
>> @@ -208,11 +210,13 @@
>> if (a != null) {
>> if (a instanceof RequestScoped) {
>> return "request";
>> - } else if (a instanceof SessionScoped) {
>> + } else if (a instanceof ViewScoped) {
>> + return "view";
>> + } if (a instanceof SessionScoped) {
>> return "session";
>> } else if (a instanceof ApplicationScoped) {
>> return "application";
>> - } else if (a instanceof UnScoped) {
>> + } else if (a instanceof NoneScoped) {
>> return "none";
>> }
>> }
>>
>> --
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
>> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>>
>
> Jason Lee, SCJP
> Senior Java Developer, Sun Microsystems
> Mojarra and Mojarra Scales Dev Team
> https://mojarra.dev.java.net
> https://scales.dev.java.net
> http://blogs.steeplesoft.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>