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 2009/11/08 21:56:35 UTC

svn commit: r833924 - in /myfaces/myfaces-build-tools/trunk/maven2-plugins: myfaces-builder-annotations/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/annotation/ myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/mav...

Author: lu4242
Date: Sun Nov  8 20:56:34 2009
New Revision: 833924

URL: http://svn.apache.org/viewvc?rev=833924&view=rev
Log:
MYFACES-2373 Add a way to document event capabilities for components using myfaces builder plugin

Added:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-annotations/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/annotation/JSFListener.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerHolder.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerMeta.java
Modified:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ModelUtils.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxHelper.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/tagdoc/TagdocUtils.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-annotations/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/annotation/JSFListener.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-annotations/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/annotation/JSFListener.java?rev=833924&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-annotations/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/annotation/JSFListener.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-annotations/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/annotation/JSFListener.java Sun Nov  8 20:56:34 2009
@@ -0,0 +1,54 @@
+/*
+ *  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.buildtools.maven2.plugin.builder.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @since 1.0.4 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 796607 $ $Date: 2009-07-21 22:00:30 -0500 (mar, 21 jul 2009) $
+ */
+@Documented
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.SOURCE)
+public @interface JSFListener
+{   
+    String name() default "";
+    
+    String event() default "";
+    
+    /**
+     * (true|false) Define if the property is required or not. Default:false
+     */
+    boolean required() default false;
+    
+    /**
+     * Short description
+     */
+    String desc() default "";
+
+    String clazz() default "";
+    
+    String phases() default "";
+}

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.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/model/ComponentMeta.java?rev=833924&r1=833923&r2=833924&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ComponentMeta.java Sun Nov  8 20:56:34 2009
@@ -34,7 +34,7 @@
  * class or interface that a UIComponent can be derived from.
  */
 public class ComponentMeta extends ViewEntityMeta implements 
-    PropertyHolder, FacetHolder
+    PropertyHolder, FacetHolder, ListenerHolder
 {
     private String _bodyContent;
 
@@ -58,6 +58,7 @@
     private Boolean _template;
     
     protected Map _facets;
+    protected Map _listeners;
 
     /**
      * Write an instance of this class out as xml.
@@ -87,6 +88,11 @@
             FacetMeta facet = (FacetMeta) i.next();
             FacetMeta.writeXml(out, facet);
         }
+        for (Iterator i = _listeners.values().iterator(); i.hasNext();)
+        {
+            ListenerMeta listener = (ListenerMeta) i.next();
+            ListenerMeta.writeXml(out, listener);
+        }
     }
 
     /**
@@ -119,6 +125,7 @@
         digester.addBeanPropertySetter(newPrefix + "/template");
         
         FacetMeta.addXmlRules(digester, newPrefix);
+        ListenerMeta.addXmlRules(digester, newPrefix);
     }
 
     /**
@@ -128,6 +135,7 @@
     {
         super("component");
         _facets = new LinkedHashMap();
+        _listeners = new LinkedHashMap();
     }
 
     /**
@@ -167,6 +175,7 @@
 
         ModelUtils.mergeProps(this, other);
         ModelUtils.mergeFacets(this, other);
+        ModelUtils.mergeListeners(this, other);
         
         if (inheritParentTag)
         {
@@ -396,6 +405,31 @@
     }
     
     /**
+     * @since 1.0.4
+     */
+    public void addListener(ListenerMeta prop)
+    {
+        _listeners.put(prop.getClassName(), prop);
+    }
+
+    /**
+     * @since 1.0.4
+     */
+    public Iterator listeners()
+    {
+        return _listeners.values().iterator();
+    }
+
+    /**
+     * @since 1.0.4
+     */
+    public ListenerMeta getListener(String name)
+    {
+        return (ListenerMeta) _listeners.get(name);
+    }
+
+    
+    /**
      * 
      * @since 1.0.4
      */

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerHolder.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/model/ListenerHolder.java?rev=833924&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerHolder.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerHolder.java Sun Nov  8 20:56:34 2009
@@ -0,0 +1,38 @@
+/*
+ *  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.buildtools.maven2.plugin.builder.model;
+
+import java.util.Iterator;
+
+/**
+ * Interface for any artifact that has JSF listener on it.
+ * 
+ * @since 1.0.4
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 796607 $ $Date: 2009-07-21 22:00:30 -0500 (mar, 21 jul 2009) $
+ */
+public interface ListenerHolder
+{
+    
+    Iterator listeners();
+
+    ListenerMeta getListener(String name);
+
+    void addListener(ListenerMeta prop);
+}

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerMeta.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/model/ListenerMeta.java?rev=833924&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerMeta.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ListenerMeta.java Sun Nov  8 20:56:34 2009
@@ -0,0 +1,247 @@
+/*
+ *  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.buildtools.maven2.plugin.builder.model;
+
+import org.apache.commons.digester.Digester;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.io.XmlWriter;
+
+/**
+ * 
+ * @since 1.0.4
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 796607 $ $Date: 2009-07-21 22:00:30 -0500 (mar, 21 jul 2009) $
+ */
+public class ListenerMeta
+{
+    private String _longDescription;
+    private String _description;
+    private String _name;
+    private Boolean _required;
+    
+    private Boolean _inherited; //Define if this facet is inherited from parent component
+    private Boolean _generated; //Define if this facet should be generated
+    
+    private String _className;
+    private String _eventClassName;
+    private String _phases;
+
+    public ListenerMeta()
+    {
+        
+    }
+    
+    public ListenerMeta(ListenerMeta pm)
+    {
+        _name = pm._name;
+        _className = pm._className;
+        _eventClassName = pm._eventClassName;
+        _required = pm._required;
+        _description = pm._description;
+        _longDescription = pm._longDescription;
+        _phases = pm._phases;
+        _inherited = pm._inherited;
+    }
+    
+    /**
+     * Write this model out as xml.
+     */
+    public static void writeXml(XmlWriter out, ListenerMeta am)
+    {
+        out.beginElement("listener");
+        out.writeElement("name", am._name);
+        out.writeElement("className", am._className);
+        out.writeElement("eventClassName", am._eventClassName);
+        out.writeElement("required", am._required);
+        out.writeElement("desc", am._description);
+        out.writeElement("longDesc", am._longDescription);
+        out.writeElement("phases", am._phases);
+        out.writeElement("inherited", am._inherited);
+        out.endElement("listener");
+    }
+
+    /**
+     * Add digester rules to repopulate a Model instance from an xml file.
+     */
+    public static void addXmlRules(Digester digester, String prefix)
+    {
+        String newPrefix = prefix + "/listener";
+
+        digester.addObjectCreate(newPrefix, ListenerMeta.class);
+        digester.addSetNext(newPrefix, "addListener");
+
+        digester.addBeanPropertySetter(newPrefix + "/name");
+        digester.addBeanPropertySetter(newPrefix + "/className");
+        digester.addBeanPropertySetter(newPrefix + "/eventClassName");
+        digester.addBeanPropertySetter(newPrefix + "/required");
+        digester.addBeanPropertySetter(newPrefix + "/desc", "description");
+        digester.addBeanPropertySetter(newPrefix + "/longDesc",
+                "longDescription");
+        digester.addBeanPropertySetter(newPrefix + "/phases", "phases");
+        digester.addBeanPropertySetter(newPrefix + "/inherited", "inherited");        
+    }
+
+    /**
+     * Merge the data in the specified other property into this one, throwing an
+     * exception if there is an incompatibility.
+     */
+    public void merge(ListenerMeta other)
+    {
+        
+        _name = ModelUtils.merge(this._name, other._name);
+        _required = ModelUtils.merge(this._required, other._required);
+        _description = ModelUtils.merge(this._description, other._description);
+        _longDescription = ModelUtils.merge(this._longDescription, other._longDescription);
+        _phases = ModelUtils.merge(this._phases, other._phases);
+    }
+    
+    
+    
+    /**
+     * Sets the listener name for this listener.
+     *
+     * @param name  the listener name
+     */
+    public void setName(String name)
+    {
+        _name = name;
+    }
+    
+    /**
+     * Returns the listener name for this listener.
+     *
+     * @return  the listener name
+     */
+    public String getName()
+    {
+        return _name;
+    }
+    
+    /**
+     * The fully-qualified name of the JSF entity class, ie the class that actually
+     * implements a Listener.
+     * <p>
+     * The specified class may be a hand-written one, or one created via code generation. 
+     */
+    public String getClassName()
+    {
+        return _className;
+    }
+
+    public void setClassName(String className)
+    {
+        _className = className;
+    }
+    
+    /**
+     * Sets the description of this property.
+     *
+     * @param description  the property description
+     */
+    public void setDescription(String description)
+    {
+        _description = description;
+    }
+
+    /**
+     * Returns the description of this property.
+     *
+     * @return  the property description
+     */
+    public String getDescription()
+    {
+        return _description;
+    }
+
+    /**
+     * Sets the required flag of this facet.
+     *
+     * @param required  the facet required flag
+     */
+    public void setRequired(Boolean required)
+    {
+        _required = required;
+    }
+
+    /**
+     * Returns required flag of this facet.
+     *
+     * @return  the facet required flag
+     */
+    public Boolean isRequired()
+    {
+        return ModelUtils.defaultOf(_required,false);
+    }
+    
+    public void setLongDescription(String desc)
+    {
+        _longDescription = desc;
+    }
+
+    public String getLongDescription()
+    {
+        return _longDescription;
+    }
+    
+    public void setInherited(Boolean inherited)
+    {
+        _inherited = inherited;
+    }
+
+    public Boolean isInherited()
+    {
+        return ModelUtils.defaultOf(_inherited, false);
+    }
+    
+    public void setGenerated(Boolean generated)
+    {
+        _generated = generated;
+    }
+
+    /**
+     * Indicates if the property should be generated
+     * or not.
+     * 
+     * @return
+     */
+    public Boolean isGenerated()
+    {
+        return ModelUtils.defaultOf(_generated, false);
+    }
+
+    public void setEventClassName(String eventClassName)
+    {
+        _eventClassName = eventClassName;
+    }
+
+    public String getEventClassName()
+    {
+        return _eventClassName;
+    }
+
+    public void setPhases(String phases)
+    {
+        _phases = phases;
+    }
+
+    public String getPhases()
+    {
+        return _phases;
+    }
+    
+}

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ModelUtils.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/model/ModelUtils.java?rev=833924&r1=833923&r2=833924&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ModelUtils.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ModelUtils.java Sun Nov  8 20:56:34 2009
@@ -128,6 +128,32 @@
     
     /**
      * @since 1.0.4
+     * @param dst
+     * @param src
+     */
+    public static void mergeListeners(ListenerHolder dst, ListenerHolder src)
+    {
+        for (Iterator i = src.listeners(); i.hasNext();)
+        {
+            ListenerMeta srcProp = (ListenerMeta) i.next();
+            ListenerMeta dstProp = dst.getListener(srcProp.getName());
+            if (dstProp == null)
+            {
+                // Just copy the whole property unaltered
+                dstProp = new ListenerMeta(srcProp);
+                dstProp.setInherited(Boolean.TRUE);
+                dst.addListener(dstProp);
+            }
+            else
+            {
+                // merge the two property objects together
+                dstProp.merge(srcProp);
+            }
+        }
+    }
+    
+    /**
+     * @since 1.0.4
      */
     public static void mergeAttributes(AttributeHolder dst, AttributeHolder src)
     {

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxHelper.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/QdoxHelper.java?rev=833924&r1=833923&r2=833924&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxHelper.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxHelper.java Sun Nov  8 20:56:34 2009
@@ -18,15 +18,25 @@
  */
 package org.apache.myfaces.buildtools.maven2.plugin.builder.qdox;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ClassMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ConverterMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FaceletTagMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ValidatorMeta;
+import org.codehaus.plexus.components.io.fileselectors.FileInfo;
+import org.codehaus.plexus.components.io.fileselectors.FileSelector;
 
+import com.thoughtworks.qdox.JavaDocBuilder;
 import com.thoughtworks.qdox.model.JavaClass;
 
 /**
@@ -252,4 +262,127 @@
         }            
         return value;
     }
+    
+    public static void addFileToJavaDocBuilder(JavaDocBuilder builder,
+            FileSelector selector, File path)
+    {
+        addFileToJavaDocBuilder(builder,selector, path, path.getPath());
+    }
+    
+    
+    public static void addFileToJavaDocBuilder(JavaDocBuilder builder,
+            FileSelector selector, File path, String basePath)
+    {
+        if (path.isDirectory())
+        {
+            File[] files = path.listFiles();
+            
+            //Scan all files in directory
+            for (int i = 0; i < files.length; i++)
+            {
+                addFileToJavaDocBuilder(builder, selector, files[i], basePath);
+            }
+        }
+        else
+        {
+            File file = path;
+
+            try
+            {
+                String name = file.getPath();
+                while (name.startsWith("/"))
+                {
+                    name = name.substring(1);
+                }
+                while (name.startsWith("\\"))
+                {
+                    name = name.substring(1);
+                }
+                SourceFileInfo fileInfo = new SourceFileInfo(file,name);
+                if (selector.isSelected(fileInfo))
+                {
+                    //System.out.println("file:"+name);
+                    builder.addSource(file);
+                }
+            }
+            catch (FileNotFoundException e)
+            {
+                Log log = LogFactory.getLog(QdoxHelper.class);
+                log.error("Error reading file: "+file.getName()+" "+e.getMessage());
+            }
+            catch (IOException e)
+            {
+                Log log = LogFactory.getLog(QdoxHelper.class);
+                log.error("Error reading file: "+file.getName()+" "+e.getMessage());                
+            }
+        }
+    }
+    
+    private static class SourceFileInfo implements FileInfo
+    {
+        private File file;
+        
+        private String name;
+
+        /**
+         * Creates a new instance.
+         */
+        public SourceFileInfo( File file )
+        {
+            this( file, file.getPath().replace( '\\', '/' ) );
+        }
+
+        /**
+         * Creates a new instance.
+         */
+        public SourceFileInfo( File file, String name )
+        {
+            this.file = file;
+            this.name = name;
+        }
+        
+        /**
+         * Sets the resources file.
+         */
+        public void setFile( File file )
+        {
+            this.file = file;
+        }
+
+        /**
+         * Returns the resources file.
+         */
+        public File getFile()
+        {
+            return file;
+        }
+
+        /**
+         * Sets the resources name.
+         */
+        public void setName( String name )
+        {
+            this.name = name;
+        }
+
+        public String getName()
+        {
+            return name;
+        }        
+        
+        public InputStream getContents() throws IOException
+        {
+            return new FileInputStream( getFile() );
+        }
+
+        public boolean isDirectory()
+        {
+            return file.isDirectory();
+        }
+
+        public boolean isFile()
+        {
+            return file.isFile();
+        }        
+    }
 }

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=833924&r1=833923&r2=833924&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 Sun Nov  8 20:56:34 2009
@@ -19,10 +19,6 @@
 package org.apache.myfaces.buildtools.maven2.plugin.builder.qdox;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
@@ -42,8 +38,11 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ClassMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ConverterMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FaceletTagMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FacetHolder;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FacetMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ListenerHolder;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ListenerMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.MethodSignatureMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.PropertyHolder;
@@ -54,12 +53,8 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ValidatorMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.WebConfigMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.WebConfigParamMeta;
-import org.codehaus.plexus.components.io.fileselectors.FileInfo;
-import org.codehaus.plexus.components.io.fileselectors.FileSelector;
 import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector;
 
-import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FaceletTagMeta;
-
 import com.thoughtworks.qdox.JavaDocBuilder;
 import com.thoughtworks.qdox.model.AbstractJavaEntity;
 import com.thoughtworks.qdox.model.Annotation;
@@ -89,7 +84,8 @@
     private static final String DOC_RENDERERS = "JSFRenderers";
 
     private static final String DOC_PROPERTY = "JSFProperty";
-    private static final String DOC_FACET = "JSFFacet";   
+    private static final String DOC_FACET = "JSFFacet";
+    private static final String DOC_LISTENER = "JSFListener";
     
     //This property is used in special cases where properties 
     //does not have methods defined on component class, like binding
@@ -187,7 +183,7 @@
             }
             
             //Scan all files on directory and add to builder
-            addFileToJavaDocBuilder(builder, selector, srcDir);
+            QdoxHelper.addFileToJavaDocBuilder(builder, selector, srcDir);
         }        
         
         JavaClass[] classes = builder.getClasses();
@@ -195,127 +191,6 @@
         buildModel(model, sourceDirs, classes);
     }
     
-    private void addFileToJavaDocBuilder(JavaDocBuilder builder,
-            FileSelector selector, File path)
-    {
-        addFileToJavaDocBuilder(builder,selector, path, path.getPath());
-    }
-    
-    
-    private void addFileToJavaDocBuilder(JavaDocBuilder builder,
-            FileSelector selector, File path, String basePath)
-    {
-        if (path.isDirectory())
-        {
-            File[] files = path.listFiles();
-            
-            //Scan all files in directory
-            for (int i = 0; i < files.length; i++)
-            {
-                addFileToJavaDocBuilder(builder, selector, files[i], basePath);
-            }
-        }
-        else
-        {
-            File file = path;
-
-            try
-            {
-                String name = file.getPath();
-                while (name.startsWith("/"))
-                {
-                    name = name.substring(1);
-                }
-                while (name.startsWith("\\"))
-                {
-                    name = name.substring(1);
-                }
-                SourceFileInfo fileInfo = new SourceFileInfo(file,name);
-                if (selector.isSelected(fileInfo))
-                {
-                    //System.out.println("file:"+name);
-                    builder.addSource(file);
-                }
-            }
-            catch (FileNotFoundException e)
-            {
-                log.error("Error reading file: "+file.getName()+" "+e.getMessage());
-            }
-            catch (IOException e)
-            {
-                log.error("Error reading file: "+file.getName()+" "+e.getMessage());                
-            }
-        }
-    }
-    
-    private class SourceFileInfo implements FileInfo
-    {
-        private File file;
-        
-        private String name;
-
-        /**
-         * Creates a new instance.
-         */
-        public SourceFileInfo( File file )
-        {
-            this( file, file.getPath().replace( '\\', '/' ) );
-        }
-
-        /**
-         * Creates a new instance.
-         */
-        public SourceFileInfo( File file, String name )
-        {
-            this.file = file;
-            this.name = name;
-        }
-        
-        /**
-         * Sets the resources file.
-         */
-        public void setFile( File file )
-        {
-            this.file = file;
-        }
-
-        /**
-         * Returns the resources file.
-         */
-        public File getFile()
-        {
-            return file;
-        }
-
-        /**
-         * Sets the resources name.
-         */
-        public void setName( String name )
-        {
-            this.name = name;
-        }
-
-        public String getName()
-        {
-            return name;
-        }        
-        
-        public InputStream getContents() throws IOException
-        {
-            return new FileInputStream( getFile() );
-        }
-
-        public boolean isDirectory()
-        {
-            return file.isDirectory();
-        }
-
-        public boolean isFile()
-        {
-            return file.isFile();
-        }        
-    }
-
     /**
      * Scan the source tree for doc-annotations, and build Model objects
      * containing info extracted from the doc-annotation attributes and
@@ -1214,6 +1089,7 @@
         // Now here walk the component looking for property annotations.
         processComponentProperties(clazz, component);
         processComponentFacets(clazz, component);
+        processComponentListeners(clazz, component);
 
         model.addComponent(component);
     }
@@ -1752,6 +1628,71 @@
             }
         }
     }
+
+    /**
+     * @since 1.0.4
+     */
+    private void processComponentListeners(JavaClass clazz,
+            ListenerHolder component)
+    {
+        JavaMethod[] methods = clazz.getMethods();
+        for (int i = 0; i < methods.length; ++i)
+        {
+            JavaMethod method = methods[i];
+
+            DocletTag tag = method.getTagByName(DOC_LISTENER);
+            if (tag != null)
+            {
+                Map props = tag.getNamedParameterMap();
+                processComponentListener(props, (AbstractJavaEntity)tag.getContext(), clazz,
+                        method, component);
+            }
+
+            Annotation anno = getAnnotation(method, DOC_LISTENER);
+            if (anno != null)
+            {
+                Map props = anno.getNamedParameterMap();
+                processComponentListener(props, (AbstractJavaEntity)anno.getContext(), clazz,
+                        method, component);
+            }
+        }
+        
+        Type [] interfaces = clazz.getImplements();
+        
+        //Scan interfaces for properties to be added to this component
+        //This feature allow us to have groups of functions.
+        for (int i = 0; i < interfaces.length;++i)
+        {
+            JavaClass intf = interfaces[i].getJavaClass();
+
+            //If the interfaces has a JSFComponent Doclet,
+            //this is managed in other way
+            if (intf.getTagByName(DOC_COMPONENT, false) == null)
+            {
+                JavaMethod[] intfmethods = intf.getMethods();
+                for (int j = 0; j < intfmethods.length; ++j)
+                {
+                    JavaMethod intfmethod = intfmethods[j];
+
+                    DocletTag tag = intfmethod.getTagByName(DOC_LISTENER);
+                    if (tag != null)
+                    {
+                        Map props = tag.getNamedParameterMap();
+                        processInterfaceComponentListener(props, (AbstractJavaEntity)tag.getContext(), 
+                                clazz, intfmethod, component);
+                    }
+
+                    Annotation anno = getAnnotation(intfmethod, DOC_LISTENER);
+                    if (anno != null)
+                    {
+                        Map props = anno.getNamedParameterMap();
+                        processInterfaceComponentListener(props, (AbstractJavaEntity)anno.getContext(),
+                                clazz, intfmethod, component);
+                    }
+                }
+            }
+        }
+    }
         
     private void processInterfaceComponentProperty(Map props, AbstractJavaEntity ctx,
     JavaClass clazz, JavaMethod method, PropertyHolder component)
@@ -1789,6 +1730,27 @@
         }            
     }
     
+    /**
+     * @since 1.0.4
+     */
+    private void processInterfaceComponentListener(Map props, AbstractJavaEntity ctx,
+            JavaClass clazz, JavaMethod method, ListenerHolder component)
+    {
+        this.processComponentListener(props, ctx, clazz, method, component);
+                
+        ListenerMeta listener = component.getListener(QdoxHelper.methodToPropName(method.getName()));
+                
+        //Try to get the method from the component clazz to see if this
+        //has an implementation
+        JavaMethod clazzMethod = clazz.getMethodBySignature(method.getName(), null , false);
+                
+        if (clazzMethod == null)
+        {
+            //The method should be generated!
+            listener.setGenerated(Boolean.TRUE);
+        }            
+    }
+    
     private void processComponentProperty(Map props, AbstractJavaEntity ctx,
             JavaClass clazz, JavaMethod method, PropertyHolder component)
     {
@@ -1920,6 +1882,58 @@
         component.addFacet(p);
     }
     
+    /**
+     * @since 1.0.4
+     */
+    private void processComponentListener(Map props, AbstractJavaEntity ctx,
+            JavaClass clazz, JavaMethod method, ListenerHolder component)
+    {
+        Boolean required = getBoolean(clazz, "required", props, null);
+
+        String longDescription = ctx.getComment();
+        String descDflt = QdoxHelper.getFirstSentence(longDescription);
+        if ((descDflt == null) || (descDflt.length() < 2))
+        {
+            descDflt = "no description";
+        }
+        String shortDescription = getString(clazz, "desc", props, descDflt);
+        
+        Type returnType = null;
+        
+        if (method.getName().startsWith("set"))
+        {
+            returnType = method.getParameters()[0].getType();
+        }
+        else
+        {
+            returnType = method.getReturns();
+        }
+        
+        String fullyQualifiedReturnType = returnType.getJavaClass().getFullyQualifiedName();
+        fullyQualifiedReturnType = QdoxHelper.getFullyQualifiedClassName(clazz, fullyQualifiedReturnType);
+        fullyQualifiedReturnType = getString(clazz, "clazz", props, fullyQualifiedReturnType);
+        
+        String phases = getString(clazz, "phases", props, null);
+        String eventClassName = getString(clazz, "event", props, null);
+        String name = getString(clazz, "name", props, QdoxHelper.methodToPropName(method.getName()));
+        
+        ListenerMeta p = new ListenerMeta();
+        p.setName(name);
+        p.setClassName(fullyQualifiedReturnType);
+        p.setEventClassName(eventClassName);
+        p.setRequired(required);
+        p.setDescription(shortDescription);
+        p.setLongDescription(longDescription);
+        p.setPhases(phases);
+        
+        //If the method is abstract this should be generated
+        if (method.isAbstract())
+        {
+            p.setGenerated(Boolean.TRUE);
+        }
+
+        component.addListener(p);
+    }
     
     private void processComponentJspProperty(Map props, AbstractJavaEntity ctx,
             JavaClass clazz, PropertyHolder component)

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocUtils.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/tagdoc/TagdocUtils.java?rev=833924&r1=833923&r2=833924&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocUtils.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/tagdoc/TagdocUtils.java Sun Nov  8 20:56:34 2009
@@ -32,6 +32,8 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FacetHolder;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FacetMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ListenerHolder;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ListenerMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.Model;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.PropertyHolder;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.PropertyMeta;
@@ -119,6 +121,31 @@
         return list;
     }
     
+    /**
+     * @since 1.0.4
+     * @param component
+     * @return
+     */
+    static public List getSortedListenerList(ListenerHolder component)
+    {
+        TreeSet facetNames = new TreeSet();
+        Iterator iter = component.listeners();
+        while (iter.hasNext())
+        {
+            facetNames.add(((ListenerMeta) iter.next()).getClassName());
+        }
+        
+        // Now get a list of PropertyMetas
+        List list = new ArrayList();
+        Iterator nameIter = facetNames.iterator();
+        while (nameIter.hasNext())
+        {
+            String name = (String) nameIter.next();
+            list.add(component.getListener(name));
+        }
+        return list;
+    }
+    
     static public List getSortedAttributeList(AttributeHolder component)
     {
         // Sort the names

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm?rev=833924&r1=833923&r2=833924&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-component.vm Sun Nov  8 20:56:34 2009
@@ -61,6 +61,53 @@
    </table>
    </p>
   </section>
+#end
+#set($listenerList = ${tagdocUtils.getSortedListenerList($component)})
+#if ($listenerList.size() != 0)
+  <section name="Supported Listeners">
+   <p>
+   <table>
+    <tr>
+     <th>Name</th>
+     <th>Listener</th>
+     <th>Event</th>
+     <th>Phases</th>
+     <th>Required</th>
+     <th>Description</th>
+    </tr>
+#foreach( $listener in $listenerList )
+    <tr>
+#if ($listener.name)
+     <td>$listener.name</td>
+#else
+     <td></td>
+#end
+#if ($listener.className)
+    <td>$listener.className</td>
+#else
+    <td></td>
+#end
+#if ($listener.eventClassName)
+    <td>$listener.eventClassName</td>
+#else
+    <td></td>
+#end
+#if ($listener.phases)
+     <td>$listener.phases</td>
+#else
+     <td></td>
+#end
+     <td>$listener.isRequired()</td>
+#if ($listener.longDescription)
+     <td>$listener.longDescription</td>
+#else
+     <td></td>
+#end     
+    </tr>
+#end
+   </table>
+   </p>
+  </section>
 #end  
 #set ($propertyList = ${tagdocUtils.getSortedPropertyList($component)})
 #if ($propertyList.size() != 0)