myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1004060 - in /myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation: InjectableConversation.java InstanceProducer.java
Date Sun, 03 Oct 2010 22:30:16 GMT
Author: gpetracek
Date: Sun Oct  3 22:30:16 2010
New Revision: 1004060

URL: http://svn.apache.org/viewvc?rev=1004060&view=rev
Log:
minor changes for add-ons

Added:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InjectableConversation.java
Modified:
    myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InstanceProducer.java

Added: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InjectableConversation.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/scope/conversation/InjectableConversation.java?rev=1004060&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InjectableConversation.java
(added)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InjectableConversation.java
Sun Oct  3 22:30:16 2010
@@ -0,0 +1,67 @@
+/*
+ * 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.jsf.impl.scope.conversation;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager;
+import org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils;
+import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContext;
+
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.Bean;
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * @author Gerhard Petracek
+ */
+@Typed()
+public class InjectableConversation implements Conversation
+{
+    private static final long serialVersionUID = 7754789230388003028L;
+
+    protected final Bean<?> bean;
+    protected final EditableWindowContext editableWindowContext;
+
+    protected InjectableConversation(Bean<?> bean, WindowContextManager windowContextManager)
+    {
+        this.bean = bean;
+        this.editableWindowContext = (EditableWindowContext) windowContextManager.getCurrentWindowContext();
+    }
+
+    public void close()
+    {
+        findConversation().close();
+    }
+
+    public void restart()
+    {
+        findConversation().restart();
+    }
+
+    protected Conversation findConversation()
+    {
+        Class conversationGroup = ConversationUtils.getConversationGroup(this.bean);
+
+        Set<Annotation> qualifiers = this.bean.getQualifiers();
+
+        return this.editableWindowContext.getConversation(conversationGroup,
+                                                          qualifiers.toArray(new Annotation[qualifiers.size()]));
+    }
+}

Modified: myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InstanceProducer.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/scope/conversation/InstanceProducer.java?rev=1004060&r1=1004059&r2=1004060&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InstanceProducer.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/scope/conversation/InstanceProducer.java
Sun Oct  3 22:30:16 2010
@@ -28,20 +28,15 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.JsfAwareWindowContextConfig;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.WindowContextManagerFactory;
 import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContextManager;
-import org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.spi.EditableWindowContext;
-import org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils;
 
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.context.Dependent;
 import javax.inject.Named;
-import java.lang.annotation.Annotation;
-import java.util.Set;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -121,34 +116,10 @@ final class InstanceProducer
 
     @Produces
     @Dependent
-    protected Conversation currentConversation(final InjectionPoint injectionPoint,
-                                               final WindowContextManager windowContextManager)
+    protected Conversation currentConversation(InjectionPoint injectionPoint,
+                                               WindowContextManager windowContextManager)
     {
         //for @Inject Conversation conversation;
-        return new Conversation()
-        {
-            private static final long serialVersionUID = 7754789230388003028L;
-
-            public void close()
-            {
-                findConversation().close();
-            }
-
-            public void restart()
-            {
-                findConversation().restart();
-            }
-
-            private Conversation findConversation()
-            {
-                Bean<?> bean = injectionPoint.getBean();
-                Class conversationGroup = ConversationUtils.getConversationGroup(bean);
-
-                Set<Annotation> qualifiers = bean.getQualifiers();
-
-                return ((EditableWindowContext)windowContextManager.getCurrentWindowContext())
-                        .getConversation(conversationGroup, qualifiers.toArray(new Annotation[qualifiers.size()]));
-            }
-        };
+        return new InjectableConversation(injectionPoint.getBean(), windowContextManager);
     }
 }



Mime
View raw message