You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by ba...@apache.org on 2006/11/27 20:31:40 UTC
svn commit: r479752 [1/2] - in
/incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin: ./
src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/
src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/
src/main/java/org/a...
Author: baranda
Date: Mon Nov 27 12:31:39 2006
New Revision: 479752
URL: http://svn.apache.org/viewvc?view=rev&rev=479752
Log:
Merged with branch https://svn.apache.org/repos/asf/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin (r468887-479747), where the maven-faces-plugin has been adapted to autogenerate the components for MyFaces. This includes new generator abstract classes that can be implemented to generate different outputs.
Added:
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/
- copied from r479747, incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/
Modified:
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/pom.xml
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojo.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/PropertyBean.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java
Modified: incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/pom.xml?view=diff&rev=479752&r1=479751&r2=479752
==============================================================================
--- incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/pom.xml (original)
+++ incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/pom.xml Mon Nov 27 12:31:39 2006
@@ -1,15 +1,17 @@
<project>
<modelVersion>4.0.0</modelVersion>
+ <!--
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
<version>incubator-m1-SNAPSHOT</version>
</parent>
+ -->
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-faces-plugin</artifactId>
- <version>incubator-1.2-m1-SNAPSHOT</version>
+ <version>baranda-2.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven Faces Plugin</name>
@@ -66,5 +68,13 @@
<version>1.2.0_rc2-dev</version>
</dependency>
</dependencies>
+
+ <!-- Temporary section to deploy to baranda's repo -->
+ <distributionManagement>
+ <repository>
+ <id>baranda-repo</id>
+ <url>scpexe://people.apache.org/home/baranda/public_html/repo</url>
+ </repository>
+ </distributionManagement>
</project>
Modified: incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java?view=diff&rev=479752&r1=479751&r2=479752
==============================================================================
--- incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java (original)
+++ incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java Mon Nov 27 12:31:39 2006
@@ -15,58 +15,52 @@
*/
package org.apache.myfaces.trinidadbuild.plugin.faces;
-import java.io.File;
-import java.io.IOException;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-
-
+import org.apache.commons.digester.AbstractObjectCreationFactory;
+import org.apache.commons.digester.Digester;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.GeneratorHelper;
import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.AttributeBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ConverterBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigParser;
-import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ValidatorBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.AttributeFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.ComponentFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.ConverterFilter;
-import org.apache.myfaces.trinidadbuild.plugin.faces.util.Filter;
-import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
-import org.apache.myfaces.trinidadbuild.plugin.faces.util.PropertyFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.ValidatorFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.XIncludeFilter;
-import org.apache.commons.digester.AbstractObjectCreationFactory;
-import org.apache.commons.digester.Digester;
-
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-
import org.codehaus.plexus.util.FileUtils;
-
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
abstract public class AbstractFacesMojo extends AbstractMojo
{
protected List getCompileDependencyResources(
@@ -190,25 +184,69 @@
return false;
}
+ /**
+ * @deprecated call Util.convertStringToLiteral instead
+ */
protected String convertStringToLiteral(String value)
{
- return convertStringToLiteral("String", value);
+ return Util.convertStringToLiteral("String", value);
}
+ /**
+ * @deprecated call Util.convertStringToLiteral instead
+ */
protected String convertStringToLiteral(String className, String value)
{
- if (value == null)
+ return Util.convertStringToLiteral(className, value);
+ }
+
+ protected String readLicenseHeader() throws MojoExecutionException
+ {
+ if (licenseHeaderFile == null)
{
- return null;
+ return _DEFAULT_LICENSE_HEADER;
}
- else if ("String".equals(className))
+
+ if (!licenseHeaderFile.exists())
{
- return "\"" + value.replaceAll("\'", "\\'") + "\"";
+ throw new MojoExecutionException("License header file not found: "
+ +licenseHeaderFile.getName());
}
- else
+
+ if (licenseHeaderFile.isDirectory())
{
- return value;
+ throw new MojoExecutionException("Expecting a file and found a directory: "
+ +licenseHeaderFile.getName());
}
+
+ StringBuffer sb = new StringBuffer();
+
+ try
+ {
+ BufferedReader reader = new BufferedReader(new FileReader(licenseHeaderFile));
+ String line;
+
+ while ((line = reader.readLine()) != null)
+ {
+ sb.append(line+"\n");
+ }
+ }
+ catch (IOException e)
+ {
+ throw new MojoExecutionException("Exception reading license header file", e);
+ }
+
+ return sb.toString();
+ }
+
+ protected String getLicenseHeader() throws MojoExecutionException
+ {
+ if (_licenseHeader == null)
+ {
+ _licenseHeader = readLicenseHeader();
+ }
+
+ return _licenseHeader;
}
static public class URLCreationFactory extends AbstractObjectCreationFactory
@@ -258,10 +296,10 @@
}
protected void writePreamble(
- PrettyWriter out)
+ PrettyWriter out) throws MojoExecutionException
{
out.write(_AUTO_GENERATE_WARNING);
- out.write(_COPYRIGHT);
+ out.write(getLicenseHeader());
}
protected void copyFile(
@@ -290,27 +328,15 @@
}
}
+ /**
+ * @deprecated use Util.writeImports instead
+ */
protected void writeImports(
PrettyWriter out,
String packageName,
Set imports)
{
- Iterator iterator = imports.iterator();
- iterator = new FilteredIterator(iterator,
- new PackageImportsFilter(packageName));
- while (iterator.hasNext())
- {
- String className = (String)iterator.next();
- out.println("import " + className + ";");
- }
-
- out.println();
- }
-
- protected String convertMultilineComment(
- String commentBody)
- {
- return commentBody.replaceAll("\n", "\n * ");
+ GeneratorHelper.writeImports(out,packageName,imports);
}
private ClassLoader createCompileClassLoader(
@@ -345,16 +371,17 @@
return cl;
}
- static protected class SkipFilter extends ComponentFilter
+ protected class SkipFilter extends ComponentFilter
{
protected boolean accept(
ComponentBean component)
{
String componentType = component.getComponentType();
- // always skip API and base class generation
- return (!componentType.startsWith("javax") &&
- !componentType.endsWith("Base"));
+ // skip API and base class generation?
+ return !skipApiOrBaseClasses || (!componentType.startsWith("javax") &&
+ !componentType.endsWith("Base"));
+
}
}
@@ -369,7 +396,7 @@
protected boolean accept(
ComponentBean component)
{
- String componentType = component.getComponentType();
+ String componentType = component.getComponentType();
return (componentType.startsWith(_typePrefix));
}
private final String _typePrefix;
@@ -459,14 +486,7 @@
private final String _packageContains;
}
- static final protected class TagAttributeFilter extends PropertyFilter
- {
- protected boolean accept(
- PropertyBean property)
- {
- return (!property.isTagAttributeExcluded());
- }
- }
+
static final protected class ComponentTagFilter extends ComponentFilter
{
@@ -573,34 +593,41 @@
}
}
- static private class PackageImportsFilter implements Filter
- {
- public PackageImportsFilter(
- String packageName)
- {
- _packageName = packageName;
- }
-
- public boolean accept(
- Object object)
- {
- String className = (String)object;
- String packageName = Util.getPackageFromFullClass(className);
- return (!packageName.equals(_packageName) &&
- !packageName.equals("java.lang"));
- }
+ /**
+ * @parameter
+ */
+ private File licenseHeaderFile;
- private final String _packageName;
- }
+ /**
+ * @parameter default-value = "true"
+ */
+ private boolean skipApiOrBaseClasses;
private FacesConfigBean _facesConfig;
+ private String _licenseHeader;
static final private String _AUTO_GENERATE_WARNING =
"// WARNING: This file was automatically generated. Do not edit it directly,\n"+
"// or you will lose your changes.\n\n";
- static private final String _COPYRIGHT =
-"/*\n" +
-"** (TBD - insert proper license in generated code).\n" +
-"*/\n";
+
+ static final private String _DEFAULT_LICENSE_HEADER =
+ "/*\n" +
+ " * Licensed to the Apache Software Foundation (ASF) under one\n" +
+ " * or more contributor license agreements. See the NOTICE file\n" +
+ " * distributed with this work for additional information\n" +
+ " * regarding copyright ownership. The ASF licenses this file\n" +
+ " * to you under the Apache License, Version 2.0 (the\n" +
+ " * \"License\"); you may not use this file except in compliance\n" +
+ " * with the License. You may obtain a copy of the License at\n" +
+ " *\n" +
+ " * http://www.apache.org/licenses/LICENSE-2.0\n" +
+ " *\n" +
+ " * Unless required by applicable law or agreed to in writing,\n" +
+ " * software distributed under the License is distributed on an\n" +
+ " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" +
+ " * KIND, either express or implied. See the License for the\n" +
+ " * specific language governing permissions and limitations\n" +
+ " * under the License.\n" +
+ "*/";
}
Modified: incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java?view=diff&rev=479752&r1=479751&r2=479752
==============================================================================
--- incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java (original)
+++ incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java Mon Nov 27 12:31:39 2006
@@ -15,39 +15,26 @@
*/
package org.apache.myfaces.trinidadbuild.plugin.faces;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.component.ComponentGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.component.MyFacesComponentGenerator;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.component.TrinidadComponentGenerator;
import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
-import org.apache.myfaces.trinidadbuild.plugin.faces.parse.EventBean;
-import org.apache.myfaces.trinidadbuild.plugin.faces.parse.EventRefBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacesConfigBean;
-import org.apache.myfaces.trinidadbuild.plugin.faces.parse.FacetBean;
-import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.ComponentFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
-import org.apache.myfaces.trinidadbuild.plugin.faces.util.PropertyFilter;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.SourceTemplate;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+
/**
* @version $Id$
* @requiresDependencyResolution compile
@@ -75,7 +62,7 @@
/**
* Generates parsed components.
*/
- private void _generateComponents() throws IOException
+ private void _generateComponents() throws IOException, MojoExecutionException
{
// Make sure generated source directory
// is added to compilation source path
@@ -123,13 +110,23 @@
* @param component the parsed component metadata
*/
private void _generateComponent(
- ComponentBean component)
+ ComponentBean component) throws MojoExecutionException
{
+ ComponentGenerator generator;
+
String fullClassName = component.getComponentClass();
-
+
+ if (component.isTrinidadComponent())
+ {
+ generator = new TrinidadComponentGenerator(getLog(), _is12());
+ }
+ else {
+ generator = new MyFacesComponentGenerator(getLog(),_is12() );
+ }
+
try
{
- getLog().debug("Generating " + fullClassName);
+ getLog().debug("Generating " + fullClassName+", with generator: "+generator.getClass().getName());
String sourcePath = Util.convertClassToSourcePath(fullClassName, ".java");
File targetFile = new File(generatedSourceDirectory, sourcePath);
@@ -142,8 +139,8 @@
if (componentFamily == null)
{
- getLog().error("Missing <component-family> for \"" +
- fullClassName + "\"");
+ getLog().warn("Missing <component-family> for \"" +
+ fullClassName + "\", generation of this Component is skipped");
}
else
{
@@ -189,21 +186,21 @@
out.println();
// imports
- _writeImports(out, template, packageName,
+ generator.writeImports(out, template, packageName,
fullSuperclassName, superclassName,
component);
// class
- _writeClassBegin(out, className, superclassName, component, template);
+ generator.writeClassBegin(out, className, superclassName, component, template);
// static final constants
- _writePropertyValueConstants(out, component);
- _writePropertyConstants(out, superclassName, component);
- _writeFacetConstants(out, component);
- _writeGenericConstants(out, componentFamily, componentType);
+ generator.writePropertyValueConstants(out, component);
+ generator.writePropertyConstants(out, superclassName, component);
+ generator.writeFacetConstants(out, component);
+ generator.writeGenericConstants(out, componentFamily, componentType);
// public constructors and methods
- _writeConstructor(out, component, Modifier.PUBLIC);
+ generator.writeConstructor(out, component, Modifier.PUBLIC);
// insert template code
if (template != null)
@@ -212,24 +209,28 @@
template.close();
}
- _writeFacetMethods(out, component);
- _writePropertyMethods(out, component);
+ generator.writeFacetMethods(out, component);
+
+ if (template == null)
+ {
+ generator.writePropertyMethods(out, component);
+ } else {
+ generator.writePropertyMethods(out, component, template.getIgnoreMethods());
+ }
if (!suppressListenerMethods)
- _writeListenerMethods(out, component);
+ generator.writeListenerMethods(out, component);
- _writeGetFamily(out);
+ generator.writeStateManagementMethods(out, component);
+
+ generator.writeGetFamily(out);
// protected constructors and methods
// TODO: reverse this order, to make protected constructor go first
// for now we want consistency with previous code generation
- _writeGetBeanType(out);
- _writeConstructor(out, component, Modifier.PROTECTED);
-
- // static initializer
- _writeTypeLock(out, component);
+ generator.writeOther(out, component);
- _writeClassEnd(out);
+ generator.writeClassEnd(out);
out.close();
@@ -251,1051 +252,6 @@
}
}
- private void _writeClassBegin(
- PrettyWriter out,
- String className,
- String superclassName,
- ComponentBean component,
- SourceTemplate template)
- {
- out.println("/**");
-
- // TODO: restore description (needs escaping?)
-// String description = component.getDescription();
-// if (description != null)
-// {
-// out.println(" *");
-// out.println(" * " + convertMultilineComment(description));
-// }
-
- String longDescription = component.getLongDescription();
- if (longDescription != null)
- {
- out.println(" *");
- out.println(" * " + convertMultilineComment(longDescription));
- }
-
- if (component.hasEvents(true))
- {
- // the events javadoc
- out.println(" *");
- out.println(" * <h4>Events:</h4>");
- out.println(" * <table border=\"1\" width=\"100%\" cellpadding=\"3\" summary=\"\">");
- out.println(" * <tr bgcolor=\"#CCCCFF\" class=\"TableHeadingColor\">");
- out.println(" * <th align=\"left\">Type</th>");
- out.println(" * <th align=\"left\">Phases</th>");
- out.println(" * <th align=\"left\">Description</th>");
- out.println(" * </tr>");
- Iterator events = component.events(true);
- while (events.hasNext())
- {
- EventRefBean eventRef = (EventRefBean)events.next();
- EventBean event = eventRef.resolveEventType();
- if (event != null)
- {
- String eventClass = event.getEventClass();
- String[] eventPhases = eventRef.getEventDeliveryPhases();
- String eventDescription = event.getDescription();
- out.println(" * <tr class=\"TableRowColor\">");
- out.println(" * <td valign=\"top\"><code>" + eventClass + "</code></td>");
- out.print(" * <td valign=\"top\" nowrap>");
- if (eventPhases != null)
- {
- for (int i=0; i < eventPhases.length; i++)
- {
- if (i > 0)
- out.print("<br>");
- out.print(eventPhases[i]);
- }
- }
- out.println("</td>");
- out.println(" * <td valign=\"top\">" + eventDescription + "</td>");
- out.println(" * </tr>");
- }
- }
- out.println(" * </table>");
- }
-
- if (!component.hasChildren())
- {
- out.println(" * <p>");
- out.println(" * It does not support any children.");
- }
-
- out.println(" */");
-
- // TODO: eliminate <mfp:component-class-modifier> metadata
- int modifiers = component.getComponentClassModifiers();
- String classStart = Modifier.toString(modifiers);
- // TODO: use canonical ordering
- classStart = classStart.replaceAll("public abstract", "abstract public");
- out.println(classStart + " class " + className +
- " extends " + superclassName);
-
- Set interfaces = new HashSet();
- if (template != null)
- interfaces.addAll(template.getImplements());
-
- if (component.isNamingContainer())
- interfaces.add("javax.faces.component.NamingContainer");
-
- Iterator events = component.events();
- while (events.hasNext())
- {
- EventRefBean eventRef = (EventRefBean)events.next();
- EventBean event = eventRef.resolveEventType();
- if (event != null)
- {
- if (!eventRef.isIgnoreSourceInterface())
- {
- String source = event.getEventSourceInterface();
- if (source != null)
- interfaces.add(Util.getClassFromFullClass(source));
- }
- }
- }
-
- if (!interfaces.isEmpty())
- {
- Set implementsSet = new HashSet();
- for (Iterator iter=interfaces.iterator(); iter.hasNext();)
- {
- String fcqn = (String)iter.next();
- implementsSet.add(Util.getClassFromFullClass(fcqn));
- }
-
- // implements clause spans multiple lines
- char[] indent = new char[classStart.length() +
- " class ".length() +
- className.length() + 1];
- Arrays.fill(indent, ' ');
- out.print(indent);
- out.print("implements ");
- for (Iterator iter=implementsSet.iterator(); iter.hasNext();)
- {
- out.print((String)iter.next());
- if (iter.hasNext())
- {
- out.println(",");
- out.print(indent);
- out.print(" "); // same length as "implements "
- }
- }
- out.println();
- }
-
- out.println("{");
- out.indent();
- }
-
- private void _writeClassEnd(
- PrettyWriter out)
- {
- out.unindent();
- out.println("}");
- }
-
- private void _writeImports(
- PrettyWriter out,
- SourceTemplate template,
- String packageName,
- String fullSuperclassName,
- String superclassName,
- ComponentBean component)
- {
- Set imports = new TreeSet();
-
- // Use the template imports
- if (template != null)
- imports.addAll(template.getImports());
-
- // FacesBean is always needed to define the TYPE
- imports.add("org.apache.myfaces.trinidad.bean.FacesBean");
-
- // Detect NamingContainer
- if (component.isNamingContainer())
- imports.add("javax.faces.component.NamingContainer");
-
- Iterator properties = component.properties();
- properties = new FilteredIterator(properties, new NonVirtualFilter());
- // PropertyKey only needed if there are properties
- if (properties.hasNext())
- {
- imports.add("org.apache.myfaces.trinidad.bean.PropertyKey");
-
- PropertyFilter resolvable = new ResolvableTypeFilter();
- while (properties.hasNext())
- {
- PropertyBean property = (PropertyBean)properties.next();
- String propertyClass = property.getPropertyClass();
- if (propertyClass != null)
- {
- imports.add(propertyClass);
- // Check for generics
- String[] types = property.getAttributeClassParameters();
- if(types != null)
- {
- for(int i = types.length - 1; i >= 0; i--)
- {
- _addGenericImports(imports, types[i]);
- }
- }
- }
-
- // ComponentUtils only needed for resolvable properties
- if (resolvable.accept(property))
- imports.add("org.apache.myfaces.trinidad.util.ComponentUtils");
- }
- }
-
- Iterator facets = component.facets();
- // UIComponent needed if there are facets
- if (facets.hasNext())
- imports.add("javax.faces.component.UIComponent");
-
- Iterator events = component.events();
- while (events.hasNext())
- {
- EventRefBean eventRef = (EventRefBean)events.next();
- EventBean event = eventRef.resolveEventType();
-
- if (event == null)
- {
- getLog().warn("Unknown event type \"" + eventRef.getEventType() + "\""+
- " in component:"+component.getComponentType());
- }
- else
- {
- String listenerClass = event.getEventListenerClass();
- if (listenerClass != null)
- imports.add(listenerClass);
-
- if (!eventRef.isIgnoreSourceInterface())
- {
- String sourceInterface = event.getEventSourceInterface();
- if (sourceInterface != null)
- imports.add(sourceInterface);
- }
- }
- }
-
- // Import causes a collision if className and superclassName are equal
- if (!superclassName.equals(fullSuperclassName))
- {
- String superPackageName = Util.getPackageFromFullClass(fullSuperclassName);
- // component superclass only needed if not in
- // same package as component class
- if (superPackageName != packageName)
- imports.add(fullSuperclassName);
- }
-
- // do not import implicit types!
- imports.removeAll(Util.PRIMITIVE_TYPES);
-
- writeImports(out, packageName, imports);
- }
-
- private void _addGenericImports(Set imports, String type)
- {
- Matcher matcher = _GENERIC_TYPE.matcher(type);
- if(matcher.matches())
- {
- // Generic type
- imports.add(matcher.group(1));
- String[] types = matcher.group(2).split(",");
- for(int i = types.length - 1; i >= 0; i--)
- {
- _addGenericImports(imports, types[i]);
- }
- }
- else
- {
- // Non-generic type
- imports.add(type);
- }
- }
-
- private void _writeGenericConstants(
- PrettyWriter out,
- String componentFamily,
- String componentType) throws IOException
- {
- out.println();
- out.println("static public final String COMPONENT_FAMILY =");
- out.println(" \"" + componentFamily + "\";");
- out.println("static public final String COMPONENT_TYPE =");
- out.println(" \"" + componentType + "\";");
- }
-
- private void _writePropertyConstants(
- PrettyWriter out,
- String superclassName,
- ComponentBean component) throws IOException
- {
- out.println("static public final FacesBean.Type TYPE = new FacesBean.Type(");
- out.indent();
- out.println(superclassName + ".TYPE);");
- out.unindent();
-
- // component property keys
- Iterator properties = component.properties();
- properties = new FilteredIterator(properties, new NonVirtualFilter());
- while (properties.hasNext())
- {
- PropertyBean property = (PropertyBean)properties.next();
- String propName = property.getPropertyName();
- String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
- String propAlias = property.getAliasOf();
-
- out.println("static public final PropertyKey " + propKey + " =");
- out.indent();
- if (propAlias != null)
- {
- String aliasKey = Util.getConstantNameFromProperty(propAlias, "_KEY");
- out.print("TYPE.registerAlias(" + aliasKey + ", \"" + propName + "\");");
- }
- else
- {
- out.print("TYPE.registerKey(\"" + propName + "\"");
-
- // property class
- String propFullClass = property.getPropertyClass();
- String propClass = Util.getClassFromFullClass(propFullClass);
- if (propClass == null)
- {
- propClass = "String";
- }
- String propDefault = property.getDefaultValue();
-
- if (!"Object".equals(propClass) || propDefault != null)
- {
- // TODO: do not use boxed class here
- String boxedClass = Util.getBoxedClass(propClass);
- out.print(", " + boxedClass + ".class");
- }
-
- if (propDefault != null)
- {
- out.print(", " + _convertStringToBoxedLiteral(propClass, propDefault));
- }
-
- // property capabilities
- String propCaps = _getPropertyCapabilities(property);
- if (propCaps != null)
- out.print(", " + propCaps);
- out.println(");");
- }
- out.unindent();
- }
- }
-
- private void _writePropertyValueConstants(
- PrettyWriter out,
- ComponentBean component) throws IOException
- {
- // component property keys
- Iterator properties = component.properties();
- properties = new FilteredIterator(properties, new NonVirtualFilter());
- while (properties.hasNext())
- {
- PropertyBean property = (PropertyBean)properties.next();
- String[] propertyValues = property.getPropertyValues();
-
- if (propertyValues != null)
- {
- String propName = property.getPropertyName();
-
- for (int i=0; i < propertyValues.length; i++)
- {
- String propValue = propertyValues[i];
- String propValueName = propName +
- Character.toUpperCase(propValue.charAt(0)) +
- propValue.substring(1);
- String propValueKey = Util.getConstantNameFromProperty(propValueName);
-
- out.println("static public final String " + propValueKey + " = \"" + propValue + "\";");
- }
-
- }
- }
- }
-
- private void _writeFacetConstants(
- PrettyWriter out,
- ComponentBean component) throws IOException
- {
- Iterator facets = component.facets();
- while (facets.hasNext())
- {
- FacetBean facet = (FacetBean)facets.next();
- String facetName = facet.getFacetName();
- String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
- out.println("static public final " +
- "String " + facetKey + " = \"" + facetName + "\";");
- }
- }
-
- private String _convertStringToBoxedLiteral(
- String className,
- String value)
- {
- if (value == null)
- {
- return null;
- }
- else if ("String".equals(className))
- {
- return "\"" + value.replaceAll("\'", "\\'") + "\"";
- }
- else if ("boolean".equals(className))
- {
- return ("true".equals(value)) ? "Boolean.TRUE" : "Boolean.FALSE";
- }
- else if ("char".equals(className))
- {
- return "new Character('" + value.replaceAll("\'", "\\'") + "')";
- }
- else if ("int".equals(className))
- {
- return "new Integer(" + value + ")";
- }
- else if ("float".equals(className))
- {
- return "new Float(" + value + ")";
- }
- else
- {
- throw new IllegalStateException();
- }
- }
-
- private void _writeConstructor(
- PrettyWriter out,
- ComponentBean component,
- int modifiers) throws IOException
- {
- String fullClassName = component.getComponentClass();
- String className = Util.getClassFromFullClass(fullClassName);
-
- if (Modifier.isPublic(modifiers))
- {
- // TODO: eliminate this inconsistency
- if (!Modifier.isAbstract(component.getComponentClassModifiers()))
- {
- String rendererType = component.getRendererType();
-
- if (rendererType != null)
- rendererType = _convertStringToBoxedLiteral("String", rendererType);
-
- out.println();
- out.println("/**");
- // TODO: restore this correctly phrased comment (tense vs. command)
- //out.println(" * Constructs an instance of " + className + ".");
- out.println(" * Construct an instance of the " + className + ".");
- out.println(" */");
- out.println("public " + className + "()");
- out.println("{");
- out.indent();
- out.println("super(" + rendererType + ");");
- out.unindent();
- out.println("}");
- }
- }
- else if (Modifier.isProtected(modifiers))
- {
- out.println();
- out.println("/**");
- // TODO: restore this more descriptive comment with param docs
- //out.println(" * Construct an instance of the " + className);
- //out.println(" * with the specified renderer type.");
- //out.println(" * ");
- //out.println(" * @param rendererType the renderer type");
- out.println(" * Construct an instance of the " + className + ".");
- out.println(" */");
- out.println("protected " + className + "(");
- out.indent();
- out.println("String rendererType");
- out.println(")");
- out.unindent();
- out.println("{");
- out.indent();
- out.println("super(rendererType);");
- out.unindent();
- out.println("}");
-
- // TODO: eliminate this inconsistency
- if (Modifier.isAbstract(component.getComponentClassModifiers()))
- {
- out.println();
- out.println("/**");
- // TODO: restore this correctly phrased comment (tense vs. command)
- //out.println(" * Constructs an instance of " + className + ".");
- out.println(" * Construct an instance of the " + className + ".");
- out.println(" */");
- out.println("protected " + className + "()");
- out.println("{");
- out.indent();
- out.println("this(null);");
- out.unindent();
- out.println("}");
- }
- }
- }
-
- private void _writeGetFamily(
- PrettyWriter out) throws IOException
- {
- out.println();
- out.println("@Override");
- out.println("public String getFamily()");
- out.println("{");
- out.indent();
- out.println("return COMPONENT_FAMILY;");
- out.unindent();
- out.println("}");
- }
-
- private void _writeGetBeanType(
- PrettyWriter out) throws IOException
- {
- out.println();
- out.println("@Override");
- out.println("protected FacesBean.Type getBeanType()");
- out.println("{");
- out.indent();
- out.println("return TYPE;");
- out.unindent();
- out.println("}");
- }
-
- private void _writePropertyMethods(
- PrettyWriter out,
- ComponentBean component) throws IOException
- {
- Iterator properties = component.properties();
- properties = new FilteredIterator(properties, new NonVirtualFilter());
- while (properties.hasNext())
- {
- PropertyBean property = (PropertyBean)properties.next();
- if (property.isList())
- _writePropertyListMethods(out, property);
- else
- {
- _writePropertyGet(out, property);
- _writePropertySet(out, property);
- }
- }
- }
-
- private void _writePropertyListMethods(
- PrettyWriter out,
- PropertyBean property) throws IOException
- {
- String propName = property.getPropertyName();
- String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
- String propertyClass = property.getPropertyClass();
- if (!"java.util.List".equals(propertyClass))
- {
- getLog().error("Invalid list type: " + propertyClass);
- return;
- }
-
- // Look for the generic type - if it doesn't exist, then
- // we'll be an Object.
- String[] params = property.getPropertyClassParameters();
- if ((params == null) || (params.length == 0))
- propertyClass = "java.lang.Object";
- else
- propertyClass = params[0];
-
- propertyClass = Util.getClassFromFullClass(propertyClass);
-
- String singularName = _getSingular(propName);
- String propVar = Util.getVariableFromName(singularName);
- String description = property.getDescription();
- String addMethod = Util.getPrefixedPropertyName("add", singularName);
- String removeMethod = Util.getPrefixedPropertyName("remove", singularName);
- String getMethod = Util.getPrefixedPropertyName("get", propName);
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * Adds a " + convertMultilineComment(description));
- }
- out.println(" */");
- out.println("final public void " + addMethod + "(" + propertyClass + " " +
- propVar + ")");
- out.println("{");
- out.indent();
- out.println("if (" + propVar + " == null)");
- out.println(" throw new NullPointerException();");
- out.println();
- out.println("getFacesBean().addEntry(" + propKey + ", " + propVar + ");");
- out.unindent();
- out.println("}");
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * Removes a " + convertMultilineComment(description));
- }
- out.println(" */");
- out.println("final public void " + removeMethod + "(" + propertyClass + " " +
- propVar + ")");
- out.println("{");
- out.indent();
- out.println("if (" + propVar + " == null)");
- out.println(" throw new NullPointerException();");
- out.println();
- out.println("getFacesBean().removeEntry(" + propKey + ", " + propVar + ");");
- out.unindent();
- out.println("}");
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * Gets all " + convertMultilineComment(description));
- }
- out.println(" */");
- out.println("final public " + propertyClass + "[] " + getMethod + "()");
- out.println("{");
- out.indent();
- out.println("return (" + propertyClass + "[]) getFacesBean().getEntries(");
- out.println(" " + propKey + ", " + propertyClass + ".class);");
- out.unindent();
- out.println("}");
- }
-
- static private String _getSingular(String plural)
- {
- if (plural.endsWith("s"))
- return plural.substring(0, plural.length() - 1);
- return plural;
- }
-
- private void _writePropertySet(
- PrettyWriter out,
- PropertyBean property) throws IOException
- {
- String propertyClass = Util.getPropertyClass(property);
- _writePropertySet(out, property, propertyClass);
-
- if (property.getAlternateClass() != null)
- {
- String alternateClass = Util.getAlternatePropertyClass(property);
- _writePropertySet(out, property, alternateClass);
- }
- }
-
- private void _writePropertySet(
- PrettyWriter out,
- PropertyBean property,
- String propertyClass) throws IOException
- {
- String propName = property.getPropertyName();
- String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
- String propVar = Util.getVariableFromName(propName);
- String description = property.getDescription();
- String setMethod = Util.getPrefixedPropertyName("set", propName);
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * Sets " + convertMultilineComment(description));
- }
- // TODO: restore this comment.
-// if (property.isRequired())
-// {
-// out.println(" * <p>");
-// out.println(" * This is a required property on the component.");
-// }
- // TODO: put this back in
- //out.println(" * ");
- //out.println(" * @param " + propName + " the new " + propName + " value");
- out.println(" */");
-
- out.println("final public void " + setMethod + "(" + propertyClass + " " + propVar + ")");
- out.println("{");
- out.indent();
- if (Util.isPrimitiveClass(propertyClass))
- {
- // TODO: use UIXComponentBase setXXXProperty methods when possible
- if (propertyClass.equals("boolean"))
- {
- // TODO: add back space before ternary operator
- out.println("setProperty(" + propKey + ", " + propVar + "? Boolean.TRUE : Boolean.FALSE);");
- }
- else
- {
- String boxedClass = Util.getBoxedClass(propertyClass);
- out.println("setProperty(" + propKey + ", new " + boxedClass + "(" + propVar + "));");
- }
- }
- else
- {
- out.println("setProperty(" + propKey + ", (" + propVar + "));");
- }
- out.unindent();
- out.println("}");
- }
-
- private void _writePropertyGet(
- PrettyWriter out,
- PropertyBean property) throws IOException
- {
- String propName = property.getPropertyName();
- String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
- String propertyFullClass = property.getPropertyClass();
- String propertyClass = Util.getClassFromFullClass(propertyFullClass);
- String description = property.getDescription();
- String getMethod = Util.getMethodReaderFromProperty(propName, propertyClass);
-
- boolean isUnchecked = false;
- String[] genericTypes = property.getPropertyClassParameters();
- if(genericTypes != null && genericTypes.length > 0)
- {
- isUnchecked = true;
- propertyClass = Util.getPropertyClass(property);
- }
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * Gets " + convertMultilineComment(description));
- }
- if (property.isRequired())
- {
- out.println(" * <p>");
- out.println(" * This is a required property on the component.");
- out.println(" * </p>");
- }
- // TODO: put this back in
- //out.println(" *");
- //out.println(" * @return the new " + propName + " value");
- out.println(" */");
-
- if(isUnchecked)
- {
- out.println("@SuppressWarnings(\"unchecked\")");
- }
-
- out.println("final public " + propertyClass + " " + getMethod + "()");
- out.println("{");
- out.indent();
-
- String resolvableType = _resolveType(propertyFullClass);
- if (resolvableType != null)
- {
- // TODO: change signature of ComponentUtils.resolveCharacter
- // to take Object instead of Character
- if (resolvableType.equals("Character"))
- {
- out.println("return ComponentUtils.resolveCharacter((Character)getProperty(" + propKey + "));");
- }
- else
- {
- // TODO: stop specifying default values in the getters
- String resolveMethod = Util.getPrefixedPropertyName("resolve", resolvableType);
- String propertyDefault = property.getDefaultValue();
- out.print("return ComponentUtils." + resolveMethod + "(getProperty(" + propKey + ")");
- if (propertyDefault != null)
- {
- out.print(", " + convertStringToLiteral(propertyClass,
- propertyDefault));
- }
- out.println(");");
- }
- }
- else
- {
- if(propertyClass.equals("Object"))
- {
- // Cast is not necessary if the property class is Object
- out.println("return getProperty(" + propKey + ");");
- }
- else
- {
- out.println("return (" + propertyClass + ")" +
- "getProperty(" + propKey + ");");
- }
- }
- out.unindent();
- out.println("}");
- }
-
- private void _writeFacetMethods(
- PrettyWriter out,
- ComponentBean component) throws IOException
- {
- Iterator facets = component.facets();
- while (facets.hasNext())
- {
- FacetBean facet = (FacetBean)facets.next();
- _writeFacetGet(out, facet);
- _writeFacetSet(out, facet);
- }
- }
-
- private void _writeFacetSet(
- PrettyWriter out,
- FacetBean facet) throws IOException
- {
- String facetName = facet.getFacetName();
- // TODO: drop the unnecessary "Facet" suffix
- String facetVar = facetName + "Facet";
- String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
- String setMethod = Util.getPrefixedPropertyName("set", facetName);
- String description = facet.getDescription();
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * " + convertMultilineComment(description));
- }
- if (facet.isRequired())
- {
- out.println(" * <p>");
- out.println(" * This is a required facet on the component.");
- }
- // TODO: put this back in
- //out.println(" * ");
- //out.println(" * @param " + facetVar + " the new " + facetName + " facet");
- out.println(" */");
-
- // Remove type safety warning since getFacets is not generics enabled
- // under JSF 1.1 spec
- // TODO: Remove this line when Trinidad switch to JSF 1.2
- out.println("@SuppressWarnings(\"unchecked\")");
-
- out.println("final public void " + setMethod + "(UIComponent " + facetVar + ")");
- out.println("{");
- out.indent();
- out.println("getFacets().put(" + facetKey + ", " + facetVar + ");");
- out.unindent();
- out.println("}");
- }
-
- private void _writeFacetGet(
- PrettyWriter out,
- FacetBean facet) throws IOException
- {
- String facetName = facet.getFacetName();
- String facetKey = Util.getConstantNameFromProperty(facetName, "_FACET");
- String getMethod = Util.getPrefixedPropertyName("get", facetName);
- String description = facet.getDescription();
-
- out.println();
- out.println("/**");
- if (description != null)
- {
- out.println(" * " + convertMultilineComment(description));
- }
- if (facet.isRequired())
- {
- out.println(" * <p>");
- out.println(" * This is a required facet on the component.");
- }
- // TODO: put this back in
- //out.println(" * ");
- //out.println(" * @return the " + facetName + " facet");
- out.println(" */");
-
- out.println("final public UIComponent " + getMethod + "()");
- out.println("{");
- out.indent();
- out.println("return getFacet(" + facetKey + ");");
- out.unindent();
- out.println("}");
- }
-
- private void _writeListenerMethods(
- PrettyWriter out,
- ComponentBean component) throws IOException
- {
- Iterator events = component.events();
- while (events.hasNext())
- {
- EventRefBean eventRef = (EventRefBean)events.next();
- EventBean event = eventRef.resolveEventType();
- if (event != null)
- {
- _writeListenerAdd(out, event);
- _writeListenerRemove(out, event);
- _writeListenersGet(out, event);
- }
- }
- }
-
- private void _writeListenerAdd(
- PrettyWriter out,
- EventBean event) throws IOException
- {
- String listenerFullClass = event.getEventListenerClass();
- String listenerClass = Util.getClassFromFullClass(listenerFullClass);
-
- String eventName = event.getEventName();
- String addMethod = Util.getMethodNameFromEvent("add", eventName, "Listener");
-
- out.println();
- out.println("/**");
- out.println(" * Adds a " + eventName + " listener.");
- out.println(" *");
- out.println(" * @param listener the " + eventName + " listener to add");
- out.println(" */");
-
- out.println("final public void " + addMethod + "(");
- out.indent();
- out.println(listenerClass + " listener)");
- out.unindent();
- out.println("{");
- out.indent();
- out.println("addFacesListener(listener);");
- out.unindent();
- out.println("}");
- }
-
- private void _writeListenerRemove(
- PrettyWriter out,
- EventBean event) throws IOException
- {
- String listenerFullClass = event.getEventListenerClass();
- String listenerClass = Util.getClassFromFullClass(listenerFullClass);
-
- String eventName = event.getEventName();
- String removeMethod = Util.getMethodNameFromEvent("remove", eventName, "Listener");
-
- out.println();
- out.println("/**");
- out.println(" * Removes a " + eventName + " listener.");
- out.println(" *");
- out.println(" * @param listener the " + eventName + " listener to remove");
- out.println(" */");
-
- out.println("final public void " + removeMethod + "(");
- out.indent();
- out.println(listenerClass + " listener)");
- out.unindent();
- out.println("{");
- out.indent();
- out.println("removeFacesListener(listener);");
- out.unindent();
- out.println("}");
- }
-
- private void _writeListenersGet(
- PrettyWriter out,
- EventBean event) throws IOException
- {
- String listenerFullClass = event.getEventListenerClass();
- String listenerClass = Util.getClassFromFullClass(listenerFullClass);
-
- String eventName = event.getEventName();
- String getMethod = Util.getMethodNameFromEvent("get", eventName, "Listeners");
-
- out.println();
- out.println("/**");
- out.println(" * Returns an array of attached " + eventName + " listeners.");
- out.println(" *");
- out.println(" * @return an array of attached " + eventName + " listeners.");
- out.println(" */");
-
- out.println("final public " + listenerClass + "[] " + getMethod + "()");
- out.println("{");
- out.indent();
- out.println("return (" + listenerClass + "[])" +
- "getFacesListeners(" + listenerClass + ".class);");
- out.unindent();
- out.println("}");
- }
-
- private void _writeTypeLock(
- PrettyWriter out, ComponentBean component) throws IOException
- {
- out.println();
- out.println("static");
- out.println("{");
- out.indent();
- String rendererType = component.getRendererType();
- if (rendererType == null)
- {
- out.println("TYPE.lock();");
- }
- else
- {
- String componentFamily = component.findComponentFamily();
- out.println("TYPE.lockAndRegister(\"" + componentFamily + "\"," +
- "\"" + rendererType + "\");");
- }
-
- out.unindent();
- out.println("}");
- }
-
- private String _getPropertyCapabilities(
- PropertyBean property)
- {
- List caps = new ArrayList();
-
- if (property.isMethodBinding() ||
- property.isLiteralOnly())
- {
- caps.add("PropertyKey.CAP_NOT_BOUND");
- }
-
- if (property.isStateHolder())
- {
- caps.add("PropertyKey.CAP_STATE_HOLDER");
- }
-
- if (property.isTransient())
- {
- caps.add("PropertyKey.CAP_TRANSIENT");
- }
-
- if (property.isList())
- {
- caps.add("PropertyKey.CAP_LIST");
- }
-
- if (caps.isEmpty())
- return null;
-
- StringBuffer sb = new StringBuffer();
- for (int i=0; i < caps.size(); i++)
- {
- if (i > 0)
- sb.append(" | ");
- sb.append(caps.get(i));
- }
- return sb.toString();
- }
-
- private class NonVirtualFilter extends PropertyFilter
- {
- protected boolean accept(
- PropertyBean property)
- {
- return (!property.isVirtual());
- }
- }
-
- private class ResolvableTypeFilter extends PropertyFilter
- {
- protected boolean accept(
- PropertyBean property)
- {
- String propertyClass = property.getPropertyClass();
- String resolvableType = _resolveType(propertyClass);
- return (resolvableType != null);
- }
- }
-
private class IfModifiedFilter extends ComponentFilter
{
protected boolean accept(
@@ -1313,31 +269,11 @@
}
}
- static private String _resolveType(
- String className)
- {
- return (String)_RESOLVABLE_TYPES.get(className);
- }
-
- static private Map _createResolvableTypes()
- {
- Map resolvableTypes = new HashMap();
+ private boolean _is12()
+ {
+ return "1.2".equals(jsfVersion) || "12".equals(jsfVersion);
+ }
- resolvableTypes.put("boolean", "Boolean");
- resolvableTypes.put("char", "Character");
- // TODO: put this back in
- //resolvableTypes.put("java.util.Date", "Date");
- resolvableTypes.put("int", "Integer");
- resolvableTypes.put("float", "Float");
- resolvableTypes.put("java.util.Locale", "Locale");
- resolvableTypes.put("long", "Long");
- resolvableTypes.put("java.lang.String", "String");
- // TODO: put this back in
- //resolvableTypes.put("java.lang.String[]", "StringArray");
- resolvableTypes.put("java.util.TimeZone", "TimeZone");
-
- return Collections.unmodifiableMap(resolvableTypes);
- }
/**
* @parameter expression="${project}"
@@ -1385,6 +321,8 @@
*/
private boolean suppressListenerMethods;
- static private final Pattern _GENERIC_TYPE = Pattern.compile("([^<]+)<(.+)>");
- static final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
+ /**
+ * @parameter
+ */
+ private String jsfVersion;
}
Modified: incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojo.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojo.java?view=diff&rev=479752&r1=479751&r2=479752
==============================================================================
--- incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojo.java (original)
+++ incubator/adffaces/branches/faces-1_2/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateFacesConfigMojo.java Mon Nov 27 12:31:39 2006
@@ -15,17 +15,15 @@
*/
package org.apache.myfaces.trinidadbuild.plugin.faces;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.XIncludeFilter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -41,19 +39,17 @@
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-
-import org.apache.myfaces.trinidadbuild.plugin.faces.util.XIncludeFilter;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
/**
* @version $Id$
@@ -269,9 +265,8 @@
/**
* @parameter
- * @required
*/
- private String typePrefix;
+ private String typePrefix = "";
/**
* Name of an XSLT stylesheet in src/main/conf that will be applied