You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/05/28 01:54:12 UTC

svn commit: r660761 - in /myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder: ./ qdox/ unpack/ utils/

Author: lu4242
Date: Tue May 27 16:54:12 2008
New Revision: 660761

URL: http://svn.apache.org/viewvc?rev=660761&view=rev
Log:
myfaces-metadata.xml generation for myfaces core 1.2, and stuff necessary for tomahawk12

Modified:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/unpack/UnpackMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/utils/MyfacesUtils.java

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java?rev=660761&r1=660760&r2=660761&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java Tue May 27 16:54:12 2008
@@ -138,7 +138,15 @@
      * 
      * @parameter expression="src/main/java"
      */    
-    private File mainSourceDirectory;    
+    private File mainSourceDirectory;
+    
+    /**
+     * This param is used to search in this folder if some file to
+     * be generated exists and avoid generation and duplicate exception.
+     * 
+     * @parameter
+     */        
+    private File mainSourceDirectory2;
 
     /**
      * Execute the Mojo.
@@ -253,7 +261,16 @@
                     component.getClassName(), ".", "/")+".java");
                                 
                 if (!f.exists() && canGenerateComponent(component))
-                {                
+                {
+                    if (mainSourceDirectory2 != null){
+                        File f2 = new File(mainSourceDirectory2, StringUtils.replace(
+                                component.getClassName(), ".", "/")+".java");
+                        if (f2.exists())
+                        {
+                            //Skip
+                            continue;
+                        }
+                    }
                     log.info("Generating component class:"+component.getClassName());
                     _generateComponent(velocityEngine, builder,component,baseContext);
                 }

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java?rev=660761&r1=660760&r2=660761&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeTagsMojo.java Tue May 27 16:54:12 2008
@@ -89,7 +89,15 @@
      * @parameter expression="src/main/java"
      */    
     private File mainSourceDirectory;
-    
+
+    /**
+     * This param is used to search in this folder if some file to
+     * be generated exists and avoid generation and duplicate exception.
+     * 
+     * @parameter
+     */        
+    private File mainSourceDirectory2;
+
     /**
      * @parameter 
      */
@@ -228,7 +236,16 @@
                     component.getTagClass(), ".", "/")+".java");
                 
                 if (!f.exists() && canGenerateComponentTag(component))
-                {                
+                {
+                    if (mainSourceDirectory2 != null){
+                        File f2 = new File(mainSourceDirectory2, StringUtils.replace(
+                                component.getTagClass(), ".", "/")+".java");
+                        if (f2.exists())
+                        {
+                            //Skip
+                            continue;
+                        }
+                    }
                     log.info("Generating tag class:"+component.getTagClass());
                     _generateComponent(velocityEngine, component,baseContext);
                 }

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java?rev=660761&r1=660760&r2=660761&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java Tue May 27 16:54:12 2008
@@ -3,6 +3,7 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -41,6 +42,7 @@
 import com.thoughtworks.qdox.model.JavaField;
 import com.thoughtworks.qdox.model.JavaMethod;
 import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.parser.structs.AnnoDef;
 
 /**
  * An implementation of the ModelBuilder interface that uses the Qdox java
@@ -926,7 +928,122 @@
             Map props = tag.getNamedParameterMap();
             processComponentJspProperty(props, tag.getContext(), clazz,
                     component);
-        }        
+        }
+        
+        Annotation jspPropertyAnno = getAnnotation(clazz, DOC_JSP_PROPERTY);
+        if (jspPropertyAnno != null)
+        {
+            Map props = jspPropertyAnno.getNamedParameterMap();
+            processComponentJspProperty(props, jspPropertyAnno.getContext(),
+                    clazz, component);
+        }
+        
+        
+        Annotation jspAnno = getAnnotation(clazz, "JSFJspProperties");        
+        if (jspAnno != null){
+            Object jspProps = jspAnno.getNamedParameter("properties");
+            
+            if (jspProps instanceof AnnoDef){
+                AnnoDef jspPropertiesAnno = (AnnoDef) jspProps;                
+                Map props = new NonParentesisMap(jspPropertiesAnno.args);
+                processComponentJspProperty(props, jspAnno.getContext(), clazz,
+                        component);               
+            }else{
+                List jspPropsList = (List) jspProps;
+                for (int i = 0; i < jspPropsList.size();i++)
+                {
+                    AnnoDef anno = (AnnoDef) jspPropsList.get(i);
+                    
+                    Map props = new NonParentesisMap(anno.args);
+                    processComponentJspProperty(props, jspAnno.getContext(), clazz,
+                            component);                    
+                }
+            }
+            
+        }
+    }
+    
+    /**
+     * This class uses delegate pattern to remove square parentesis 
+     * that appear when you get the arguments from an AnnoDef. I think
+     * is a design problem in the annotation feature of qdox (1.6.3).
+     * 
+     * TODO: change this on a future version of qdox!  
+     *
+     */
+    public class NonParentesisMap implements Map{
+
+        Map _delegate = null;
+        public NonParentesisMap(Map delegate){
+            _delegate = delegate;
+        }
+        public void clear()
+        {
+            _delegate.clear();
+        }
+
+        public boolean containsKey(Object key)
+        {
+            return _delegate.containsKey(key);
+        }
+
+        public boolean containsValue(Object value)
+        {
+            return _delegate.containsValue(value);
+        }
+
+        public Set entrySet()
+        {
+            return _delegate.entrySet();
+        }
+
+        public Object get(Object key)
+        {
+            Object value = _delegate.get(key);
+            if (value == null)
+                return null;
+            if (value instanceof List)
+            {
+                return ((List) value).get(0);
+            }            
+            return value; 
+        }
+
+        public boolean isEmpty()
+        {
+            return _delegate.isEmpty();
+        }
+
+        public Set keySet()
+        {
+            return _delegate.keySet();
+        }
+
+        public Object put(Object arg0, Object arg1)
+        {
+            return _delegate.put(arg0, arg1);
+        }
+
+        public void putAll(Map arg0)
+        {
+            _delegate.putAll(arg0);
+        }
+
+        public Object remove(Object key)
+        {
+            return _delegate.remove(key);
+        }
+
+        public int size()
+        {
+            return _delegate.size();
+        }
+
+        public Collection values()
+        {
+            return _delegate.values();
+        }
+        
     }
     
     private void processComponentFacets(JavaClass clazz,

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/unpack/UnpackMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/unpack/UnpackMojo.java?rev=660761&r1=660760&r2=660761&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/unpack/UnpackMojo.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/unpack/UnpackMojo.java Tue May 27 16:54:12 2008
@@ -101,7 +101,7 @@
      * 
      * @optional
      * @parameter expression="${scanModel}"
-     *            default-value="true"
+     *            default-value="false"
      */    
     private boolean scanModel;
     

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/utils/MyfacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/utils/MyfacesUtils.java?rev=660761&r1=660760&r2=660761&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/utils/MyfacesUtils.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/utils/MyfacesUtils.java Tue May 27 16:54:12 2008
@@ -85,6 +85,19 @@
 
     public static String getJspPropertyType12(PropertyMeta property)
     {
+        if (property.getJspName().equals("actionListener"))
+        {
+            return "javax.el.MethodExpression";
+        }
+        if (property.getJspName().equals("validator"))
+        {
+            return "javax.el.MethodExpression";
+        }
+        if (property.getJspName().equals("valueChangeListener"))
+        {
+            return "javax.el.MethodExpression";
+        }
+        
         if (property.isMethodExpression())
             return "MethodExpression";
 
@@ -137,6 +150,46 @@
 
         return value.toString();
     }
+    
+    public static String importTagClasses12(ComponentMeta component)
+    {
+        Set imports = new HashSet();
+        for (Iterator it = component.properties(); it.hasNext();)
+        {
+            PropertyMeta property = (PropertyMeta) it.next();
+            if (property.getClassName() != null && 
+                    !PRIMITIVE_TYPES.contains(property.getClassName()))
+            {
+                if (!property.getClassName().startsWith("java.lang"))
+                {
+                    imports.add(property.getClassName());
+                }
+            }
+            if (property.getJspName().equals("actionListener")){
+                imports.add("javax.faces.event.MethodExpressionActionListener");
+            }
+            if (property.getJspName().equals("valueChangeListener")){
+                imports.add("javax.faces.event.MethodExpressionValueChangeListener");
+            }
+            if (property.getJspName().equals("validator")){
+                imports.add("javax.faces.validator.MethodExpressionValidator");
+            }
+        }
+
+        StringBuilder value = new StringBuilder();
+
+        for (Iterator importIterator = imports.iterator(); importIterator
+                .hasNext();)
+        {
+            value.append("import ");
+            value.append((String) importIterator.next());
+            value.append(';');
+            value.append('\n');
+        }
+
+        return value.toString();
+    }
+    
 
     public static boolean isConverter(String propClass)
     {