You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2010/07/12 23:43:24 UTC
svn commit: r963502 - 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...
Author: gpetracek
Date: Mon Jul 12 21:43:24 2010
New Revision: 963502
URL: http://svn.apache.org/viewvc?rev=963502&view=rev
Log:
EXTCDI-1, EXTCDI-2 and EXTCDI-3 ConversationAware
Added:
myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationAware.java
Modified:
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/webapp/helloMyFacesCodi.jsp
myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/GroupedConversationContextAdapter.java
Added: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationAware.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/ConversationAware.java?rev=963502&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationAware.java (added)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationAware.java Mon Jul 12 21:43:24 2010
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.cdi.core.api.scope.conversation;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface ConversationAware
+{
+ /**
+ * @param conversation the {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation}
+ * which holds the bean
+ */
+ void setConversation(Conversation conversation);
+}
\ No newline at end of file
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=963502&r1=963501&r2=963502&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:43:24 2010
@@ -21,6 +21,8 @@ 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 org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationAware;
import javax.inject.Named;
import javax.inject.Inject;
@@ -34,7 +36,7 @@ import java.util.Date;
@Named
@ConversationScoped
@ConversationGroup(ConversationGroup1.class)
-public class ConversationDemoBean1 implements Serializable
+public class ConversationDemoBean1 implements Serializable, ConversationAware
{
private String value = "Hello grouped conversation1! ";
private Date createdAt;
@@ -43,6 +45,8 @@ public class ConversationDemoBean1 imple
@Inject
private WindowContext windowContext;
+ private Conversation conversation;
+
@PostConstruct
public void init()
{
@@ -54,8 +58,19 @@ public class ConversationDemoBean1 imple
this.windowContext.endConversationGroup(ConversationGroup1.class);
}
+ public void endConversation()
+ {
+ //this.conversation.end();
+ this.conversation.restart();
+ }
+
public String getValue()
{
return value + createdAt.toLocaleString();
}
+
+ public void setConversation(Conversation conversation)
+ {
+ this.conversation = conversation;
+ }
}
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=963502&r1=963501&r2=963502&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:43:24 2010
@@ -51,6 +51,7 @@
<h:panelGrid>
<h:commandLink value="next" action="next"/>
<h:commandLink value="end conversation group 1" action="#{conversationDemoBean1.endGroup1}"/>
+ <h:commandLink value="end conversation of bean" action="#{conversationDemoBean1.endConversation}"/>
</h:panelGrid>
</h:form>
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=963502&r1=963501&r2=963502&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:43:24 2010
@@ -19,6 +19,7 @@
package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationAware;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationGroup;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowScoped;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ViewAccessScoped;
@@ -84,7 +85,13 @@ public class GroupedConversationContextA
Conversation foundConversation = getConversation(conversationManager, beanDescriptor);
//noinspection unchecked
- return (T) foundConversation.getBean(beanClass);
+ T conversationScopedBean = (T)foundConversation.getBean(beanClass);
+
+ if(conversationScopedBean instanceof ConversationAware)
+ {
+ ((ConversationAware)conversationScopedBean).setConversation(foundConversation);
+ }
+ return conversationScopedBean;
}
protected <T> void scopeBeanEntry(WindowContextManager conversationManager, BeanEntry<T> beanEntry)