[seam-commits] Seam SVN: r12619 - in modules/faces/trunk: api and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Apr 23 15:29:49 EDT 2010


Author: lincolnthree
Date: 2010-04-23 15:29:49 -0400 (Fri, 23 Apr 2010)
New Revision: 12619

Modified:
   modules/faces/trunk/api/
   modules/faces/trunk/impl/
   modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/environment/SeamApplicationWrapper.java
   modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/util/BeanManagerUtils.java
   modules/faces/trunk/pom.xml
Log:
* Updated ApplicationWrapper to properly scope Converters/Validators


Property changes on: modules/faces/trunk/api
___________________________________________________________________
Name: svn:ignore
   - .settings
build
target
.classpath
.project

   + .settings
build
target
.classpath
.project
bin



Property changes on: modules/faces/trunk/impl
___________________________________________________________________
Name: svn:ignore
   - .settings
target
.classpath
.project

   + .settings
target
.classpath
.project
bin


Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/environment/SeamApplicationWrapper.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/environment/SeamApplicationWrapper.java	2010-04-23 19:27:28 UTC (rev 12618)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/environment/SeamApplicationWrapper.java	2010-04-23 19:29:49 UTC (rev 12619)
@@ -50,6 +50,12 @@
    @Inject
    BeanManagerUtils managerUtils;
 
+   @Override
+   public Application getWrapped()
+   {
+      return parent;
+   }
+
    public void installWrapper(@Observes final PostConstructApplicationEvent event)
    {
       ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
@@ -61,10 +67,7 @@
    public Converter createConverter(final Class<?> targetClass)
    {
       Converter result = parent.createConverter(targetClass);
-      if (result != null)
-      {
-         result = managerUtils.getContextualInstance(result.getClass());
-      }
+      result = attemptExtension(result);
       return result;
    }
 
@@ -72,10 +75,7 @@
    public Converter createConverter(final String converterId)
    {
       Converter result = parent.createConverter(converterId);
-      if (result != null)
-      {
-         result = managerUtils.getContextualInstance(result.getClass());
-      }
+      result = attemptExtension(result);
       return result;
    }
 
@@ -83,16 +83,24 @@
    public Validator createValidator(final String validatorId)
    {
       Validator result = parent.createValidator(validatorId);
+      result = attemptExtension(result);
+      return result;
+   }
+
+   @SuppressWarnings("unchecked")
+   private <T> T attemptExtension(T result)
+   {
       if (result != null)
       {
-         result = managerUtils.getContextualInstance(result.getClass());
+         if (managerUtils.isDependentScoped(result.getClass()))
+         {
+            managerUtils.injectNonContextualInstance(result);
+         }
+         else
+         {
+            result = (T) managerUtils.getContextualInstance(result.getClass());
+         }
       }
       return result;
    }
-
-   @Override
-   public Application getWrapped()
-   {
-      return parent;
-   }
 }

Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/util/BeanManagerUtils.java
===================================================================
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/util/BeanManagerUtils.java	2010-04-23 19:27:28 UTC (rev 12618)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/util/BeanManagerUtils.java	2010-04-23 19:29:49 UTC (rev 12619)
@@ -25,6 +25,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -55,6 +56,17 @@
       injectionTarget.inject(instance, creationalContext);
    }
 
+   @SuppressWarnings("unchecked")
+   public <T> boolean isDependentScoped(final Class<T> type)
+   {
+      Bean<T> bean = (Bean<T>) manager.resolve(manager.getBeans(type));
+      if (bean != null)
+      {
+         return Dependent.class.equals(bean.getScope());
+      }
+      return false;
+   }
+
    /**
     * Get a single CDI managed instance of a specific class. Return only the
     * first result if multiple beans are available.

Modified: modules/faces/trunk/pom.xml
===================================================================
--- modules/faces/trunk/pom.xml	2010-04-23 19:27:28 UTC (rev 12618)
+++ modules/faces/trunk/pom.xml	2010-04-23 19:29:49 UTC (rev 12619)
@@ -6,7 +6,6 @@
 		<artifactId>weld-parent</artifactId>
 		<version>9</version>
 	</parent>
-   -->
 
 	<artifactId>seam-faces-parent</artifactId>
 	<groupId>org.jboss.seam.faces</groupId>



More information about the seam-commits mailing list