myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1089354 - in /myfaces/extensions/cdi/trunk: core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ jee-modules/j...
Date Wed, 06 Apr 2011 08:40:46 GMT
Author: gpetracek
Date: Wed Apr  6 08:40:45 2011
New Revision: 1089354

URL: http://svn.apache.org/viewvc?rev=1089354&view=rev
Log:
EXTCDI-100 conversation-required support for view-meta-data and explicit conversation groups

Modified:
    myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationRequired.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ViewConfigDescriptor.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDescriptor.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/JsfUtils.java

Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationRequired.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationRequired.java?rev=1089354&r1=1089353&r2=1089354&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationRequired.java
(original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationRequired.java
Wed Apr  6 08:40:45 2011
@@ -19,6 +19,7 @@
 package org.apache.myfaces.extensions.cdi.core.api.scope.conversation;
 
 import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewConfig;
+import org.apache.myfaces.extensions.cdi.core.api.config.view.ViewMetaData;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
@@ -33,8 +34,12 @@ import static java.lang.annotation.Reten
 @Target({TYPE})
 @Retention(RUNTIME)
 @Documented
+
+@ViewMetaData(override = true)
 public @interface ConversationRequired
 {
+    Class<?> conversationGroup() default ConversationRequired.class;
+
     /**
      * Default entry-point which will be used if a violation had been detected
      * @return entry-point page

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ViewConfigDescriptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ViewConfigDescriptor.java?rev=1089354&r1=1089353&r2=1089354&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ViewConfigDescriptor.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/api/src/main/java/org/apache/myfaces/extensions/cdi/jsf/api/config/view/ViewConfigDescriptor.java
Wed Apr  6 08:40:45 2011
@@ -55,6 +55,14 @@ public interface ViewConfigDescriptor
     List<Annotation> getMetaData();
 
     /**
+     * Custom meta-data which is configured for the entry. It allows to provide and resolve
custom meta-data annotated
+     * with {@link org.apache.myfaces.extensions.cdi.core.api.config.view.ViewMetaData}
+     * @param target target type
+     * @return custom meta-data for the given type of the current entry
+     */
+    <T extends Annotation> List<T> getMetaData(Class<T> target);
+
+    /**
      * {@link AccessDecisionVoter}s which should be invoked to secure the page represented
by the current entry.
      * @return configured access-decision-voters
      */

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDescriptor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDescriptor.java?rev=1089354&r1=1089353&r2=1089354&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDescriptor.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/DefaultViewConfigDescriptor.java
Wed Apr  6 08:40:45 2011
@@ -265,6 +265,23 @@ public class DefaultViewConfigDescriptor
     /**
      * {@inheritDoc}
      */
+    public <T extends Annotation> List<T> getMetaData(Class<T> target)
+    {
+        List<T> result = new ArrayList<T>();
+
+        for(Annotation annotation : this.metaDataList)
+        {
+            if(target.isAssignableFrom(annotation.annotationType()))
+            {
+                result.add((T)annotation);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void addPageBean(Class pageBeanClass)
     {
         List<PageBeanDescriptor> newList = new ArrayList<PageBeanDescriptor>(this.pageBeanDescriptors);

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java?rev=1089354&r1=1089353&r2=1089354&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/config/view/ExtractedViewConfigDefinitionEntry.java
Wed Apr  6 08:40:45 2011
@@ -313,6 +313,15 @@ class ExtractedViewConfigDefinitionEntry
         throw new IllegalStateException(NOT_IMPLEMENTED_MESSAGE);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public <T extends Annotation> List<T> getMetaData(Class<T> target)
+    {
+        throw new IllegalStateException(NOT_IMPLEMENTED_MESSAGE);
+    }
+
+
     private String ensureValidViewIds(String result)
     {
         if(!result.startsWith("/"))

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/JsfUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/JsfUtils.java?rev=1089354&r1=1089353&r2=1089354&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/JsfUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/JsfUtils.java
Wed Apr  6 08:40:45 2011
@@ -45,6 +45,7 @@ import java.lang.annotation.Annotation;
 import java.net.URLEncoder;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
@@ -273,7 +274,7 @@ public abstract class JsfUtils
 
     private static String checkConversationRequired(BeanManager beanManager,
                                                     UIViewRoot uiViewRoot,
-                                                    ViewConfigDescriptor entry)
+                                                    ViewConfigDescriptor viewConfigDescriptor)
     {
         Class<? extends ViewConfig> currentView =
                 ViewConfigCache.getViewConfigDescriptor(uiViewRoot.getViewId()).getViewConfig();
@@ -283,10 +284,13 @@ public abstract class JsfUtils
             return null;
         }
 
-        for(PageBeanDescriptor pageBeanDescriptor : entry.getPageBeanDescriptors())
+        List<PageBeanDescriptor> pageBeanDescriptorList = viewConfigDescriptor.getPageBeanDescriptors();
+        for(PageBeanDescriptor pageBeanDescriptor : pageBeanDescriptorList)
         {
             Class<?> pageBeanClass = pageBeanDescriptor.getBeanClass();
-            ConversationRequired conversationRequired = pageBeanClass.getAnnotation(ConversationRequired.class);
+
+            ConversationRequired conversationRequired =
+                    resolveConversationRequiredAnnotation(viewConfigDescriptor, pageBeanDescriptorList,
pageBeanClass);
 
             if(conversationRequired == null)
             {
@@ -303,6 +307,7 @@ public abstract class JsfUtils
 
                 Bean<?> foundBean;
                 Set<Bean<?>> beanSet;
+                Class<?> conversationGroup;
                 for(Bean<?> currentBean : foundBeans)
                 {
                     beanSet = new HashSet<Bean<?>>(1);
@@ -315,7 +320,16 @@ public abstract class JsfUtils
                         continue;
                     }
 
-                    if(!editableWindowContext.isConversationActive(ConversationUtils.getConversationGroup(foundBean),
+                    if(ConversationRequired.class.equals(conversationRequired.conversationGroup()))
+                    {
+                        conversationGroup = ConversationUtils.getConversationGroup(foundBean);
+                    }
+                    else
+                    {
+                        conversationGroup = conversationRequired.conversationGroup();
+                    }
+
+                    if(!editableWindowContext.isConversationActive(conversationGroup,
                             foundBean.getQualifiers().toArray(new Annotation[foundBean.getQualifiers().size()])))
                     {
                         return ViewConfigCache
@@ -327,6 +341,26 @@ public abstract class JsfUtils
         return null;
     }
 
+    private static ConversationRequired resolveConversationRequiredAnnotation(ViewConfigDescriptor
viewConfigDescriptor,
+            List<PageBeanDescriptor> pageBeanDescriptorList, Class<?> pageBeanClass)
+    {
+        ConversationRequired conversationRequired = pageBeanClass.getAnnotation(ConversationRequired.class);
+
+        //here we support just simple constellations
+        //TODO handle unsupported constellations
+        if(conversationRequired == null && pageBeanDescriptorList.size() == 1)
+        {
+            List<ConversationRequired> conversationRequiredMetaData =
+                    viewConfigDescriptor.getMetaData(ConversationRequired.class);
+
+            if(conversationRequiredMetaData.size() == 1)
+            {
+                conversationRequired = conversationRequiredMetaData.iterator().next();
+            }
+        }
+        return conversationRequired;
+    }
+
     private static boolean isEntryPoint(Class<? extends ViewConfig> currentView,
                                         Class<? extends ViewConfig> defaultEntryPoint,
                                         Class<? extends ViewConfig>[] entryPoints)



Mime
View raw message