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 2011/02/24 23:25:25 UTC
svn commit: r1074320 - 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/myfac...
Author: lu4242
Date: Thu Feb 24 22:25:24 2011
New Revision: 1074320
URL: http://svn.apache.org/viewvc?rev=1074320&view=rev
Log:
MYFACES-3032 Include composite component information on documentation generated by myfaces-builder-plugin
Added:
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/CompositeComponentModelBuilder.java
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_Location.java
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttribute.java
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttributes.java
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/
myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/default.dtd
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/ModelParams.java
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/Model.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=1074320&r1=1074319&r2=1074320&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 Thu Feb 24 22:25:24 2011
@@ -264,6 +264,18 @@ public class BuildMetaDataMojo extends A
private File generatedSourceDirectory;
/**
+ * The directory where there are the composite component templates
+ *
+ * @parameter expression="src/main/resources/META-INF/resources"
+ */
+ private File compositeComponentDirectory;
+
+ /**
+ * @parameter
+ */
+ private Map compositeComponentLibraries;
+
+ /**
* Create a metadata file containing information imported from other projects
* plus data extracted from annotated classes in this project.
*/
@@ -331,6 +343,12 @@ public class BuildMetaDataMojo extends A
parameters.setSourceDirs(sourceDirs);
+ List compositeComponentDirs = new ArrayList();
+ compositeComponentDirs.add(compositeComponentDirectory);
+ parameters.setCompositeComponentDirectories(compositeComponentDirs);
+
+ parameters.setCompositeComponentLibraries(compositeComponentLibraries);
+
buildModel(model, project, parameters);
resolveReplacePackage(model);
@@ -479,22 +497,23 @@ public class BuildMetaDataMojo extends A
{
if (component.getName() != null)
{
- if (component.getDescription() == null)
+ if (!component.isComposite().booleanValue())
{
- throw new MojoExecutionException(
- "Missing mandatory property on component " + component.getClassName()
- + " [sourceClass=" + component.getSourceClassName() + "]: description");
- }
-
- if (component.getType() == null)
- {
- throw new MojoExecutionException(
- "Missing mandatory property on component " + component.getClassName()
- + " [sourceClass=" + component.getSourceClassName() + "]: type");
+ if (component.getDescription() == null)
+ {
+ throw new MojoExecutionException(
+ "Missing mandatory property on component " + component.getClassName()
+ + " [sourceClass=" + component.getSourceClassName() + "]: description");
+ }
+ if (component.getType() == null)
+ {
+ throw new MojoExecutionException(
+ "Missing mandatory property on component " + component.getClassName()
+ + " [sourceClass=" + component.getSourceClassName() + "]: type");
+ }
+ // this is a concrete component, so it must have a family property
+ validateComponentFamily(model, component);
}
-
- // this is a concrete component, so it must have a family property
- validateComponentFamily(model, component);
}
}
Modified: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/ModelParams.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/ModelParams.java?rev=1074320&r1=1074319&r2=1074320&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/ModelParams.java (original)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/ModelParams.java Thu Feb 24 22:25:24 2011
@@ -19,6 +19,7 @@
package org.apache.myfaces.buildtools.maven2.plugin.builder;
import java.util.List;
+import java.util.Map;
public class ModelParams
{
@@ -26,7 +27,11 @@ public class ModelParams
private String excludes;
- private List sources;
+ private List sources;
+
+ private List compositeComponentDirectories;
+
+ private Map compositeComponentLibraries;
public ModelParams()
{
@@ -56,4 +61,20 @@ public class ModelParams
{
this.sources = sources;
}
+ public List getCompositeComponentDirectories()
+ {
+ return compositeComponentDirectories;
+ }
+ public Map getCompositeComponentLibraries()
+ {
+ return compositeComponentLibraries;
+ }
+ public void setCompositeComponentDirectories(List compositeComponentDirectories)
+ {
+ this.compositeComponentDirectories = compositeComponentDirectories;
+ }
+ public void setCompositeComponentLibraries(Map compositeComponentLibraries)
+ {
+ this.compositeComponentLibraries = compositeComponentLibraries;
+ }
}
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=1074320&r1=1074319&r2=1074320&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 Thu Feb 24 22:25:24 2011
@@ -55,6 +55,9 @@ public class ComponentMeta extends ViewE
private Boolean _clientBehaviorHolder;
private Boolean _composite;
+ private String _ccLibraryName;
+ private String _ccResourceName;
+
private Boolean _generatedComponentClass;
private Boolean _generatedTagClass;
@@ -88,6 +91,8 @@ public class ComponentMeta extends ViewE
out.writeElement("template", _template);
out.writeElement("clientBehaviorHolder", _clientBehaviorHolder);
out.writeElement("composite", _composite);
+ out.writeElement("ccLibraryName", _ccLibraryName);
+ out.writeElement("ccResourceName", _ccResourceName);
for (Iterator i = _facets.values().iterator(); i.hasNext();)
{
@@ -145,6 +150,8 @@ public class ComponentMeta extends ViewE
digester.addBeanPropertySetter(newPrefix + "/template");
digester.addBeanPropertySetter(newPrefix + "/clientBehaviorHolder");
digester.addBeanPropertySetter(newPrefix + "/composite");
+ digester.addBeanPropertySetter(newPrefix + "/ccLibraryName");
+ digester.addBeanPropertySetter(newPrefix + "/ccResourceName");
FacetMeta.addXmlRules(digester, newPrefix);
ListenerMeta.addXmlRules(digester, newPrefix);
@@ -565,6 +572,42 @@ public class ComponentMeta extends ViewE
_composite = composite;
}
+ /**
+ *
+ * @since 1.0.9
+ */
+ public String getCcLibraryName()
+ {
+ return _ccLibraryName;
+ }
+
+ /**
+ *
+ * @since 1.0.9
+ */
+ public void setCcLibraryName(String ccLibraryName)
+ {
+ this._ccLibraryName = ccLibraryName;
+ }
+
+ /**
+ *
+ * @since 1.0.9
+ */
+ public String getCcResourceName()
+ {
+ return _ccResourceName;
+ }
+
+ /**
+ *
+ * @since 1.0.9
+ */
+ public void setCcResourceName(String ccResourceName)
+ {
+ this._ccResourceName = ccResourceName;
+ }
+
//THIS METHODS ARE USED FOR VELOCITY TO GET DATA AND GENERATE CLASSES
public Collection getFacetList()
@@ -645,4 +688,5 @@ public class ComponentMeta extends ViewE
}
return ModelUtils.defaultOf(_overrideEventNames,false);
}
+
}
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=1074320&r1=1074319&r2=1074320&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 Thu Feb 24 22:25:24 2011
@@ -53,6 +53,8 @@ public class Model
private Map _faceletTagsByName = new TreeMap();
private Map _webConfigsByModelId = new TreeMap();
+ private Map _componentsByType = new TreeMap();
+
private String _modelId;
/**
@@ -234,6 +236,10 @@ public class Model
{
_components.add(component);
_componentsByClass.put(component.getClassName(), component);
+ if (null != component.getType())
+ {
+ _componentsByType.put(component.getType(), component);
+ }
if (null != component.getTagClass())
{
_componentsByTagClass.put(component.getTagClass(), component);
@@ -265,6 +271,11 @@ public class Model
{
return (ComponentMeta) _componentsByTagClass.get(className);
}
+
+ public ComponentMeta findComponentByType(String componentType)
+ {
+ return (ComponentMeta) _componentsByType.get(componentType);
+ }
/**
* Holds info about a JSF Converter definition
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/CompositeComponentModelBuilder.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/CompositeComponentModelBuilder.java?rev=1074320&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/CompositeComponentModelBuilder.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/CompositeComponentModelBuilder.java Thu Feb 24 22:25:24 2011
@@ -0,0 +1,587 @@
+/*
+ * 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.qdox;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.ModelParams;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ComponentMeta;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.model.FacetMeta;
+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.PropertyMeta;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ext.LexicalHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class CompositeComponentModelBuilder
+{
+ private final Log log = LogFactory.getLog(CompositeComponentModelBuilder.class);
+ public static final String COMPOSITE_LIBRARY_NAME = "http://java.sun.com/jsf/composite";
+
+ public static final String INTERFACE_NAME = "interface";
+ public static final String ATTRIBUTE_NAME = "attribute";
+ public static final String FACET_NAME = "facet";
+
+ private static class CompositeComponentMetadataHandler extends
+ DefaultHandler implements LexicalHandler
+ {
+ private final Model model;
+
+ private final String alias;
+
+ private final String componentName;
+
+ private final String libraryName;
+
+ private final String resourceName;
+
+ private boolean inDocument = false;
+
+ private Locator locator;
+
+ private boolean inCompositeInterface = false;
+
+ private ComponentMeta component = null;
+
+ public CompositeComponentMetadataHandler(Model model, String alias, String componentName,
+ String libraryName, String resourceName)
+ {
+ this.model = model;
+ this.alias = alias;
+ this.componentName = componentName;
+ this.libraryName = libraryName;
+ this.resourceName = resourceName;
+ }
+
+ public void characters(char[] ch, int start, int length) throws SAXException
+ {
+ if (this.inDocument && inCompositeInterface)
+ {
+ }
+ }
+
+ public void comment(char[] ch, int start, int length) throws SAXException
+ {
+ if (this.inDocument && inCompositeInterface)
+ {
+ }
+ }
+
+ protected _TagAttributes createAttributes(Attributes attrs)
+ {
+ int len = attrs.getLength();
+ _TagAttribute[] ta = new _TagAttribute[len];
+ for (int i = 0; i < len; i++)
+ {
+ ta[i] = new _TagAttribute(this.createLocation(), attrs.getURI(i), attrs.getLocalName(i), attrs
+ .getQName(i), attrs.getValue(i));
+ }
+ return new _TagAttributes(ta);
+ }
+
+ protected _Location createLocation()
+ {
+ return new _Location(this.alias, this.locator.getLineNumber(), this.locator.getColumnNumber());
+ }
+
+ public void endCDATA() throws SAXException
+ {
+ if (this.inDocument && inCompositeInterface)
+ {
+ }
+ }
+
+ public void endDocument() throws SAXException
+ {
+ super.endDocument();
+ }
+
+ public void endDTD() throws SAXException
+ {
+ this.inDocument = true;
+ }
+
+ public void endElement(String uri, String localName, String qName) throws SAXException
+ {
+ if (COMPOSITE_LIBRARY_NAME.equals(uri))
+ {
+ if (INTERFACE_NAME.equals(localName))
+ {
+ this.inCompositeInterface=false;
+ this.component = null;
+ }
+ }
+ }
+
+ public void endEntity(String name) throws SAXException
+ {
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException
+ {
+ }
+
+ public void fatalError(SAXParseException e) throws SAXException
+ {
+ if (this.locator != null)
+ {
+ throw new SAXException("Error Traced[line: " + this.locator.getLineNumber() + "] " + e.getMessage());
+ }
+ else
+ {
+ throw e;
+ }
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
+ {
+ if (this.inDocument && inCompositeInterface)
+ {
+ }
+ }
+
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException
+ {
+ String dtd = "org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/default.dtd";
+ /*
+ * if ("-//W3C//DTD XHTML 1.0 Transitional//EN".equals(publicId)) { dtd = "xhtml1-transitional.dtd"; } else
+ * if (systemId != null && systemId.startsWith("file:/")) { return new InputSource(systemId); }
+ */
+ URL url = getResource(dtd);
+ return new InputSource(url.toString());
+ }
+
+ public static URL getResource(String resource)
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
+ if (url == null)
+ {
+ url = ClassUtils.class.getClassLoader().getResource(resource);
+ }
+ return url;
+ }
+
+ public void setDocumentLocator(Locator locator)
+ {
+ this.locator = locator;
+ }
+
+ public void startCDATA() throws SAXException
+ {
+ if (this.inDocument && inCompositeInterface)
+ {
+ }
+ }
+
+ public void startDocument() throws SAXException
+ {
+ this.inDocument = true;
+ }
+
+ public void startDTD(String name, String publicId, String systemId) throws SAXException
+ {
+ // metadata does not require output doctype
+ this.inDocument = false;
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
+ {
+ if (COMPOSITE_LIBRARY_NAME.equals(uri))
+ {
+ if (INTERFACE_NAME.equals(localName))
+ {
+ this.inCompositeInterface=true;
+ _TagAttributes attrs = this.createAttributes(attributes);
+
+ this.component = null;
+ //1. Use componentType attribute to find the class in the model.
+ _TagAttribute type = attrs.get("componentType");
+ boolean setComponentType = false;
+ if (type != null)
+ {
+ this.component = model.findComponentByType(type.getValue());
+ if (this.component == null)
+ {
+ //Component not found, set component type when created
+ setComponentType = true;
+ }
+ }
+ if (this.component == null)
+ {
+ //2. Use libraryName + '.' + componentName
+ this.component = model.findComponentByClassName(alias);
+ }
+ if (this.component == null)
+ {
+ //No class bound, create
+ this.component = new ComponentMeta();
+ // Set as class name the assigned by Application.createResource,
+ // even if not exists.
+ this.component.setClassName(alias);
+ }
+ //componentType
+ if (setComponentType)
+ {
+ component.setType(type.getValue());
+ }
+
+ //Mark it as composite
+ component.setComposite(Boolean.TRUE);
+
+ component.setCcLibraryName(libraryName);
+
+ component.setCcResourceName(resourceName);
+
+ //name: Force name to be the one derived by the composite component
+ component.setName(componentName);
+
+ //shortDescription
+ _TagAttribute shortDescription = attrs.get("shortDescription");
+ if (shortDescription != null)
+ {
+ component.setDescription(shortDescription.getValue());
+ }
+
+ // Ignored properties:
+ // displayName
+ // preferred
+ // expert
+ // hidden
+ model.addComponent(component);
+ }
+ if (ATTRIBUTE_NAME.equals(localName))
+ {
+ _TagAttributes attrs = this.createAttributes(attributes);
+ //name
+ String name = attrs.get("name").getValue();
+
+ PropertyMeta property = component.getProperty(name);
+
+ if (property == null)
+ {
+ property = new PropertyMeta();
+ component.addProperty(property);
+ }
+
+ //default
+ _TagAttribute defaultValue = attrs.get("default");
+ if (defaultValue != null)
+ {
+ property.setDefaultValue(defaultValue.getValue());
+ }
+ //required
+ _TagAttribute required = attrs.get("required");
+ if (required != null)
+ {
+ property.setRequired(Boolean.valueOf(required.getValue()));
+ }
+ //shortDescription
+ _TagAttribute shortDescription = attrs.get("shortDescription");
+ if (shortDescription != null)
+ {
+ property.setDescription(shortDescription.getValue());
+ }
+ //type
+ _TagAttribute type = attrs.get("type");
+ if (type != null)
+ {
+ property.setDeferredValueType(type.getValue());
+ }
+ //method-signature
+ _TagAttribute methodSignature = attrs.get("method-signature");
+ if (methodSignature != null)
+ {
+ String signature = methodSignature.getValue();
+ try
+ {
+ MethodSignatureMeta msm = new MethodSignatureMeta();
+ List paramsList = _getParameters(signature);
+ for (int i = 0; i < paramsList.size(); i++)
+ {
+ msm.addParameterType((String)paramsList.get(i));
+ }
+ msm.setReturnType(_getReturnType(signature));
+ property.setMethodBindingSignature(msm);
+ }
+ catch (Exception e)
+ {
+ throw new SAXException(e);
+ }
+ }
+
+ // Ignored properties:
+ // preferred
+ // expert
+ // hidden
+ // targets
+ // displayName
+ }
+ if (FACET_NAME.equals(localName))
+ {
+ _TagAttributes attrs = this.createAttributes(attributes);
+
+ String name = attrs.get("name").getValue();
+
+ FacetMeta facet = component.getFacet(name);
+
+ if (facet == null)
+ {
+ facet = new FacetMeta();
+ facet.setName(name);
+ component.addFacet(facet);
+ }
+
+ //required
+ _TagAttribute required = attrs.get("required");
+ if (required != null)
+ {
+ facet.setRequired(Boolean.valueOf(required.getValue()));
+ }
+
+ //shortDescription
+ _TagAttribute shortDescription = attrs.get("shortDescription");
+ if (shortDescription != null)
+ {
+ facet.setDescription(shortDescription.getValue());
+ }
+
+ // Ignored properties:
+ // preferred
+ // expert
+ // hidden
+ // displayName
+ }
+ }
+ }
+
+ private String _getReturnType(String signature) throws Exception
+ {
+ int endName = signature.indexOf('(');
+ if (endName < 0)
+ {
+ throw new Exception("Invalid method signature:" + signature);
+ }
+ int end = signature.lastIndexOf(' ', endName);
+ if (end < 0)
+ {
+ throw new Exception("Invalid method signature:" + signature);
+ }
+ return signature.substring(0,end);
+ }
+
+ /**
+ * Get the parameters types from the function signature.
+ *
+ * @return An array of parameter class names
+ */
+ private List _getParameters(String signature) throws Exception
+ {
+ ArrayList params = new ArrayList();
+ // Signature is of the form
+ // <return-type> S <method-name S? '('
+ // < <arg-type> ( ',' <arg-type> )* )? ')'
+ int start = signature.indexOf('(') + 1;
+ boolean lastArg = false;
+ while (true)
+ {
+ int p = signature.indexOf(',', start);
+ if (p < 0)
+ {
+ p = signature.indexOf(')', start);
+ if (p < 0)
+ {
+ throw new Exception("Invalid method signature:"+signature);
+ }
+ lastArg = true;
+ }
+ String arg = signature.substring(start, p).trim();
+ if (!"".equals(arg))
+ {
+ params.add(arg);
+ }
+ if (lastArg)
+ {
+ break;
+ }
+ start = p + 1;
+ }
+ return params;
+ }
+
+ public void startEntity(String name) throws SAXException
+ {
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException
+ {
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException
+ {
+ if (this.inDocument && inCompositeInterface)
+ {
+ }
+ }
+ }
+
+ public void buildModel(Model model, ModelParams parameters)
+ {
+ if (parameters.getCompositeComponentDirectories() != null &&
+ parameters.getCompositeComponentLibraries() != null &&
+ !parameters.getCompositeComponentDirectories().isEmpty() &&
+ !parameters.getCompositeComponentLibraries().isEmpty())
+ {
+ for (Iterator it = parameters.getCompositeComponentDirectories().iterator(); it.hasNext();)
+ {
+ Object odir = it.next();
+ File dir = null;
+ if (odir instanceof File)
+ {
+ dir = (File) odir;
+ }
+ else
+ {
+ dir = new File(odir.toString());
+ }
+ if (dir != null && dir.exists())
+ {
+ for (Iterator it2 = parameters.getCompositeComponentLibraries().entrySet().iterator();
+ it2.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) it2.next();
+ String shortTagLibraryName = (String) entry.getKey();
+ String libraryName = (String) entry.getValue();
+ File dirToScan = new File(dir,libraryName);
+ if (dirToScan != null && dirToScan.exists() && dirToScan.isDirectory() )
+ {
+ FileFilter fileFilter = new FileFilter()
+ {
+ public boolean accept(File file)
+ {
+ return file.getName().endsWith(".xhtml");
+ }
+ };
+ File[] files = dirToScan.listFiles(fileFilter);
+ if (files != null)
+ {
+ for (int i = 0; i < files.length; i++)
+ {
+ String componentName = files[i].getName().substring(
+ 0, files[i].getName().length()-6);
+ try
+ {
+ doParseMetadata(model, files[i].toURL(),
+ shortTagLibraryName, libraryName, files[i].getName(),
+ componentName, libraryName+'.'+ componentName);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Error while processing composite component: "+
+ libraryName+'/'+componentName, e);
+ }
+ catch (IOException e)
+ {
+ log.error("Error while processing composite component: "+
+ libraryName+'/'+componentName, e);
+ }
+ catch (SAXException e)
+ {
+ log.error("Error while processing composite component: "+
+ libraryName+'/'+componentName, e);
+ }
+ catch (ParserConfigurationException e)
+ {
+ log.error("Error while processing composite component: "+
+ libraryName+'/'+componentName, e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void doParseMetadata(Model model,
+ URL src, String shortLibraryName,
+ String libraryName, String resourceName, String componentName, String alias)
+ throws IOException, SAXException,
+ ParserConfigurationException
+ {
+ InputStream is = null;
+ try
+ {
+ is = new BufferedInputStream(src.openStream(), 1024);
+ CompositeComponentMetadataHandler handler =
+ new CompositeComponentMetadataHandler(model, alias, shortLibraryName + ':' +
+ componentName, libraryName, resourceName);
+ SAXParser parser = this.createSAXParser(handler);
+ parser.parse(is, handler);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ is.close();
+ }
+ }
+ }
+
+ private final SAXParser createSAXParser(DefaultHandler handler)
+ throws SAXException, ParserConfigurationException
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ factory.setFeature("http://xml.org/sax/features/namespace-prefixes",
+ true);
+ factory.setFeature("http://xml.org/sax/features/validation", false);
+ factory.setValidating(false);
+ SAXParser parser = factory.newSAXParser();
+ XMLReader reader = parser.getXMLReader();
+ reader.setProperty("http://xml.org/sax/properties/lexical-handler",
+ handler);
+ reader.setErrorHandler(handler);
+ reader.setEntityResolver(handler);
+ return parser;
+ }
+}
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=1074320&r1=1074319&r2=1074320&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 Thu Feb 24 22:25:24 2011
@@ -118,13 +118,14 @@ public class QdoxModelBuilder implements
JavaClass[] classes = QdoxHelper.getSourceClasses(parameters.getSourceDirs(),
parameters.getIncludes(), parameters.getExcludes());
buildModel(model, parameters.getSourceDirs(), classes);
+ CompositeComponentModelBuilder qccmb = new CompositeComponentModelBuilder();
+ qccmb.buildModel(model, parameters);
}
protected void buildModel(Model model, List sourceDirs, JavaClass[] classes)
throws MojoExecutionException
{
String currModelId = model.getModelId();
-
// Sort the class array so that they are processed in a
// predictable order, regardless of how the source scanning
// returned them.
@@ -135,7 +136,6 @@ public class QdoxModelBuilder implements
JavaClass clazz = classes[i];
processClass(processedClasses, clazz, model);
}
-
// Post-process the list of components which we added in this run.
// Note that model has all the inherited components in it too, so
// we need to skip them.
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_Location.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/_Location.java?rev=1074320&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_Location.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_Location.java Thu Feb 24 22:25:24 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.qdox;
+
+import java.io.Serializable;
+
+public class _Location implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private int column;
+ private int line;
+ private String path;
+
+ public _Location(String path, int line, int column)
+ {
+ this.column = column;
+ this.line = line;
+ this.path = path;
+ }
+
+ public int getColumn()
+ {
+ return column;
+ }
+
+ public int getLine()
+ {
+ return line;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public String toString()
+ {
+ return path + " at line " + line + " and column " + column;
+ }
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttribute.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/_TagAttribute.java?rev=1074320&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttribute.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttribute.java Thu Feb 24 22:25:24 2011
@@ -0,0 +1,115 @@
+/*
+ * 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.qdox;
+
+
+/**
+ * Representation of a Tag's attribute in a Facelet File
+ *
+ * @author Jacob Hookom
+ * @version $Id: TagAttribute.java,v 1.9 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class _TagAttribute
+{
+ private final String localName;
+
+ private final _Location location;
+
+ private final String namespace;
+
+ private final String qName;
+
+ private final String value;
+
+ private String string;
+
+ public _TagAttribute(_Location location, String ns, String localName, String qName, String value)
+ {
+ this.location = location;
+ this.namespace = ns;
+ this.localName = localName;
+ this.qName = qName;
+ this.value = value;
+ }
+
+ /**
+ * Local name of this attribute
+ *
+ * @return local name of this attribute
+ */
+ public String getLocalName()
+ {
+ return this.localName;
+ }
+
+ /**
+ * The location of this attribute in the FaceletContext
+ *
+ * @return the TagAttribute's location
+ */
+ public _Location getLocation()
+ {
+ return this.location;
+ }
+
+ /**
+ * The resolved Namespace for this attribute
+ *
+ * @return resolved Namespace
+ */
+ public String getNamespace()
+ {
+ return this.namespace;
+ }
+
+ /**
+ * The qualified name for this attribute
+ *
+ * @return the qualified name for this attribute
+ */
+ public String getQName()
+ {
+ return this.qName;
+ }
+
+ /**
+ * Return the literal value of this attribute
+ *
+ * @return literal value
+ */
+ public String getValue()
+ {
+ return this.value;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ if (this.string == null)
+ {
+ this.string = this.location + " " + this.qName + "=\"" + this.value + "\"";
+ }
+ return this.string;
+ }
+
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttributes.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/_TagAttributes.java?rev=1074320&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttributes.java (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/_TagAttributes.java Thu Feb 24 22:25:24 2011
@@ -0,0 +1,208 @@
+/*
+ * 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.qdox;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A set of TagAttributes, usually representing all attributes on a Tag.
+ *
+ * TODO: PROFILE - Explore the possibility of using HashMap instead of sorted arrays.
+ * The footprint should be higher, but the instanciation and access speed should be faster
+ * Instanciation: from O(n log n) to O(1)
+ * Access: from O(log n) to O(1)
+ *
+ * @see org.apache.myfaces.view.facelets.tag.Tag
+ * @see org.apache.myfaces.view.facelets.tag.TagAttributeImpl
+ * @author Jacob Hookom
+ * @version $Id: TagAttributes.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class _TagAttributes
+{
+ private final static _TagAttribute[] EMPTY = new _TagAttribute[0];
+
+ private final _TagAttribute[] _attributes;
+
+ private final String[] _namespaces;
+
+ private final List _nsattrs;
+
+ /**
+ *
+ */
+ public _TagAttributes(_TagAttribute[] attrs)
+ {
+ _attributes = attrs;
+
+ // grab namespaces
+ Set set = new HashSet();
+ for (int i = 0; i < _attributes.length; i++)
+ {
+ _TagAttribute attribute = _attributes[i];
+ set.add(attribute.getNamespace());
+ }
+
+ _namespaces = (String[]) set.toArray(new String[set.size()]);
+ Arrays.sort(_namespaces);
+
+ // assign attrs
+ int size = _namespaces.length;
+ //List<List<TagAttribute>> temp = new ArrayList<List<TagAttribute>>(size);
+ List temp = new ArrayList(size);
+ for (int i = 0; i < size; i++)
+ {
+ //temp.add(new ArrayList<TagAttribute>());
+ temp.add(new ArrayList());
+ }
+
+ for (int i = 0; i < _attributes.length; i++)
+ {
+ _TagAttribute attribute = _attributes[i];
+ ((List)temp.get(Arrays.binarySearch(_namespaces, attribute.getNamespace()))).add(attribute);
+ }
+
+ //_nsattrs = new ArrayList<TagAttribute[]>(size);
+ _nsattrs = new ArrayList(size);
+
+ for (int i = 0; i < temp.size(); i++)
+ {
+ List l = (List) temp.get(i);
+ _nsattrs.add(l.toArray(new _TagAttribute[l.size()]));
+ }
+ }
+
+ /**
+ * Return an array of all TagAttributes in this set
+ *
+ * @return a non-null array of TagAttributes
+ */
+ public _TagAttribute[] getAll()
+ {
+ return _attributes;
+ }
+
+ /**
+ * Using no namespace, find the TagAttribute
+ *
+ * @see #get(String, String)
+ * @param localName
+ * tag attribute name
+ * @return the TagAttribute found, otherwise null
+ */
+ public _TagAttribute get(String localName)
+ {
+ return get("", localName);
+ }
+
+ /**
+ * Find a TagAttribute that matches the passed namespace and local name.
+ *
+ * @param ns
+ * namespace of the desired attribute
+ * @param localName
+ * local name of the attribute
+ * @return a TagAttribute found, otherwise null
+ */
+ public _TagAttribute get(String ns, String localName)
+ {
+ if (ns != null && localName != null)
+ {
+ int idx = Arrays.binarySearch(_namespaces, ns);
+ if (idx >= 0)
+ {
+ _TagAttribute[] array = (_TagAttribute[]) _nsattrs.get(idx);
+ for (int i = 0; i < array.length ; i++)
+ {
+ _TagAttribute attribute = array[i];
+ if (localName.equals(attribute.getLocalName()))
+ {
+ return attribute;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get all TagAttributes for the passed namespace
+ *
+ * @param namespace
+ * namespace to search
+ * @return a non-null array of TagAttributes
+ */
+ public _TagAttribute[] getAll(String namespace)
+ {
+ int idx = 0;
+ if (namespace == null)
+ {
+ idx = Arrays.binarySearch(_namespaces, "");
+ }
+ else
+ {
+ idx = Arrays.binarySearch(_namespaces, namespace);
+ }
+
+ if (idx >= 0)
+ {
+ return (_TagAttribute[]) _nsattrs.get(idx);
+ }
+
+ return EMPTY;
+ }
+
+ /**
+ * A list of Namespaces found in this set
+ *
+ * @return a list of Namespaces found in this set
+ */
+ public String[] getNamespaces()
+ {
+ return _namespaces;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ for (int i = 0; i < _attributes.length; i++)
+ {
+ _TagAttribute attribute = _attributes[i];
+ sb.append(attribute);
+ sb.append(' ');
+ }
+
+ if (sb.length() > 1)
+ {
+ sb.setLength(sb.length() - 1);
+ }
+
+ return sb.toString();
+ }
+}
Added: myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/default.dtd
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/default.dtd?rev=1074320&view=auto
==============================================================================
--- myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/default.dtd (added)
+++ myfaces/myfaces-build-tools/trunk/maven2-plugins/myfaces-builder-plugin/src/main/resources/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/default.dtd Thu Feb 24 22:25:24 2011
@@ -0,0 +1,22 @@
+<!--
+ * 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.
+-->
+<!-- DTD for facelets class in
+org.apache.myfaces.view.facelets.compiler.SAXCompiler
+-->
+<!ELEMENT default ANY>
\ No newline at end of file