myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r931219 - in /myfaces/extensions/cdi/branches/sandbox_conversations: core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/ core/impl/...
Date Tue, 06 Apr 2010 16:41:50 GMT
Author: gpetracek
Date: Tue Apr  6 16:41:49 2010
New Revision: 931219

URL: http://svn.apache.org/viewvc?rev=931219&view=rev
Log:
minor change

Added:
    myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/
    myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/
    myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/named/
    myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/named/AbstractNamedConversationContextAdapter.java
Modified:
    myfaces/extensions/cdi/branches/sandbox_conversations/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationContext.java
    myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/pom.xml
    myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/named/NamedConversationContextAdapter.java

Modified: myfaces/extensions/cdi/branches/sandbox_conversations/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationContext.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/sandbox_conversations/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationContext.java?rev=931219&r1=931218&r2=931219&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/sandbox_conversations/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationContext.java
(original)
+++ myfaces/extensions/cdi/branches/sandbox_conversations/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/scope/conversation/ConversationContext.java
Tue Apr  6 16:41:49 2010
@@ -18,10 +18,12 @@
  */
 package org.apache.myfaces.extensions.cdi.core.api.scope.conversation;
 
+import java.io.Serializable;
+
 /**
  * @author Gerhard Petracek
  */
-public interface ConversationContext
+public interface ConversationContext extends Serializable
 {
     /**
      * @return the id of the conversation (unique for each window/tab)

Added: myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/named/AbstractNamedConversationContextAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/named/AbstractNamedConversationContextAdapter.java?rev=931219&view=auto
==============================================================================
--- myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/named/AbstractNamedConversationContextAdapter.java
(added)
+++ myfaces/extensions/cdi/branches/sandbox_conversations/core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/scope/conversation/named/AbstractNamedConversationContextAdapter.java
Tue Apr  6 16:41:49 2010
@@ -0,0 +1,133 @@
+/*
+ * 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.impl.scope.conversation.named;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.named.ConversationScoped;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationManager;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.context.spi.Context;
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * @author Gerhard Petracek
+ */
+public abstract class AbstractNamedConversationContextAdapter implements Context
+{
+    protected BeanManager beanManager;
+
+    public AbstractNamedConversationContextAdapter(BeanManager beanManager)
+    {
+        this.beanManager = beanManager;
+    }
+
+    /**
+     * @return annotation of the codi conversation scope
+     */
+    public Class<? extends Annotation> getScope()
+    {
+        return ConversationScoped.class;
+    }
+
+    /**
+     * @param component descriptor of the bean
+     * @param creationalContext context for creating a bean
+     * @return a scoped bean-instance
+     */
+    public <T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
+    {
+        if (component instanceof Bean)
+        {
+            ConversationManager conversationManager = resolveConversationManager();
+
+            T beanInstance = component.create(creationalContext);
+            scopeBeanInstance((Bean<T>)component, beanInstance, conversationManager);
+            return beanInstance;
+        }
+
+        Class invalidComponentClass = component.create(creationalContext).getClass();
+        throw new IllegalStateException(invalidComponentClass + " is no valid conversation
scoped bean");
+    }
+
+    /**
+     * @param component descriptor of the bean
+     * @return an instance of the requested bean if it already exists in the current
+     * {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
+     * null otherwise
+     */
+    public <T> T get(Contextual<T> component)
+    {
+        if (component instanceof Bean)
+        {
+            Bean<T> foundBean = ((Bean<T>) component);
+            ConversationManager conversationManager = resolveConversationManager();
+
+            return resolveBeanInstance(foundBean, conversationManager);
+        }
+        return null;
+    }
+
+    /**
+     * @return an instance of a custom (the default) {@link ConversationManager}
+     */
+    private ConversationManager resolveConversationManager()
+    {
+        Bean<ConversationManager> conversationManagerBean = resolveConversationManagerBean();
+        CreationalContext<ConversationManager> conversationManagerCreationalContext
= this.beanManager.createCreationalContext(conversationManagerBean);
+        return conversationManagerBean.create(conversationManagerCreationalContext);
+    }
+
+    protected abstract Bean<ConversationManager> resolveConversationManagerBean();
+
+    /**
+     * @return the descriptor of the default {@link ConversationManager}
+     */
+    protected Set<Bean<?>> getDefaultConversationManager()
+    {
+        return this.beanManager.getBeans(ConversationManager.class);
+    }
+
+    /**
+     * @param beanDescriptor descriptor of the requested bean
+     * @param conversationManager the current {@link ConversationManager}
+     * @return the instance of the requested bean if it exists in the current {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
+     * null otherwise
+     */
+    private <T> T resolveBeanInstance(Bean<T> beanDescriptor, ConversationManager
conversationManager)
+    {
+        //TODO
+        return null;
+    }
+
+    /**
+     * Store the given bean in the {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
+     *
+     * @param beanDescriptor descriptor of the current bean
+     * @param beanInstance bean to save in the current conversation
+     * @param conversationManager current {@link ConversationManager}
+     */
+    private <T> void scopeBeanInstance(Bean<T> beanDescriptor, T beanInstance,
ConversationManager conversationManager)
+    {
+        //TODO
+    }
+}

Modified: myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/pom.xml?rev=931219&r1=931218&r2=931219&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/pom.xml
(original)
+++ myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/pom.xml
Tue Apr  6 16:41:49 2010
@@ -42,6 +42,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.myfaces.extensions.cdi.core</groupId>
+            <artifactId>myfaces-extcdi-core-impl</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.myfaces.extensions.cdi.jee-modules</groupId>
             <artifactId>myfaces-extcdi-jsf12-module-api</artifactId>
             <version>1.0.0-SNAPSHOT</version>

Modified: myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/named/NamedConversationContextAdapter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/named/NamedConversationContextAdapter.java?rev=931219&r1=931218&r2=931219&view=diff
==============================================================================
--- myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/named/NamedConversationContextAdapter.java
(original)
+++ myfaces/extensions/cdi/branches/sandbox_conversations/jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/jsf/impl/scope/conversation/named/NamedConversationContextAdapter.java
Tue Apr  6 16:41:49 2010
@@ -18,80 +18,28 @@
  */
 package org.apache.myfaces.extensions.cdi.javaee.jsf.impl.scope.conversation.named;
 
-import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.named.ConversationScoped;
 import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationManager;
 import org.apache.myfaces.extensions.cdi.core.api.tools.annotate.DefaultAnnotation;
+import org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.named.AbstractNamedConversationContextAdapter;
 import org.apache.myfaces.extensions.cdi.javaee.jsf.api.qualifier.Jsf;
 
-import javax.enterprise.context.spi.Context;
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.faces.context.FacesContext;
-import java.lang.annotation.Annotation;
 import java.util.Set;
 
 /**
  * @author Gerhard Petracek
  */
-public class NamedConversationContextAdapter implements Context
+public class NamedConversationContextAdapter extends AbstractNamedConversationContextAdapter
 {
-    private BeanManager beanManager;
-
     public NamedConversationContextAdapter(BeanManager beanManager)
     {
-        this.beanManager = beanManager;
-    }
-
-    /**
-     * @return annotation of the codi conversation scope
-     */
-    public Class<? extends Annotation> getScope()
-    {
-        return ConversationScoped.class;
-    }
-
-    /**
-     * @param component descriptor of the bean
-     * @param creationalContext context for creating a bean
-     * @return a scoped bean-instance
-     */
-    public <T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
-    {
-        if (component instanceof Bean)
-        {
-            ConversationManager conversationManager = resolveConversationManager();
-
-            T beanInstance = component.create(creationalContext);
-            scopeBeanInstance((Bean<T>)component, beanInstance, conversationManager);
-            return beanInstance;
-        }
-
-        Class invalidComponentClass = component.create(creationalContext).getClass();
-        throw new IllegalStateException(invalidComponentClass + " is no valid conversation
scoped bean");
+        super(beanManager);
     }
 
     /**
-     * @param component descriptor of the bean
-     * @return an instance of the requested bean if it already exists in the current
-     * {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
-     * null otherwise
-     */
-    public <T> T get(Contextual<T> component)
-    {
-        if (component instanceof Bean)
-        {
-            Bean<T> foundBean = ((Bean<T>) component);
-            ConversationManager conversationManager = resolveConversationManager();
-
-            return resolveBeanInstance(foundBean, conversationManager);
-        }
-        return null;
-    }
-
-    /**
-     * @return true as soon as JSF is active (the {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
+     * @return true as soon as JSF is active the {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
      * will be created automatically
      */
     public boolean isActive()
@@ -100,20 +48,10 @@ public class NamedConversationContextAda
     }
 
     /**
-     * @return an instance of a custom (the default) {@link ConversationManager}
-     */
-    private ConversationManager resolveConversationManager()
-    {
-        Bean<ConversationManager> conversationManagerBean = resolveConversationManagerBean();
-        CreationalContext<ConversationManager> conversationManagerCreationalContext
= this.beanManager.createCreationalContext(conversationManagerBean);
-        return conversationManagerBean.create(conversationManagerCreationalContext);
-    }
-
-    /**
      * @return the descriptor of a custom {@link ConversationManager} with the qualifier
{@link Jsf} or
      * the descriptor of the default implementation provided by this module
      */
-    private Bean<ConversationManager> resolveConversationManagerBean()
+    protected Bean<ConversationManager> resolveConversationManagerBean()
     {
         Set<?> conversationManagerBeans = this.beanManager.getBeans(ConversationManager.class,
DefaultAnnotation.of(Jsf.class));
 
@@ -129,36 +67,4 @@ public class NamedConversationContextAda
         //noinspection unchecked
         return (Bean<ConversationManager>)conversationManagerBeans.iterator().next();
     }
-
-    /**
-     * @return the descriptor of the default {@link ConversationManager}
-     */
-    private Set<Bean<?>> getDefaultConversationManager()
-    {
-        return this.beanManager.getBeans(ConversationManager.class);
-    }
-
-    /**
-     * @param beanDescriptor descriptor of the requested bean
-     * @param conversationManager the current {@link ConversationManager}
-     * @return the instance of the requested bean if it exists in the current {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
-     * null otherwise
-     */
-    private <T> T resolveBeanInstance(Bean<T> beanDescriptor, ConversationManager
conversationManager)
-    {
-        //TODO
-        return null;
-    }
-
-    /**
-     * Store the given bean in the {@link org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationContext}
-     *
-     * @param beanDescriptor descriptor of the current bean
-     * @param beanInstance bean to save in the current conversation
-     * @param conversationManager current {@link ConversationManager}
-     */
-    private <T> void scopeBeanInstance(Bean<T> beanDescriptor, T beanInstance,
ConversationManager conversationManager)
-    {
-        //TODO
-    }
-}
+}
\ No newline at end of file



Mime
View raw message