myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject svn commit: r1807864 - in /myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi: bean/ converter/ validator/
Date Sat, 09 Sep 2017 09:05:19 GMT
Author: tandraschko
Date: Sat Sep  9 09:05:18 2017
New Revision: 1807864

URL: http://svn.apache.org/viewvc?rev=1807864&view=rev
Log:
MYFACES-4127 refactored other producers to reuse AbstractDynamicProducer

Added:
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyProducer.java
      - copied, changed from r1807840, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducer.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterInfo.java
      - copied, changed from r1807840, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/ConverterInfo.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterProducer.java
      - copied, changed from r1807859, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/DynamicConverterProducer.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorInfo.java
      - copied, changed from r1807840, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/ValidatorInfo.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorProducer.java
      - copied, changed from r1807859, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/DynamicValidatorProducer.java
Removed:
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducer.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/ConverterInfo.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/DynamicConverterProducer.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/DynamicValidatorProducer.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/ValidatorInfo.java
Modified:
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyExtension.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterExtension.java
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorExtension.java

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyExtension.java?rev=1807864&r1=1807863&r2=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyExtension.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyExtension.java
Sat Sep  9 09:05:18 2017
@@ -59,7 +59,7 @@ public class ManagedPropertyExtension im
     {
         for (ManagedPropertyInfo typeInfo : types)
         {
-            afterBeanDiscovery.addBean(new DynamicManagedPropertyProducer(beanManager, typeInfo));
+            afterBeanDiscovery.addBean(new ManagedPropertyProducer(beanManager, typeInfo));
         }
     }
 }

Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyProducer.java
(from r1807840, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducer.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyProducer.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyProducer.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducer.java&r1=1807840&r2=1807864&rev=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/DynamicManagedPropertyProducer.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/bean/ManagedPropertyProducer.java
Sat Sep  9 09:05:18 2017
@@ -19,70 +19,28 @@
 
 package org.apache.myfaces.cdi.bean;
 
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import static java.util.Arrays.asList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.PassivationCapable;
 import javax.enterprise.util.AnnotationLiteral;
 import javax.faces.annotation.ManagedProperty;
 import javax.faces.context.FacesContext;
+import org.apache.myfaces.cdi.util.AbstractDynamicProducer;
 import org.apache.myfaces.shared.util.ClassUtils;
 
 /**
  *
  */
-public class DynamicManagedPropertyProducer implements Bean<Object>, Serializable,
PassivationCapable
+public class ManagedPropertyProducer extends AbstractDynamicProducer<Object>
 {
-    private static final long serialVersionUID = 1L;
-    
-
-    private BeanManager beanManager;
-    private ManagedPropertyInfo typeInfo;
-    private Set<Type> types;
-    private Class<?> beanClass;
-
-    public DynamicManagedPropertyProducer(BeanManager beanManager, ManagedPropertyInfo typeInfo)
-    {
-        this.beanManager = beanManager;
-        this.typeInfo = typeInfo;
-        types = new HashSet<Type>(asList(typeInfo.getType(), Object.class));
-        Type beanType = typeInfo.getType();
-        // Need to check for ParameterizedType to support types such as List<String>
-        if ( beanType instanceof ParameterizedType ) 
-        {
-            beanClass = ClassUtils.simpleClassForName(((ParameterizedType) beanType).getRawType().getTypeName());
-        }
-        else 
-        {
-        // need to use simpleJavaTypeToClass to support Arrays and primitive types
-            beanClass = ClassUtils.simpleJavaTypeToClass(beanType.getTypeName());
-        }
-
-    }
-    
-    @Override
-    public String getId()
-    {
-        return typeInfo.getType()+"_"+typeInfo.getExpression();
-    }
-
-    public static class DefaultAnnotationLiteral extends AnnotationLiteral<ManagedProperty>
implements ManagedProperty
+    class ManagedPropertyAnnotationLiteral extends AnnotationLiteral<ManagedProperty>
implements ManagedProperty
     {
         private static final long serialVersionUID = 1L;
         
         private String value;
 
-        public DefaultAnnotationLiteral(String value)
+        public ManagedPropertyAnnotationLiteral(String value)
         {
             this.value = value;
         }
@@ -94,74 +52,35 @@ public class DynamicManagedPropertyProdu
         }
     }
     
-    @Override
-    public Class<?> getBeanClass()
-    {
-        return beanClass;
-    }
-
-    @Override
-    public Set<Type> getTypes()
-    {
-        return types;
-    }
-    
-    @Override
-    public Set<Annotation> getQualifiers()
-    {
-        return Collections.singleton(
-                (Annotation) new DynamicManagedPropertyProducer.DefaultAnnotationLiteral(typeInfo.getExpression()));
-    }
-    
-
-    @Override
-    public Class<? extends Annotation> getScope()
-    {
-        return Dependent.class;
-    }
-
-    @Override
-    public String getName()
-    {
-        return null;
-    }
-    
-
-    @Override
-    public Set<Class<? extends Annotation>> getStereotypes()
+    public ManagedPropertyProducer(BeanManager beanManager, ManagedPropertyInfo typeInfo)
     {
-        return Collections.emptySet();
-    }
+        super(beanManager);
+        
+        Class<?> beanClass;
+        // Need to check for ParameterizedType to support types such as List<String>
+        if (typeInfo.getType() instanceof ParameterizedType) 
+        {
+            beanClass = ClassUtils.simpleClassForName(
+                    ((ParameterizedType) typeInfo.getType()).getRawType().getTypeName());
+        }
+        else 
+        {
+            // need to use simpleJavaTypeToClass to support Arrays and primitive types
+            beanClass = ClassUtils.simpleJavaTypeToClass(typeInfo.getType().getTypeName());
+        }
 
-    @Override
-    public boolean isAlternative()
-    {
-        return false;
-    }
-    
-    @Override
-    public Set<InjectionPoint> getInjectionPoints()
-    {
-        return Collections.emptySet();
+        super.id(typeInfo.getType() + "_" + typeInfo.getExpression())
+                .scope(Dependent.class)
+                .qualifiers(new ManagedPropertyAnnotationLiteral(typeInfo.getExpression()))
+                .types(typeInfo.getType(), Object.class)
+                .beanClass(beanClass)
+                .create(e -> createManagedProperty(e, typeInfo));
     }
 
-    @Override
-    public boolean isNullable()
-    {
-        return true;
-    }
-    
-    @Override
-    public Object create(CreationalContext<Object> cc)
+    protected Object createManagedProperty(CreationalContext<Object> cc, ManagedPropertyInfo
typeInfo)
     {
         FacesContext facesContext = FacesContext.getCurrentInstance();
         return facesContext.getApplication().evaluateExpressionGet(
-                facesContext, typeInfo.getExpression(), beanClass);
-    }
-
-    @Override
-    public void destroy(Object t, CreationalContext<Object> cc)
-    {
+                facesContext, typeInfo.getExpression(), getBeanClass());
     }
-    
 }

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterExtension.java?rev=1807864&r1=1807863&r2=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterExtension.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterExtension.java
Sat Sep  9 09:05:18 2017
@@ -35,7 +35,7 @@ import javax.faces.convert.FacesConverte
  */
 public class FacesConverterExtension implements Extension
 {
-    private Set<ConverterInfo> types = new HashSet<ConverterInfo>();
+    private Set<FacesConverterInfo> types = new HashSet<FacesConverterInfo>();
 
     public <T> void collect(@Observes ProcessManagedBean<T> event)
     {
@@ -55,11 +55,11 @@ public class FacesConverterExtension imp
                 {
                     if (hasForClass)
                     {
-                        types.add(new ConverterInfo(type, conv.forClass(), ""));
+                        types.add(new FacesConverterInfo(type, conv.forClass(), ""));
                     }
                     if (hasValue)
                     {
-                        types.add(new ConverterInfo(type, Object.class, conv.value()));
+                        types.add(new FacesConverterInfo(type, Object.class, conv.value()));
                     }
                 }
             }
@@ -68,9 +68,9 @@ public class FacesConverterExtension imp
     
     public void afterBean(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
     {
-        for (ConverterInfo typeInfo : types)
+        for (FacesConverterInfo typeInfo : types)
         {
-            afterBeanDiscovery.addBean(new DynamicConverterProducer(beanManager, typeInfo));
+            afterBeanDiscovery.addBean(new FacesConverterProducer(beanManager, typeInfo));
         }
     }
 

Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterInfo.java
(from r1807840, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/ConverterInfo.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterInfo.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterInfo.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/ConverterInfo.java&r1=1807840&r2=1807864&rev=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/ConverterInfo.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterInfo.java
Sat Sep  9 09:05:18 2017
@@ -26,7 +26,7 @@ import java.util.Objects;
 /**
  *
  */
-public class ConverterInfo implements Serializable
+public class FacesConverterInfo implements Serializable
 {
     private Type type;
     
@@ -34,7 +34,7 @@ public class ConverterInfo implements Se
     
     private String converterId;
 
-    public ConverterInfo(Type type, Class forClass, String converterId)
+    public FacesConverterInfo(Type type, Class forClass, String converterId)
     {
         this.type = type;
         this.forClass = forClass;
@@ -98,7 +98,7 @@ public class ConverterInfo implements Se
         {
             return false;
         }
-        final ConverterInfo other = (ConverterInfo) obj;
+        final FacesConverterInfo other = (FacesConverterInfo) obj;
         if (!Objects.equals(this.type, other.type))
         {
             return false;

Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterProducer.java
(from r1807859, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/DynamicConverterProducer.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterProducer.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterProducer.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/DynamicConverterProducer.java&r1=1807859&r2=1807864&rev=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/DynamicConverterProducer.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/converter/FacesConverterProducer.java
Sat Sep  9 09:05:18 2017
@@ -34,9 +34,9 @@ import org.apache.myfaces.shared.util.Cl
  *
  */
 @Typed
-public class DynamicConverterProducer extends AbstractDynamicProducer<Converter>
+public class FacesConverterProducer extends AbstractDynamicProducer<Converter>
 {
-    public DynamicConverterProducer(BeanManager beanManager, ConverterInfo typeInfo)
+    public FacesConverterProducer(BeanManager beanManager, FacesConverterInfo typeInfo)
     {
         super(beanManager);
         
@@ -67,7 +67,7 @@ public class DynamicConverterProducer ex
         }
         catch (Exception ex)
         {
-            Logger.getLogger(DynamicConverterProducer.class.getName()).log(
+            Logger.getLogger(FacesConverterProducer.class.getName()).log(
                     Level.SEVERE, "Could not instantiate converter " + converterClass.getName(),
ex);
             throw new FacesException("Could not instantiate converter: " + converterClass.getName(),
ex);
             

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorExtension.java?rev=1807864&r1=1807863&r2=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorExtension.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorExtension.java
Sat Sep  9 09:05:18 2017
@@ -35,7 +35,7 @@ import javax.faces.validator.FacesValida
  */
 public class FacesValidatorExtension implements Extension
 {
-    private Set<ValidatorInfo> types = new HashSet<ValidatorInfo>();
+    private Set<FacesValidatorInfo> types = new HashSet<FacesValidatorInfo>();
 
     public <T> void collect(@Observes ProcessManagedBean<T> event)
     {
@@ -52,7 +52,7 @@ public class FacesValidatorExtension imp
                 boolean hasValue = conv.value().length() > 0;
                 if (hasValue)
                 {
-                    types.add(new ValidatorInfo(type, conv.value()));
+                    types.add(new FacesValidatorInfo(type, conv.value()));
                 }
             }
         }
@@ -60,9 +60,9 @@ public class FacesValidatorExtension imp
     
     public void afterBean(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
     {
-        for (ValidatorInfo typeInfo : types)
+        for (FacesValidatorInfo typeInfo : types)
         {
-            afterBeanDiscovery.addBean(new DynamicValidatorProducer(beanManager, typeInfo));
+            afterBeanDiscovery.addBean(new FacesValidatorProducer(beanManager, typeInfo));
         }
     }
 

Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorInfo.java
(from r1807840, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/ValidatorInfo.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorInfo.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorInfo.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/ValidatorInfo.java&r1=1807840&r2=1807864&rev=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/ValidatorInfo.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorInfo.java
Sat Sep  9 09:05:18 2017
@@ -26,13 +26,13 @@ import java.util.Objects;
 /**
  *
  */
-public class ValidatorInfo implements Serializable
+public class FacesValidatorInfo implements Serializable
 {
     private Type type;
     
     private String validatorId;
 
-    public ValidatorInfo(Type type, String validatorId)
+    public FacesValidatorInfo(Type type, String validatorId)
     {
         this.type = type;
         this.validatorId = validatorId;
@@ -84,7 +84,7 @@ public class ValidatorInfo implements Se
         {
             return false;
         }
-        final ValidatorInfo other = (ValidatorInfo) obj;
+        final FacesValidatorInfo other = (FacesValidatorInfo) obj;
         if (!Objects.equals(this.type, other.type))
         {
             return false;

Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorProducer.java
(from r1807859, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/DynamicValidatorProducer.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorProducer.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorProducer.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/DynamicValidatorProducer.java&r1=1807859&r2=1807864&rev=1807864&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/DynamicValidatorProducer.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/validator/FacesValidatorProducer.java
Sat Sep  9 09:05:18 2017
@@ -34,9 +34,9 @@ import org.apache.myfaces.shared.util.Cl
  *
  */
 @Typed
-public class DynamicValidatorProducer extends AbstractDynamicProducer<Validator>
+public class FacesValidatorProducer extends AbstractDynamicProducer<Validator>
 {
-    public DynamicValidatorProducer(BeanManager beanManager, ValidatorInfo typeInfo)
+    public FacesValidatorProducer(BeanManager beanManager, FacesValidatorInfo typeInfo)
     {
         super(beanManager);
         
@@ -64,7 +64,7 @@ public class DynamicValidatorProducer ex
         }
         catch (Exception ex)
         {
-            Logger.getLogger(DynamicValidatorProducer.class.getName()).log(
+            Logger.getLogger(FacesValidatorProducer.class.getName()).log(
                     Level.SEVERE, "Could not instantiate converter " + converterClass.getName(),
ex);
             throw new FacesException("Could not instantiate converter: " + converterClass.getName(),
ex);
             



Mime
View raw message