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 03:37:37 UTC

svn commit: r833808 - in /myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main: java/org/apache/myfaces/buildtools/maven2/plugin/builder/ java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ java/org/apache/myface...

Author: lu4242
Date: Sun Nov  8 02:37:36 2009
New Revision: 833808

URL: http://svn.apache.org/viewvc?rev=833808&view=rev
Log:
MYFACES-2377 Include global config parameters javadoc on myfaces-metadata using some myfaces builder plugin annotation

Added:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigMeta.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamHolder.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamMeta.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-web-config.vm
Modified:
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/BuildMetaDataMojo.java
    myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.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

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/BuildMetaDataMojo.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/BuildMetaDataMojo.java?rev=833808&r1=833807&r2=833808&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/BuildMetaDataMojo.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/BuildMetaDataMojo.java Sun Nov  8 02:37:36 2009
@@ -249,6 +249,7 @@
      * This param is used to search in this folder if some file to
      * be generated exists and avoid generation and duplicate exception.
      * 
+     * @since 1.0.4
      * @parameter
      */    
     private List sourceDirectories;

Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.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/Model.java?rev=833808&r1=833807&r2=833808&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/Model.java Sun Nov  8 02:37:36 2009
@@ -41,6 +41,7 @@
     private List _renderKits = new ArrayList(100);
     private List _tags = new ArrayList(100);
     private List _faceletTags = new ArrayList(100);
+    private List _webConfigs = new ArrayList(10);
 
     private Map _componentsByClass = new TreeMap();
     private Map _convertersByClass = new TreeMap();
@@ -50,6 +51,7 @@
     private Map _faceletTagsByClass =  new TreeMap();
     private Map _componentsByTagClass = new TreeMap();
     private Map _faceletTagsByName = new TreeMap();
+    private Map _webConfigsByModelId = new TreeMap();
     
     private String _modelId;
 
@@ -100,6 +102,12 @@
             FaceletTagMeta c = (FaceletTagMeta) i.next();
             c.writeXml(out);
         }
+        
+        for (Iterator i = model._webConfigs.iterator(); i.hasNext();)
+        {
+            WebConfigMeta c = (WebConfigMeta) i.next();
+            c.writeXml(out);
+        }
 
         out.endElement("model");
     }
@@ -123,6 +131,7 @@
         RenderKitMeta.addXmlRules(digester, prefix);
         TagMeta.addXmlRules(digester, prefix);
         FaceletTagMeta.addXmlRules(digester, prefix);
+        WebConfigMeta.addXmlRules(digester, prefix);
     }
     
     /**
@@ -183,7 +192,17 @@
             {
                 this.addFaceletTag(faceletTag);
             }
-        }         
+        }
+        
+        for (Iterator it = other.getWebConfigs().iterator(); it.hasNext();)
+        {
+            WebConfigMeta webConfig = (WebConfigMeta) it.next();
+            
+            if (this.findWebConfigsByModelId(webConfig.getModelId())== null)
+            {
+                this.addWebConfig(webConfig);
+            }
+        }
     }
 
     /**
@@ -409,6 +428,39 @@
     {
         return (FaceletTagMeta) _faceletTagsByName.get(name);
     }
+    
+    /**
+     * @since 1.0.4
+     */
+    public List getWebConfigs()
+    {
+        return _webConfigs;
+    }
+
+    /**
+     * @since 1.0.4
+     */
+    public Iterator webConfigs()
+    {
+        return _webConfigs.iterator();
+    }
+
+    /**
+     * @since 1.0.4
+     */
+    public WebConfigMeta findWebConfigsByModelId(String modelId)
+    {
+        return (WebConfigMeta) _webConfigsByModelId.get(modelId);
+    }
+    
+    /**
+     * @since 1.0.4
+     */
+    public void addWebConfig(WebConfigMeta config)
+    {
+        _webConfigs.add(config);
+        _webConfigsByModelId.put(config.getModelId(), config);
+    }
 
     public void setModelId(String modelId)
     {

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigMeta.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/WebConfigMeta.java?rev=833808&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigMeta.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigMeta.java Sun Nov  8 02:37:36 2009
@@ -0,0 +1,174 @@
+/*
+ *  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.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+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 WebConfigMeta implements WebConfigParamHolder
+{
+    private String _xmlElementName;
+    private String _modelId;
+    
+    protected Map _webConfigParameters = new LinkedHashMap();
+    
+    /**
+     * Add digester rules to repopulate an instance of this type from an xml
+     * file.
+     */
+    public static void addXmlRules(Digester digester, String prefix)
+    {
+        String newPrefix = prefix + "/webConfig";
+        digester.addObjectCreate(newPrefix, WebConfigMeta.class);
+        digester.addSetNext(newPrefix, "addWebConfig");        
+        digester.addBeanPropertySetter(newPrefix + "/modelId");
+        WebConfigParamMeta.addXmlRules(digester, newPrefix);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * Param xmlElementName is the name of the xml element that is created
+     * when method writeXml is invoked.
+     */
+    public WebConfigMeta()
+    {
+        _xmlElementName = "webConfig";
+    }
+
+    /**
+     * Write the properties of this instance out as xml.
+     * <p>
+     * The name of the xml element that is created to hold the properties
+     * was specified when the constructor was called.
+     * <p>
+     * Subclasses that want to output their own properties should not
+     * override this method. Instead, they should override writeXmlSimple
+     * (and in rare cases writeXmlComplex).
+     * <p>
+     * Having two write methods (writeXmlSimple/writeXmlComplex) gives some basic
+     * control over the order in which data is written to xml, in order to make
+     * the generated xml look nice. Any properties written in writeXmlSimple will
+     * appear in the output file before properties written by writeXmlComplex. 
+     * Therefore, properties which are "easily read" should be written out in
+     * a writeXmlSimple method. Data which has large CDATA blocks, or complicated
+     * nested structure should be written out in a writeXmlComplex method so that
+     * the "simple" stuff can be easily read and is not buried in the middle of
+     * the harder-to-read output.
+     */
+    protected void writeXml(XmlWriter out)
+    {
+        out.beginElement(_xmlElementName);
+        writeXmlSimple(out);
+        writeXmlComplex(out);
+        out.endElement(_xmlElementName);
+    }
+
+    /**
+     * Write this model out as xml.
+     * <p>
+     * Subclasses that wish to write out properties as xml should override
+     * this method, call the super implementation, then call methods on the
+     * XmlWriter object to output their data.
+     */
+    protected void writeXmlSimple(XmlWriter out)
+    {
+        out.writeElement("modelId", _modelId);
+    }
+
+    /**
+     * See documentation for writeXml and writeXmlSimple methods.
+     */
+    protected void writeXmlComplex(XmlWriter out)
+    {
+        for (Iterator i = _webConfigParameters.values().iterator(); i.hasNext();)
+        {
+            WebConfigParamMeta prop = (WebConfigParamMeta) i.next();
+            WebConfigParamMeta.writeXml(out, prop);
+        }
+    }
+
+    /**
+     * Merge any inheritable data from the specified "other" instance into
+     * the metadata held by this instance.
+     */
+    protected void merge(ClassMeta other)
+    {
+        // There is nothing to merge between two ClassMeta objects;
+        // none of the properties on this class are inheritable.
+    }
+
+    /**
+     * Indicates which "group" of metadata this class belongs to.
+     * <p>
+     * Projects can inherit metadata from other projects, in which case
+     * all the ClassMeta objects end up in one big collection. But for
+     * some purposes it is necessary to iterate over the objects belonging
+     * to only one project (eg when generating components). This return
+     * value can be tested to check which "group" (project) a particular
+     * instance belongs to.
+     */
+    public String getModelId()
+    {
+        return _modelId;
+    }
+
+    public void setModelId(String modelId)
+    {
+        this._modelId = modelId;
+    }
+
+    public void addWebConfigParam(WebConfigParamMeta wcp)
+    {
+        _webConfigParameters.put(wcp.getName(), wcp);
+    }
+    
+    public int webConfigParametersSize()
+    {
+        return _webConfigParameters.size();
+    }
+
+    public WebConfigParamMeta getWebConfigParam(String name)
+    {
+        return (WebConfigParamMeta)_webConfigParameters.get(name);
+    }
+
+    public Iterator webConfigParameters()
+    {
+        return _webConfigParameters.values().iterator();
+    }
+    
+    //THIS METHODS ARE USED FOR VELOCITY TO GET DATA AND GENERATE CLASSES
+    
+    public Collection getWebConfigParametersList()
+    {
+        return _webConfigParameters.values();
+    }
+}

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamHolder.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/WebConfigParamHolder.java?rev=833808&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamHolder.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamHolder.java Sun Nov  8 02:37:36 2009
@@ -0,0 +1,36 @@
+/*
+ *  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;
+
+/**
+ * 
+ * @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 WebConfigParamHolder
+{
+    Iterator webConfigParameters();
+
+    WebConfigParamMeta getWebConfigParam(String name);
+
+    void addWebConfigParam(WebConfigParamMeta wcp);
+}

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamMeta.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/WebConfigParamMeta.java?rev=833808&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamMeta.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/WebConfigParamMeta.java Sun Nov  8 02:37:36 2009
@@ -0,0 +1,227 @@
+/*
+ *  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.commons.lang.StringUtils;
+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 WebConfigParamMeta
+{
+    private String _name;
+    private String _fieldName;
+    private String   _defaultValue;
+    private String _description;
+    private String _longDescription;
+    private String _expectedValues;
+    private String _sourceClassName;
+    private String _since;
+
+    public WebConfigParamMeta()
+    {
+        
+    }
+    
+    public WebConfigParamMeta(WebConfigParamMeta pm)
+    {
+        _name = pm._name;
+        _fieldName = pm._fieldName;    
+        _description = pm._description;
+        _longDescription = pm._longDescription;
+        _defaultValue = pm._defaultValue;
+        _expectedValues = pm._expectedValues;
+        _since = pm._since;
+    }
+    
+    /**
+     * Write this model out as xml.
+     */
+    public static void writeXml(XmlWriter out, WebConfigParamMeta pm)
+    {
+        out.beginElement("webConfigParam");
+        out.writeElement("name", pm._name);
+        out.writeElement("fieldName", pm._fieldName);
+        out.writeElement("desc", pm._description);
+        out.writeElement("longDesc", pm._longDescription);
+        out.writeElement("defaultValue", pm._defaultValue);
+        out.writeElement("expectedValues", pm._expectedValues);
+        out.writeElement("sourceClassName", pm._sourceClassName);
+        out.writeElement("since", pm._since);
+        out.endElement("webConfigParam");
+    }
+
+    /**
+     * Add digester rules to repopulate a Model instance from an xml file.
+     */
+    public static void addXmlRules(Digester digester, String prefix)
+    {
+        String newPrefix = prefix + "/webConfigParam";
+
+        digester.addObjectCreate(newPrefix, WebConfigParamMeta.class);
+        digester.addSetNext(newPrefix, "addWebConfigParam");
+
+        digester.addBeanPropertySetter(newPrefix + "/name");
+        digester.addBeanPropertySetter(newPrefix + "/fieldName");
+        digester.addBeanPropertySetter(newPrefix + "/sourceClassName");
+        digester.addBeanPropertySetter(newPrefix + "/since");
+        digester.addBeanPropertySetter(newPrefix + "/desc", "description");
+        digester.addBeanPropertySetter(newPrefix + "/longDesc", "longDescription");
+        digester.addBeanPropertySetter(newPrefix + "/defaultValue", "defaultValue");
+        digester.addBeanPropertySetter(newPrefix + "/expectedValues", "expectedValues");
+        MethodSignatureMeta.addXmlRules(digester, newPrefix);
+        
+    }
+
+    /**
+     * Merge the data in the specified other property into this one, throwing an
+     * exception if there is an incompatibility.
+     */
+    public void merge(WebConfigParamMeta other)
+    {
+        // Merge className does not harm, since you cannot
+        //use polymorphism on a jsf component.  
+        _name = ModelUtils.merge(this._name, other._name);
+        _fieldName = ModelUtils.merge(this._fieldName, other._fieldName);
+        _description = ModelUtils.merge(this._description, other._description);
+        _longDescription = ModelUtils.merge(this._longDescription, other._longDescription);
+        _defaultValue = ModelUtils.merge(this._defaultValue, other._defaultValue);
+        _sourceClassName = ModelUtils.merge(this._sourceClassName, other._sourceClassName);
+        _since = ModelUtils.merge(this._since, other._since);
+        setExpectedValues(ModelUtils.merge(this._expectedValues, other._expectedValues));
+    }
+
+    /**
+     * Set the name that users refer to this property by.
+     * <p>
+     * This sets the name of xml tag attributes, and the base names of generated
+     * getter/setter methods.
+     */
+    public void setName(String name)
+    {
+        _name = name;
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public void setDescription(String desc)
+    {
+        _description = desc;
+    }
+
+    public String getDescription()
+    {
+        return _description;
+    }
+
+    public void setLongDescription(String desc)
+    {
+        _longDescription = desc;
+    }
+
+    public String getLongDescription()
+    {
+        return _longDescription;
+    }
+    
+    /**
+     * Sets the default value of this attribute.
+     *
+     * @param defaultValue  the attribute default value
+     */
+    public void setDefaultValue(String defaultValue)
+    {
+      _defaultValue = defaultValue;
+    }
+
+    /**
+     * Returns the default value of this attribute.
+     *
+     * @return  the attribute default value
+     */
+    public String getDefaultValue()
+    {
+      return _defaultValue;
+    }
+    
+    public void setFieldName(String fieldName)
+    {
+      _fieldName = fieldName;
+    }
+
+    public String getFieldName()
+    {
+      return _fieldName;
+    }
+
+    public void setExpectedValues(String expectedValues)
+    {
+        _expectedValues = expectedValues;
+    }
+
+    public String getExpectedValues()
+    {
+        return _expectedValues;
+    }
+    
+    /**
+     * Utility method to return just the packagename part of the className
+     * attribute.
+     */
+    public String getSourcePackageName()
+    {
+        return StringUtils.substring(getSourceClassName(), 0, StringUtils.lastIndexOf(getSourceClassName(), '.'));
+    }
+
+    /**
+     * Return the className of the real java class from which this metadata was gathered.
+     * <p>
+     * This is mostly used for documentation. However when generating code in "template mode",
+     * this is used to locate the original class in order to find the source code to copy.
+     * It is also used for some reason in MakeComponentsMojo when determining whether to
+     * generate a class or not - this is probably wrong.
+     */
+    public String getSourceClassName()
+    {
+        return _sourceClassName;
+    }
+
+    public void setSourceClassName(String sourceClassName)
+    {
+        this._sourceClassName = sourceClassName;
+    }
+    
+    public String getSince()
+    {
+        return _since;
+    }
+
+    public void setSince(String since)
+    {
+        _since = since;
+    }
+}

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=833808&r1=833807&r2=833808&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 02:37:36 2009
@@ -243,4 +243,13 @@
             parentClazz = parentClazz.getSuperJavaClass();
         }
     }
+    
+    public static String evaluateParameterInitializationExpression(String value)
+    {
+        if (value.charAt(0) == '"' && value.charAt(value.length()-1) == '"' && value.indexOf('+') == -1)
+        {
+            return value.substring(1,value.length()-1);
+        }            
+        return value;
+    }
 }

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=833808&r1=833807&r2=833808&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 02:37:36 2009
@@ -52,6 +52,8 @@
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.RendererMeta;
 import org.apache.myfaces.buildtools.maven2.plugin.builder.model.TagMeta;
 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;
@@ -103,6 +105,8 @@
     private static final String DOC_FACELET_TAG_ATTRIBUTE = "JSFFaceletAttribute";
     private static final String DOC_FACELET_TAG_ATTRIBUTES = "JSFFaceletAttributes";
     
+    private static final String DOC_WEB_CONFIG_PARAM = "JSFWebConfigParam";
+    
     private static class JavaClassComparator implements Comparator
     {
         public int compare(Object arg0, Object arg1)
@@ -171,7 +175,16 @@
         
         for (Iterator i = sourceDirs.iterator(); i.hasNext();)
         {
-            File srcDir = new File((String) i.next());
+            Object dir = i.next();
+            File srcDir = null;
+            if (dir instanceof File)
+            {
+                srcDir = (File) dir;
+            }
+            else         
+            {
+                new File((String) i.next());
+            }
             
             //Scan all files on directory and add to builder
             addFileToJavaDocBuilder(builder, selector, srcDir);
@@ -461,8 +474,7 @@
      * Set the parentClassName and interfaceClassNames properties of the
      * provided modelItem object.
      */
-    private void processClass(Map processedClasses, JavaClass clazz, Model model)
-            throws MojoExecutionException
+    private void processClass(Map processedClasses, JavaClass clazz, Model model) throws MojoExecutionException
     {
         if (processedClasses.containsKey(clazz.getFullyQualifiedName()))
         {
@@ -488,10 +500,40 @@
         processedClasses.put(clazz.getFullyQualifiedName(), clazz);
 
         log.info("processed class:" + clazz.getFullyQualifiedName());
-
         DocletTag tag;
         Annotation anno;
-
+        WebConfigMeta webConfig = model.findWebConfigsByModelId(model.getModelId());
+        boolean createWebConfig = false;
+        if (webConfig == null)
+        {
+            createWebConfig = true;
+            webConfig = new WebConfigMeta();
+            webConfig.setModelId(model.getModelId());
+        }
+        //Web Config Params
+        JavaField[] fields = clazz.getFields();
+        for (int i = 0; i < fields.length; ++i)
+        {
+            JavaField field = fields[i];
+            tag = field.getTagByName(DOC_WEB_CONFIG_PARAM);
+            if (tag != null)
+            {
+                Map props = tag.getNamedParameterMap();
+                processWebConfigParam(props, (AbstractJavaEntity)tag.getContext(), 
+                        clazz, field, webConfig);
+            }
+            anno = getAnnotation(field, DOC_WEB_CONFIG_PARAM);
+            if (anno != null)
+            {
+                Map props = anno.getNamedParameterMap();
+                processWebConfigParam(props, (AbstractJavaEntity)anno.getContext(),
+                        clazz, field, webConfig);
+            }
+        }
+        if (webConfig.webConfigParametersSize() > 0 && createWebConfig)
+        {
+            model.addWebConfig(webConfig);
+        }
         // converters
         tag = clazz.getTagByName(DOC_CONVERTER, false);
         if (tag != null)
@@ -505,7 +547,6 @@
             Map props = anno.getNamedParameterMap();
             processConverter(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
         }
-
         // validators
         tag = clazz.getTagByName(DOC_VALIDATOR, false);
         if (tag != null)
@@ -519,7 +560,6 @@
             Map props = anno.getNamedParameterMap();
             processValidator(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
         }
-
         // components
         tag = clazz.getTagByName(DOC_COMPONENT, false);
         if (tag != null)
@@ -533,7 +573,6 @@
             Map props = anno.getNamedParameterMap();
             processComponent(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
         }
-        
         //tag
         tag = clazz.getTagByName(DOC_TAG, false);
         if (tag != null)
@@ -594,10 +633,8 @@
             Map props = anno.getNamedParameterMap();
             processRenderKit(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
         }
-                
         // renderer
         DocletTag [] tags = clazz.getTagsByName(DOC_RENDERER, false);
-        
         for (int i = 0; i < tags.length; i++)
         {
             tag = tags[i];
@@ -607,14 +644,12 @@
                 processRenderer(props, (AbstractJavaEntity)tag.getContext(), clazz, model);
             }
         }
-        
         anno = getAnnotation(clazz, DOC_RENDERER);
         if (anno != null)
         {
             Map props = anno.getNamedParameterMap();
             processRenderer(props, (AbstractJavaEntity)anno.getContext(), clazz, model);
         }
-        
         anno = getAnnotation(clazz, DOC_RENDERERS);
         if (anno != null)
         {
@@ -815,6 +850,36 @@
         modelItem.setInterfaceClassNames(ifaceNames);
     }
     
+    private void processWebConfigParam(Map props, AbstractJavaEntity ctx,
+            JavaClass clazz, JavaField field, WebConfigMeta webConfig)
+    {
+        String longDescription = field.getComment();
+        String descDflt = QdoxHelper.getFirstSentence(longDescription);
+        if ((descDflt == null) || (descDflt.length() < 2))
+        {
+            descDflt = "no description";
+        }
+        String shortDescription = getString(clazz, "desc", props, descDflt);
+        
+        String name = getString(clazz, "name", props, 
+                QdoxHelper.evaluateParameterInitializationExpression(
+                        field.getInitializationExpression()));
+        String defaultValue = getString(clazz,"defaultValue",props,null);
+        String expectedValues = getString(clazz,"expectedValues",props,null);
+        String since = getString(clazz,"since",props,null);
+        
+        WebConfigParamMeta wcp = new WebConfigParamMeta();
+        wcp.setName(name);
+        wcp.setFieldName(field.getName());
+        wcp.setSourceClassName(clazz.getFullyQualifiedName());
+        wcp.setDefaultValue(defaultValue);
+        wcp.setExpectedValues(expectedValues);
+        wcp.setLongDescription(longDescription);
+        wcp.setDescription(shortDescription);
+        wcp.setSince(since);
+        webConfig.addWebConfigParam(wcp);
+    }
+    
     private void processConverter(Map props, AbstractJavaEntity ctx,
             JavaClass clazz, Model model)
     {

Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-web-config.vm
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-web-config.vm?rev=833808&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-web-config.vm (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/META-INF/xdoc-web-config.vm Sun Nov  8 02:37:36 2009
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<document>
+ <properties>
+  <title>Web Context Params</title>
+ </properties>
+ <body>
+  <section name="Summary">
+  <p>
+  Below is the list of available web context parameters supported: 
+  </p>
+  </section>
+#if ($baseContent)
+$baseContent
+#end
+  <section name="Web Context Parameters">
+#set ($webConfigList = ${model.getWebConfigs()})
+#foreach( $webConfig in $webConfigList )
+#if ($modelIds.contains($webConfig.modelId))
+<p>Artifact Id: $webConfig.modelId</p>
+#set ($webConfigParamList = ${webConfig.getWebConfigParametersList()})
+<table>
+ <tr>
+  <th>Name</th>
+  <th>Default Value</th>
+  <th>Expected Values</th>
+  <th>Since</th>
+  <th>Description</th>
+  <th>Source Class</th>
+ </tr>
+#foreach( $webConfigParam in $webConfigParamList )
+ <tr>
+  <td>$webConfigParam.name</td>
+#if ($webConfigParam.defaultValue)
+  <td>$webConfigParam.defaultValue</td>
+#else
+  <td></td>
+#end
+#if ($webConfigParam.expectedValues)
+  <td>$webConfigParam.expectedValues</td>
+#else
+  <td></td>
+#end
+#if ($webConfigParam.since)
+  <td>$webConfigParam.since</td>
+#else
+  <td></td>
+#end
+#if ($webConfigParam.longDescription)
+  <td>$webConfigParam.longDescription</td>
+#else
+  <td></td>
+#end
+  <td>$webConfigParam.sourceClassName</td>
+ </tr>
+#end
+</table>
+#end
+#end
+  </section>
+ </body> 
+</document>
\ No newline at end of file