myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r963487 - in /myfaces/extensions/cdi/trunk: core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ ex...
Date Mon, 12 Jul 2010 21:12:15 GMT
Author: gpetracek
Date: Mon Jul 12 21:12:15 2010
New Revision: 963487

URL: http://svn.apache.org/viewvc?rev=963487&view=rev
Log:
EXTCDI-1, EXTCDI-2 and EXTCDI-3 minor improvements

Modified:
    myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean1.java
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/listener/phase/ConfigDemoBean.java
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultCodiWebConfig.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ConversationUtils.java

Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.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/WindowContext.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
(original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/WindowContext.java
Mon Jul 12 21:12:15 2010
@@ -22,6 +22,7 @@ import org.apache.myfaces.extensions.cdi
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.util.Set;
 
 /**
  * @author Gerhard Petracek
@@ -66,6 +67,13 @@ public interface WindowContext extends A
     Conversation endConversation(Class conversationGroup, Annotation... qualifiers);
 
     /**
+     * destroys all conversation of a group independent of the qualifiers
+     * @param conversationGroup group of the conversation in question
+     * @return the removed conversation - null otherwise
+     */
+    Set<Conversation> endConversations(Class conversationGroup);
+
+    /**
      * @return configuration of the current context
      */
     WindowContextConfig getConfig();

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean1.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean1.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean1.java
(original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/conversation/grouped/ConversationDemoBean1.java
Mon Jul 12 21:12:15 2010
@@ -20,8 +20,10 @@ package org.apache.myfaces.blank.convers
 
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationGroup;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
 
 import javax.inject.Named;
+import javax.inject.Inject;
 import javax.annotation.PostConstruct;
 import java.io.Serializable;
 import java.util.Date;
@@ -38,12 +40,20 @@ public class ConversationDemoBean1 imple
     private Date createdAt;
     private static final long serialVersionUID = -4238520498463300564L;
 
+    @Inject
+    private WindowContext windowContext;
+
     @PostConstruct
     public void init()
     {
         this.createdAt = new Date();
     }
 
+    public void endGroup1()
+    {
+        this.windowContext.endConversations(ConversationGroup1.class);
+    }
+
     public String getValue()
     {
         return value + createdAt.toLocaleString();

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/listener/phase/ConfigDemoBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/listener/phase/ConfigDemoBean.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/listener/phase/ConfigDemoBean.java
(original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/listener/phase/ConfigDemoBean.java
Mon Jul 12 21:12:15 2010
@@ -33,6 +33,8 @@ import java.util.Set;
 @Typed(ConfigDemoBean.class)
 public class ConfigDemoBean extends CodiWebConfig12
 {
+    private static final long serialVersionUID = -6915243682321970384L;
+
     @Inject
     private Set<CodiConfig> codiConfig;
 

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
(original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
Mon Jul 12 21:12:15 2010
@@ -48,7 +48,10 @@
             </h:form>
 
             <h:form id="conversationForm">
-                <h:commandLink value="next" action="next"/>
+                <h:panelGrid>
+                    <h:commandLink value="next" action="next"/>
+                    <h:commandLink value="end conversation group 1" action="#{conversationDemoBean1.endGroup1}"/>
+                </h:panelGrid>
             </h:form>
             
             <h:panelGrid>

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultCodiWebConfig.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultCodiWebConfig.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultCodiWebConfig.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/config/DefaultCodiWebConfig.java
Mon Jul 12 21:12:15 2010
@@ -35,6 +35,8 @@ import javax.faces.context.FacesContext;
 @Singleton
 public class DefaultCodiWebConfig extends CodiWebConfig12
 {
+    private static final long serialVersionUID = 2195635039365964148L;
+
     private Boolean configInitialized;
 
     @Produces

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/DefaultConversationKey.java
Mon Jul 12 21:12:15 2010
@@ -25,6 +25,8 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationGroup;
 
 import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Any;
+import javax.inject.Named;
 import java.lang.annotation.Annotation;
 import java.util.Set;
 import java.util.HashSet;
@@ -52,6 +54,7 @@ class DefaultConversationKey implements 
     //old version
     //workaround
     //private static final ViewAccessScoped VIEW_ACCESS_SCOPED = DefaultAnnotation.of(ViewAccessScoped.class);
+    private static final Default DEFAULT_QUALIFIER = DefaultAnnotation.of(Default.class);
 
     //workaround
     private boolean viewAccessScopedAnnotationPresent;
@@ -81,7 +84,24 @@ class DefaultConversationKey implements 
                 //TODO test with injection into other beans
                 qualifierIterator.remove();
             }
-
+            else if(Any.class.isAssignableFrom(qualifier.annotationType()))
+            {
+                //TODO test with injection into other beans
+                qualifierIterator.remove();
+            }
+            else if(Default.class.isAssignableFrom(qualifier.annotationType()))
+            {
+                //TODO test with injection into other beans
+                qualifierIterator.remove();
+            }
+            else if(Named.class.isAssignableFrom(qualifier.annotationType()))
+            {
+                if("".equals(((Named)qualifier).value()))
+                {
+                    //TODO test with injection into other beans
+                    qualifierIterator.remove();
+                }
+            }
         }
 
         /*
@@ -97,7 +117,7 @@ class DefaultConversationKey implements 
         //for easier manual usage of the WindowContextManager
         if(this.qualifiers.isEmpty())
         {
-            this.qualifiers.add(DefaultAnnotation.of(Default.class));
+            this.qualifiers.add(DEFAULT_QUALIFIER);
         }
 
         validate();

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java
Mon Jul 12 21:12:15 2010
@@ -42,6 +42,8 @@ import java.util.Set;
  */
 public class GroupedConversationContextAdapter extends AbstractConversationContextAdapter
 {
+    private static final ViewAccessScoped VIEW_ACCESS_SCOPED = DefaultAnnotation.of(ViewAccessScoped.class);
+
     public GroupedConversationContextAdapter(BeanManager beanManager)
     {
         super(beanManager);
@@ -111,7 +113,7 @@ public class GroupedConversationContextA
         if(ViewAccessScoped.class.isAssignableFrom(conversationGroup))
         {
             //TODO maybe we have to add a real qualifier instead
-            qualifiers.add(DefaultAnnotation.of(ViewAccessScoped.class));
+            qualifiers.add(VIEW_ACCESS_SCOPED);
             conversationGroup = bean.getBeanClass();
         }
         return conversationGroup;

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/JsfWindowContext.java
Mon Jul 12 21:12:15 2010
@@ -28,6 +28,8 @@ import org.apache.myfaces.extensions.cdi
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.lang.annotation.Annotation;
 
@@ -95,6 +97,20 @@ public class JsfWindowContext implements
         return endAndRemoveConversation(conversationKey, conversation);
     }
 
+    public Set<Conversation> endConversations(Class conversationGroupKey)
+    {
+        Set<Conversation> removedConversations = new HashSet<Conversation>();
+        for(Map.Entry<ConversationKey, Conversation> conversationEntry : this.groupedConversations.entrySet())
+        {
+            if(conversationGroupKey.isAssignableFrom(conversationEntry.getKey().getConversationGroup()))
+            {
+                removedConversations.add(
+                        endAndRemoveConversation(conversationEntry.getKey(), conversationEntry.getValue()));
+            }
+        }
+        return removedConversations;
+    }
+
     private Conversation endAndRemoveConversation(ConversationKey conversationKey, Conversation
conversation)
     {
         //TODO

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ConversationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ConversationUtils.java?rev=963487&r1=963486&r2=963487&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ConversationUtils.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/util/ConversationUtils.java
Mon Jul 12 21:12:15 2010
@@ -37,6 +37,8 @@ import java.util.Set;
  */
 public class ConversationUtils
 {
+    private static final Jsf JSF_QUALIFIER = DefaultAnnotation.of(Jsf.class);
+
     /**
      * @return the descriptor of a custom
      * {@link org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager}
@@ -47,8 +49,7 @@ public class ConversationUtils
     {
         BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
 
-        Set<?> conversationManagerBeans = beanManager.getBeans(
-                WindowContextManager.class, DefaultAnnotation.of(Jsf.class));
+        Set<?> conversationManagerBeans = beanManager.getBeans(WindowContextManager.class,
JSF_QUALIFIER);
 
         if (conversationManagerBeans.isEmpty())
         {



Mime
View raw message