You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/04/25 00:51:08 UTC
svn commit: r651448 [2/2] - in
/myfaces/myfaces-build-tools/branches/builder_plugin:
bigtest/core_trunk_11/api/src/main/java/javax/faces/component/
bigtest/core_trunk_11/api/src/main/java/javax/faces/convert/
bigtest/core_trunk_11/api/src/main/java/jav...
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeConfigMojo.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeConfigMojo.java?rev=651448&r1=651447&r2=651448&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeConfigMojo.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeConfigMojo.java Thu Apr 24 15:50:55 2008
@@ -27,20 +27,12 @@
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -58,10 +50,6 @@
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.Xpp3DomWriter;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
//import com.sun.org.apache.xerces.internal.parsers.SAXParser;
@@ -122,6 +110,11 @@
* @parameter expression="faces-config11.vm"
*/
private String templateFile;
+
+ /**
+ * @parameter
+ */
+ private Map params;
/**
* Execute the Mojo.
@@ -134,7 +127,7 @@
modelIds = new ArrayList();
modelIds.add(project.getArtifactId());
}
-
+
Model model = IOUtils.loadModel(new File(buildDirectory,
metadataFile));
new Flattener(model).flatten();
@@ -196,6 +189,18 @@
baseContext.put("model", model);
baseContext.put("modelIds", modelIds);
+
+ if (params != null)
+ {
+ //Load all parameters to the context, so the template can
+ //load it. This allow to generate any config file we want
+ //(faces-config, tld, facelet,....)
+ for (Iterator it = params.keySet().iterator(); it.hasNext();)
+ {
+ String key = (String) it.next();
+ baseContext.put(key,params.get(key));
+ }
+ }
Writer writer = null;
File outFile = null;
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ConverterMeta.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ConverterMeta.java?rev=651448&r1=651447&r2=651448&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ConverterMeta.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ConverterMeta.java Thu Apr 24 15:50:55 2008
@@ -21,6 +21,7 @@
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Logger;
@@ -48,6 +49,12 @@
private String _converterId;
private int _converterClassModifiers;
+
+ //Some converters has its own tag class, so it's necessary to
+ //add some properties for this cases (f:convertNumber or f:convertDateTime)
+ private String _name;
+ private String _bodyContent;
+ private String _tagClass;
protected Map _properties;
/**
@@ -62,6 +69,9 @@
out.writeElement("converterId", cm._converterId);
out.writeElement("desc", cm._description);
out.writeElement("longDesc", cm._longDescription);
+ out.writeElement("name", cm._name);
+ out.writeElement("bodyContent", cm._bodyContent);
+ out.writeElement("tagClass", cm._tagClass);
for (Iterator i = cm._properties.values().iterator(); i.hasNext();)
{
@@ -89,15 +99,25 @@
digester.addBeanPropertySetter(newPrefix + "/desc", "description");
digester.addBeanPropertySetter(newPrefix + "/longDesc",
"longDescription");
+ digester.addBeanPropertySetter(newPrefix + "/name");
+ digester.addBeanPropertySetter(newPrefix + "/bodyContent");
+ digester.addBeanPropertySetter(newPrefix + "/tagClass");
PropertyMeta.addXmlRules(digester, newPrefix);
}
-
+
+ public ConverterMeta()
+ {
+ _properties = new LinkedHashMap();
+ }
/**
* Merge the data in the specified other property into this one, throwing an
* exception if there is an incompatibility.
*/
public void merge(ConverterMeta other)
{
+ _name = ModelUtils.merge(this._name, other._name);
+ _bodyContent = ModelUtils.merge(this._bodyContent, other._bodyContent);
+
_description = ModelUtils.merge(this._description, other._description);
_longDescription = ModelUtils.merge(this._longDescription,
other._longDescription);
@@ -176,6 +196,48 @@
public String getLongDescription()
{
return _longDescription;
+ }
+
+ /**
+ * Sets the name that the user will refer to instances of this component by.
+ * <p>
+ * In JSP tags, this value will be used as the JSP tag name.
+ * <p>
+ * This property is optional; if not set then this Model instance represents
+ * a base class that components can be derived from, but which cannot itself
+ * be instantiated as a component.
+ */
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public void setBodyContent(String bodyContent)
+ {
+ this._bodyContent = bodyContent;
+ }
+
+ public String getBodyContent()
+ {
+ return _bodyContent;
+ }
+
+ /**
+ * Sets the JSP tag handler class for this component.
+ */
+ public void setTagClass(String tagClass)
+ {
+ _tagClass = tagClass;
+ }
+
+ public String getTagClass()
+ {
+ return _tagClass;
}
/**
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ValidatorMeta.java
URL: http://svn.apache.org/viewvc/myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ValidatorMeta.java?rev=651448&r1=651447&r2=651448&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ValidatorMeta.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/model/ValidatorMeta.java Thu Apr 24 15:50:55 2008
@@ -21,6 +21,7 @@
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Logger;
@@ -42,6 +43,11 @@
private String _validatorId;
private int _validatorClassModifiers;
+ private String _name;
+ private String _bodyContent;
+ private String _tagClass;
+
+
protected Map _properties;
/**
@@ -56,6 +62,9 @@
out.writeElement("validatorId", vm._validatorId);
out.writeElement("desc", vm._description);
out.writeElement("longDesc", vm._longDescription);
+ out.writeElement("name", vm._name);
+ out.writeElement("bodyContent", vm._bodyContent);
+ out.writeElement("tagClass", vm._tagClass);
for (Iterator i = vm._properties.values().iterator(); i.hasNext();)
{
@@ -84,8 +93,17 @@
digester.addBeanPropertySetter(newPrefix + "/desc", "description");
digester.addBeanPropertySetter(newPrefix + "/longDesc",
"longDescription");
+ digester.addBeanPropertySetter(newPrefix + "/name");
+ digester.addBeanPropertySetter(newPrefix + "/bodyContent");
+ digester.addBeanPropertySetter(newPrefix + "/tagClass");
+
PropertyMeta.addXmlRules(digester, newPrefix);
}
+
+ public ValidatorMeta()
+ {
+ _properties = new LinkedHashMap();
+ }
/**
* Merge the data in the specified other property into this one, throwing an
@@ -93,6 +111,8 @@
*/
public void merge(ValidatorMeta other)
{
+ _name = ModelUtils.merge(this._name, other._name);
+ _bodyContent = ModelUtils.merge(this._bodyContent, other._bodyContent);
_description = ModelUtils.merge(this._description, other._description);
_longDescription = ModelUtils.merge(this._longDescription,
other._longDescription);
@@ -171,6 +191,48 @@
public String getLongDescription()
{
return _longDescription;
+ }
+
+ /**
+ * Sets the name that the user will refer to instances of this component by.
+ * <p>
+ * In JSP tags, this value will be used as the JSP tag name.
+ * <p>
+ * This property is optional; if not set then this Model instance represents
+ * a base class that components can be derived from, but which cannot itself
+ * be instantiated as a component.
+ */
+ public void setName(String name)
+ {
+ _name = name;
+ }
+
+ public String getName()
+ {
+ return _name;
+ }
+
+ public void setBodyContent(String bodyContent)
+ {
+ this._bodyContent = bodyContent;
+ }
+
+ public String getBodyContent()
+ {
+ return _bodyContent;
+ }
+
+ /**
+ * Sets the JSP tag handler class for this component.
+ */
+ public void setTagClass(String tagClass)
+ {
+ _tagClass = tagClass;
+ }
+
+ public String getTagClass()
+ {
+ return _tagClass;
}
/**
Modified: myfaces/myfaces-build-tools/branches/builder_plugin/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/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java?rev=651448&r1=651447&r2=651448&view=diff
==============================================================================
--- myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java (original)
+++ myfaces/myfaces-build-tools/branches/builder_plugin/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/qdox/QdoxModelBuilder.java Thu Apr 24 15:50:55 2008
@@ -22,6 +22,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.ConverterMeta;
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;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.PropertyMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.RenderKitMeta;
import org.apache.myfaces.buildtools.maven2.plugin.builder.model.RendererMeta;
@@ -436,15 +437,26 @@
String converterId = getString(clazz, "id", props, converterIdDflt);
String converterClass = getString(clazz, "class", props, clazz
.getFullyQualifiedName());
+
+ String componentName = getString(clazz, "name", props, null);
+ String bodyContent = getString(clazz, "bodyContent", props, null);
+ String tagClass = getString(clazz, "tagClass", props, null);
ConverterMeta converter = new ConverterMeta();
+ converter.setName(componentName);
+ converter.setBodyContent(bodyContent);
+ converter.setTagClass(tagClass);
converter.setClassName(converterClass);
converter.setConverterId(converterId);
converter.setDescription(shortDescription);
converter.setLongDescription(longDescription);
+
+ // Now here walk the component looking for property annotations.
+ processComponentProperties(clazz, converter);
+
model.addConverter(converter);
}
-
+
private void processValidator(Map props, AbstractJavaEntity ctx,
JavaClass clazz, Model model)
{
@@ -466,13 +478,24 @@
}
String validatorId = getString(clazz, "id", props, validatorIdDflt);
String validatorClass = getString(clazz, "class", props, clazz
- .getFullyQualifiedName());
+ .getFullyQualifiedName());
+
+ String componentName = getString(clazz, "name", props, null);
+ String bodyContent = getString(clazz, "bodyContent", props, null);
+ String tagClass = getString(clazz, "tagClass", props, null);
ValidatorMeta validator = new ValidatorMeta();
+ validator.setName(componentName);
+ validator.setBodyContent(bodyContent);
+ validator.setTagClass(tagClass);
validator.setClassName(validatorClass);
validator.setValidatorId(validatorId);
validator.setDescription(shortDescription);
validator.setLongDescription(longDescription);
+
+ // Now here walk the component looking for property annotations.
+ processComponentProperties(clazz, validator);
+
model.addValidator(validator);
}
@@ -779,7 +802,7 @@
* component properties, and add metadata about them to the model.
*/
private void processComponentProperties(JavaClass clazz,
- ComponentMeta component)
+ PropertyHolder component)
{
JavaMethod[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; ++i)
@@ -856,7 +879,7 @@
}
private void processInterfaceComponentProperty(Map props, AbstractJavaEntity ctx,
- JavaClass clazz, JavaMethod method, ComponentMeta component){
+ JavaClass clazz, JavaMethod method, PropertyHolder component){
this.processComponentProperty(props, ctx, clazz, method, component);
PropertyMeta property = component.getProperty(methodToPropName(method.getName()));
@@ -873,7 +896,7 @@
}
private void processComponentProperty(Map props, AbstractJavaEntity ctx,
- JavaClass clazz, JavaMethod method, ComponentMeta component)
+ JavaClass clazz, JavaMethod method, PropertyHolder component)
{
Boolean required = getBoolean(clazz, "required", props, null);
Boolean transientProp = getBoolean(clazz, "transient", props, null);
@@ -935,7 +958,7 @@
}
private void processComponentJspProperty(Map props, AbstractJavaEntity ctx,
- JavaClass clazz, ComponentMeta component)
+ JavaClass clazz, PropertyHolder component)
{
Boolean required = getBoolean(clazz, "required", props, null);
Boolean transientProp = getBoolean(clazz, "transient", props, null);
Propchange: myfaces/myfaces-build-tools/branches/builder_plugin/test/api/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Apr 24 15:50:55 2008
@@ -7,4 +7,4 @@
*.iws
.settings
maven-eclipse.xml
-.externalToolsBuilder
+.externalToolBuilders