You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bs...@apache.org on 2012/03/23 02:11:02 UTC
svn commit: r1304157 - in /myfaces/trinidad-maven/trunk:
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/
maven-faces-plugin/src/ma...
Author: bsullivan
Date: Fri Mar 23 01:11:01 2012
New Revision: 1304157
URL: http://svn.apache.org/viewvc?rev=1304157&view=rev
Log:
TRINIDAD-2248 Change component templating scheme to generate superclasses of templated components rather than the templated components themselves
Add support for the features as listed in the JIRA:
he current component templating scheme works as follows:
For a component with fully qualified name <package name>.<component name>
Look in the parallel java-templates directory tree for the file <package name>.<component name>Template.java
if it exists, merge the contents of <package name>.<component name>Template.java with the generated class artifacts to create the actual component source file <package name>.<component name>.java.
On the surface, this seems fine however it has a major impact on supportability because
1) The <package name>.<component name>Template.java files often can not be included in the IDE projects.
2) Debugging of the Template files (which is where all of the interesting code is) must be done against the flattened file, which is non-obvious and a pain, while the actual fixes need to be done against the Template files
3) Each Template file fix requires that the generate-components portion of the build be re-executed to reflatten the component
Developers have tried to work around the first issue in various ways:
1) They make the Template extend the superclass of the component to be generated, so that the inherited methods are present (this superclass is ignored when merging)
2) They manually add abstract implementations of any of the artifacts generated from metadata, using the bizarre /**/ prefix on the lines to indicate to the merging code that the artifact should be ignored when merging (to avoid conflicts with the merged functions.
Even with the hacks, which are a pain to use, more complicated usages with inner classes, still can't be supported.
The proposal is to use real inheritance instead. The old behavior would still be supported for backwards compatibility. In the new proposal we:
Look in the parallel java-templates directory tree for the file <package name>.<component name>.java
if it exists, generate a new package private abstract class file with the name <package name>.Partial<component name>.java containing the generated class artifacts.
The result is that rather that the generated partial class contains all of the generated logic and all of the real logic is contained in the component developer's class, extending the partial class. The developers class is in every way a real class suitable for inclusion in the source control system.
To convert an old <component name>Template.java file to a new <component name>.java file, the developer:
1) Renames the source file
2) Changes the old extends and implements to extend just the Partial class
3) Adds the constructors of the form:
/**
* Construct an instance of the <component name>
*/
public <component name>()
{
super();
}
/**
* Construct an instance of the <component name>
*/
protected <component name>(
String rendererType
)
{
super(rendererType);
}
4) Deletes any abstract functions added to make the old scheme kind of work (these are often preceeded with /**/)
5) If you add your own private property keys, you need to create your own type and then lock the TYPE yourself. For example:
public static final FacesBean.Type TYPE = new FacesBean.Type(PartialUIXRegion.TYPE);
private static final PropertyKey _VIEW_ID_INDEX_MAP_KEY =TYPE.registerKey(
"oracle.adf.view.rich.component.fragment.UIXRegion.viewIdToIndexMap", Map.class, null, 0,
PropertyKey.Mutable.OFTEN);
static
{
TYPE.lock();
}
6) Removes any no longer needed imports
Modified:
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/11.1.2.0.0/workspace.xml
myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.1.0.0/workspace.xml
myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.2.0.0/workspace.xml
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java Fri Mar 23 01:11:01 2012
@@ -19,12 +19,16 @@
package org.apache.myfaces.trinidadbuild.plugin.faces;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Modifier;
+import java.nio.channels.FileChannel;
+
import java.util.Iterator;
import org.apache.maven.plugin.MojoExecutionException;
@@ -111,6 +115,48 @@ public class GenerateComponentsMojo exte
}
/**
+ * Copies the contents of sourceFile to destFile
+ * @param sourceFile
+ * @param destFile
+ * @throws IOException
+ */
+ private static void _copyFile(File sourceFile, File destFile) throws IOException
+ {
+ // make sure that the directories exist
+ destFile.getParentFile().mkdirs();
+
+ if (!destFile.exists())
+ {
+ destFile.createNewFile();
+ }
+ else
+ {
+ // make sure we can copy over the file
+ destFile.setWritable(true);
+ }
+
+ FileChannel source = null;
+ FileChannel destination = null;
+
+ try
+ {
+ source = new FileInputStream(sourceFile).getChannel();
+ destination = new FileOutputStream(destFile).getChannel();
+
+ destination.transferFrom(source, 0, source.size());
+ }
+ finally
+ {
+ if (source != null)
+ source.close();
+
+ if (destination != null)
+ destination.close();
+ }
+ }
+
+
+ /**
* Generates a parsed component.
*
* @param component the parsed component metadata
@@ -137,11 +183,9 @@ public class GenerateComponentsMojo exte
try
{
- getLog().debug("Generating " + fullClassName+", with generator: "+generator.getClass().getName());
-
- String sourcePath = Util.convertClassToSourcePath(fullClassName, ".java");
- File targetFile = new File(generatedSourceDirectory, sourcePath);
-
+ getLog().debug("Generating " + fullClassName +
+ ", with generator: " + generator.getClass().getName());
+
StringWriter sw = new StringWriter();
PrettyWriter out = new PrettyWriter(sw);
@@ -176,19 +220,62 @@ public class GenerateComponentsMojo exte
String componentType = component.getComponentType();
+ // Handle both the case where we have the old-style FooTemplate.java that will be
+ // flattened into a single class Foo and the new style Foo.java subclass of
+ // PartialFoo, in which case we generate the package-private PartialFoo class.
+
// Use template file if it exists
String templatePath = Util.convertClassToSourcePath(fullClassName, "Template.java");
File templateFile = new File(templateSourceDirectory, templatePath);
+ boolean hasTemplate = templateFile.exists();
+ String subclassPath = Util.convertClassToSourcePath(fullClassName, ".java");
+ File subclassFile = new File(templateSourceDirectory, subclassPath);
+ boolean hasSubclass = subclassFile.exists();
+
+ // we should never have both the tempalte and the subclass
+ if (hasTemplate && hasSubclass)
+ throw new IllegalStateException("Both old style " + templatePath + " and new style " +
+ subclassPath + " component templates exist!");
+
SourceTemplate template = null;
- if (templateFile.exists())
+
+ String outClassName;
+ String outFullClassName;
+ int defaultConstructorModifier;
+
+ if (hasSubclass)
{
- getLog().debug("Using template " + templatePath);
- template = new SourceTemplate(templateFile);
- template.substitute(className + "Template", className);
- template.readPreface();
+ getLog().debug("Using subclass " + subclassPath);
+
+ outClassName = "Partial" + className;
+ outFullClassName = Util.getPackageFromFullClass(fullClassName) + '.' + outClassName;
+ defaultConstructorModifier = 0; // package pivate
+
+ // copy the file template to the destination directory
+ File destFile = new File(generatedSourceDirectory, subclassPath);
+
+ _copyFile(subclassFile, destFile);
+ destFile.setReadOnly();
+ }
+ else
+ {
+ outClassName = className;
+ outFullClassName = fullClassName;
+ defaultConstructorModifier = Modifier.PUBLIC;
+
+ if (hasTemplate)
+ {
+ getLog().debug("Using template " + templatePath);
+ template = new SourceTemplate(templateFile);
+ template.substitute(className + "Template", className);
+ template.readPreface();
+ }
}
+ String sourcePath = Util.convertClassToSourcePath(outFullClassName, ".java");
+ File targetFile = new File(generatedSourceDirectory, sourcePath);
+
// header/copyright
writePreamble(out);
@@ -202,7 +289,7 @@ public class GenerateComponentsMojo exte
component);
// class
- generator.writeClassBegin(out, className, superclassName, component, template);
+ generator.writeClassBegin(out, outClassName, superclassName, component, template, hasSubclass);
// static final constants
generator.writePropertyValueConstants(out, component);
@@ -215,7 +302,7 @@ public class GenerateComponentsMojo exte
}
// public constructors and methods
- generator.writeConstructor(out, component, Modifier.PUBLIC);
+ generator.writeConstructor(out, component, outClassName, defaultConstructorModifier);
// insert template code
if (template != null)
@@ -248,7 +335,7 @@ public class GenerateComponentsMojo exte
// protected constructors and methods
// TODO: reverse this order, to make protected constructor go first
// for now we want consistency with previous code generation
- generator.writeOther(out, component);
+ generator.writeOther(out, component, outClassName);
generator.writeClassEnd(out);
@@ -323,10 +410,10 @@ public class GenerateComponentsMojo exte
* @parameter
* @required
*/
- private String typePrefix;
+ private String typePrefix;
/**
- * @parameter
+ * @parameter default-value=false
*/
private boolean force;
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java Fri Mar 23 01:11:01 2012
@@ -877,10 +877,10 @@ public class GenerateJspTaglibsMojo exte
generator.writeImports(out, null, packageName, fullSuperclassName, superclassName, componentList);
- generator.writeClassBegin(out, className, superclassName, component, null);
+ generator.writeClassBegin(out, className, superclassName, component, null, false);
int modifiers = component.getTagClassModifiers();
- generator.writeConstructor(out, component, modifiers);
+ generator.writeConstructor(out, component, null, modifiers);
if (!Modifier.isAbstract(modifiers))
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/ClassGenerator.java Fri Mar 23 01:11:01 2012
@@ -54,11 +54,13 @@ public interface ClassGenerator
String className,
String superclassName,
ComponentBean component,
- SourceTemplate template);
+ SourceTemplate template,
+ boolean hasSubclass);
void writeConstructor(
PrettyWriter out,
ComponentBean component,
+ String overrideClassName,
int modifiers) throws IOException;
void writeClassEnd(
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java Fri Mar 23 01:11:01 2012
@@ -65,13 +65,18 @@ public abstract class AbstractComponentG
return _log;
}
+ @Override
public void writeClassBegin(
PrettyWriter out,
String className,
String superclassName,
ComponentBean component,
- SourceTemplate template)
+ SourceTemplate template,
+ boolean createSuperclass)
{
+ if (className == null)
+ throw new NullPointerException();
+
out.println("/**");
// TODO: restore description (needs escaping?)
@@ -150,6 +155,25 @@ public abstract class AbstractComponentG
// TODO: eliminate <mfp:component-class-modifier> metadata
int modifiers = component.getComponentClassModifiers();
+
+ // make abstract superclass classes abstract and package private
+ if (createSuperclass)
+ {
+ // remove all of the access modifiers to make this package provate
+ modifiers &= ~(Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED);
+
+ // force abstract on
+ modifiers |= Modifier.ABSTRACT;
+ }
+ else
+ {
+ // if no modifier is specified, default to public
+ if ((modifiers & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) == 0)
+ {
+ modifiers |= Modifier.PUBLIC;
+ }
+ }
+
String classStart = Modifier.toString(modifiers);
// TODO: use canonical ordering
classStart = classStart.replaceAll("public abstract", "abstract public");
@@ -215,6 +239,7 @@ public abstract class AbstractComponentG
out.indent();
}
+ @Override
public void writeClassEnd(
PrettyWriter out)
{
@@ -222,13 +247,14 @@ public abstract class AbstractComponentG
out.println("}");
}
-
+ @Override
public void writeImports(PrettyWriter out, SourceTemplate template, String packageName, String fullSuperclassName,
String superclassName, Collection components)
{
throw new UnsupportedOperationException("not implemented");
}
+ @Override
public void writeImports(
PrettyWriter out,
SourceTemplate template,
@@ -361,6 +387,7 @@ public abstract class AbstractComponentG
}
}
+ @Override
public void writeGenericConstants(
PrettyWriter out,
String componentFamily,
@@ -373,6 +400,7 @@ public abstract class AbstractComponentG
out.println(" \"" + componentType + "\";");
}
+ @Override
public void writePropertyConstants(
PrettyWriter out,
String superclassName,
@@ -381,6 +409,7 @@ public abstract class AbstractComponentG
// nothing
}
+ @Override
public void writePropertyValueConstants(
PrettyWriter out,
ComponentBean component) throws IOException
@@ -514,41 +543,31 @@ public abstract class AbstractComponentG
}
}
+ @Override
public void writeConstructor(
PrettyWriter out,
ComponentBean component,
+ String overrideClassName,
int modifiers) throws IOException
{
- String fullClassName = component.getComponentClass();
- String className = Util.getClassFromFullClass(fullClassName);
-
- if (Modifier.isPublic(modifiers))
+ String className;
+
+ if (overrideClassName != null)
{
- // 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();
-
- writeConstructorContent(out, component, modifiers, rendererType);
-
- out.unindent();
- out.println("}");
- }
+ className = overrideClassName;
+ }
+ else
+ {
+ String fullClassName = component.getComponentClass();
+ className = Util.getClassFromFullClass(fullClassName);
}
- else if (Modifier.isProtected(modifiers))
+
+ int classModifiers = component.getComponentClassModifiers();
+ boolean isAbstract = Modifier.isAbstract(classModifiers);
+ boolean isPackagePrivate = (modifiers &
+ (Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC)) == 0;
+
+ if (Modifier.isProtected(modifiers))
{
out.println();
out.println("/**");
@@ -573,7 +592,7 @@ public abstract class AbstractComponentG
out.println("}");
// TODO: eliminate this inconsistency
- if (Modifier.isAbstract(component.getComponentClassModifiers()))
+ if (isAbstract)
{
out.println();
out.println("/**");
@@ -589,6 +608,33 @@ public abstract class AbstractComponentG
out.println("}");
}
}
+ else if ((Modifier.isPublic(modifiers) && !isAbstract) || isPackagePrivate)
+ {
+ String accessControl = Modifier.isPublic(modifiers)
+ ? (isAbstract) ? "protected " : "public "
+ : ""; // package private
+
+ 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(accessControl + className + "()");
+ out.println("{");
+ out.indent();
+
+ writeConstructorContent(out, component, modifiers, rendererType);
+
+ out.unindent();
+ out.println("}");
+ }
}
protected abstract void writeConstructorContent(
@@ -832,6 +878,7 @@ public abstract class AbstractComponentG
PrettyWriter out,
PropertyBean property) throws IOException;
+ @Override
public void writeFacetMethods(
PrettyWriter out,
ComponentBean component) throws IOException
@@ -918,6 +965,7 @@ public abstract class AbstractComponentG
out.println("}");
}
+ @Override
public void writeListenerMethods(
PrettyWriter out,
ComponentBean component) throws IOException
@@ -1132,7 +1180,7 @@ public abstract class AbstractComponentG
}
public void writeOther(
- PrettyWriter out, ComponentBean component) throws IOException
+ PrettyWriter out, ComponentBean component, String overrideClassName) throws IOException
{
// nothing
}
@@ -1168,6 +1216,7 @@ public abstract class AbstractComponentG
protected class ResolvableTypeFilter extends PropertyFilter
{
+ @Override
protected boolean accept(
PropertyBean property)
{
@@ -1179,6 +1228,7 @@ public abstract class AbstractComponentG
protected class NonVirtualFilter extends PropertyFilter
{
+ @Override
protected boolean accept(
PropertyBean property)
{
@@ -1189,6 +1239,7 @@ public abstract class AbstractComponentG
protected static class NonOverriddenFilter
extends PropertyFilter
{
+ @Override
protected boolean accept(
PropertyBean property)
{
@@ -1204,7 +1255,7 @@ public abstract class AbstractComponentG
static private Map _createResolvableTypes()
{
- Map resolvableTypes = new HashMap();
+ Map<String, String> resolvableTypes = new HashMap<String, String>();
resolvableTypes.put("boolean", "Boolean");
resolvableTypes.put("char", "Character");
@@ -1226,6 +1277,4 @@ public abstract class AbstractComponentG
static private final Pattern _GENERIC_TYPE = Pattern.compile("([^<]+)<(.+)>");
static final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
-
-
}
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/ComponentGenerator.java Fri Mar 23 01:11:01 2012
@@ -81,7 +81,7 @@ public interface ComponentGenerator exte
ComponentBean component) throws IOException;
void writeOther(
- PrettyWriter out, ComponentBean component) throws IOException;
+ PrettyWriter out, ComponentBean component, String overrideClassName) throws IOException;
void writePropertyMethods(PrettyWriter out,
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java Fri Mar 23 01:11:01 2012
@@ -20,7 +20,6 @@ package org.apache.myfaces.trinidadbuild
import java.io.IOException;
-import java.lang.IllegalArgumentException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -371,11 +370,13 @@ public class TrinidadComponentGenerator
out.println("}");
}
- public void writeOther(PrettyWriter out, ComponentBean component) throws IOException
+ @Override
+ public void writeOther(PrettyWriter out, ComponentBean component, String overrideClassName)
+ throws IOException
{
_writeGetBeanType(out);
- writeConstructor(out, component, Modifier.PROTECTED);
+ writeConstructor(out, component, overrideClassName, Modifier.PROTECTED);
_writeTypeLock(out, component);
}
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractComponentTagGenerator.java Fri Mar 23 01:11:01 2012
@@ -46,7 +46,7 @@ import org.apache.myfaces.trinidadbuild.
*/
public abstract class AbstractComponentTagGenerator implements ComponentTagGenerator
{
-
+ @Override
public void writeImports(PrettyWriter out,
SourceTemplate template,
String packageName,
@@ -60,6 +60,7 @@ public abstract class AbstractComponentT
}
+ @Override
public void writeImports(PrettyWriter out, SourceTemplate template, String packageName, String fullSuperclassName,
String superclassName, Collection components)
{
@@ -117,11 +118,13 @@ public abstract class AbstractComponentT
GeneratorHelper.writeImports(out, packageName, imports);
}
+ @Override
public void writeClassBegin(PrettyWriter out,
String className,
String superclassName,
ComponentBean component,
- SourceTemplate template)
+ SourceTemplate template,
+ boolean hasTemplate)
{
int modifiers = component.getTagClassModifiers();
String classStart = Modifier.toString(modifiers);
@@ -139,12 +142,24 @@ public abstract class AbstractComponentT
}
+ @Override
public void writeConstructor(PrettyWriter out,
ComponentBean component,
+ String overrideClassName,
int modifiers) throws IOException
{
- String fullClassName = component.getTagClass();
- String className = Util.getClassFromFullClass(fullClassName);
+ String className;
+
+ if (overrideClassName != null)
+ {
+ className = overrideClassName;
+ }
+ else
+ {
+ String fullClassName = component.getTagClass();
+ className = Util.getClassFromFullClass(fullClassName);
+ }
+
out.println();
out.println("/**");
// TODO: restore this correctly phrased comment (tense vs. command)
@@ -156,6 +171,7 @@ public abstract class AbstractComponentT
out.println("}");
}
+ @Override
public void writeGetComponentType(
PrettyWriter out,
ComponentBean component) throws IOException
@@ -173,6 +189,7 @@ public abstract class AbstractComponentT
out.println("}");
}
+ @Override
public void writeGetRendererType(
PrettyWriter out,
ComponentBean component) throws IOException
@@ -190,6 +207,7 @@ public abstract class AbstractComponentT
out.println("}");
}
+ @Override
public void writeClassEnd(PrettyWriter out)
{
out.unindent();
@@ -225,6 +243,7 @@ public abstract class AbstractComponentT
return false;
}
+ @Override
public void writePropertyMembers(PrettyWriter out, Collection components) throws IOException
{
for (Iterator<ComponentBean> lIterator = components.iterator(); lIterator.hasNext();)
@@ -233,6 +252,7 @@ public abstract class AbstractComponentT
}
}
+ @Override
public void writeReleaseMethod(PrettyWriter out,
ComponentBean component) throws IOException
{
@@ -242,6 +262,7 @@ public abstract class AbstractComponentT
}
+ @Override
public void writeReleaseMethod(
PrettyWriter out, Collection components) throws IOException
{
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java Fri Mar 23 01:11:01 2012
@@ -121,7 +121,7 @@ public class MyFacesComponentTagGenerato
}
}
-
+ @Override
protected void writePropertyDeclaration(PrettyWriter out,
PropertyBean property) throws IOException
{
@@ -132,6 +132,7 @@ public class MyFacesComponentTagGenerato
out.println("private " + jspPropType + " " + fieldPropName + ";");
}
+ @Override
protected void writePropertySetter(PrettyWriter out,
PropertyBean property) throws IOException
{
@@ -150,6 +151,7 @@ public class MyFacesComponentTagGenerato
out.println("}");
}
+ @Override
public void writeGetComponentType(PrettyWriter out,
ComponentBean component) throws IOException
{
@@ -170,6 +172,7 @@ public class MyFacesComponentTagGenerato
out.println("}");
}
+ @Override
public void writeSetPropertiesMethod(PrettyWriter out,
String componentClass,
ComponentBean component) throws IOException
@@ -214,6 +217,7 @@ public class MyFacesComponentTagGenerato
out.println("}");
}
+ @Override
protected void writeSetPropertyMethodBody(PrettyWriter out,
String componentClass,
Iterator properties) throws IOException
@@ -571,5 +575,4 @@ public class MyFacesComponentTagGenerato
{
return (sig != null && "java.lang.String".equals(sig.getReturnType()));
}
-
}
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/ComponentBean.java Fri Mar 23 01:11:01 2012
@@ -555,16 +555,15 @@ public class ComponentBean extends Abstr
}
}
- protected Map getFlattenedProperties()
+ protected Map<String, PropertyBean> getFlattenedProperties()
{
- Map props = new HashMap(_properties);
+ Map<String, PropertyBean> props = new HashMap<String, PropertyBean>(_properties);
ComponentBean parent = resolveSupertype();
if (parent != null)
{
- Map superProps = parent.getFlattenedProperties();
- for (Iterator<Map.Entry> iter = superProps.entrySet().iterator(); iter.hasNext(); )
+ Map<String, PropertyBean> superProps = parent.getFlattenedProperties();
+ for (Map.Entry<String, PropertyBean> entry : superProps.entrySet())
{
- Map.Entry entry = iter.next();
if (!props.containsKey(entry.getKey()))
{
props.put(entry.getKey(), entry.getValue());
@@ -685,16 +684,15 @@ public class ComponentBean extends Abstr
}
}
- protected Map getFlattenedFacets()
+ protected Map<String, FacetBean> getFlattenedFacets()
{
- Map facets = new HashMap(_facets);
+ Map<String, FacetBean> facets = new HashMap<String, FacetBean>(_facets);
ComponentBean parent = resolveSupertype();
if (parent != null)
{
- Map superFacets = parent.getFlattenedFacets();
- for (Iterator<Map.Entry> iter = superFacets.entrySet().iterator(); iter.hasNext(); )
+ Map<String, FacetBean> superFacets = parent.getFlattenedFacets();
+ for (Map.Entry<String, FacetBean> entry : superFacets.entrySet())
{
- Map.Entry entry = iter.next();
if (!facets.containsKey(entry.getKey()))
{
facets.put(entry.getKey(), entry.getValue());
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/SourceTemplate.java Fri Mar 23 01:11:01 2012
@@ -33,12 +33,12 @@ public class SourceTemplate
_substitutions.put(in, out);
}
- public Set getImports()
+ public Set<String> getImports()
{
return Collections.unmodifiableSet(_imports);
}
- public Set getImplements()
+ public Set<String> getImplements()
{
return Collections.unmodifiableSet(_implements);
}
@@ -74,7 +74,7 @@ public class SourceTemplate
String className = interfaces[i];
if (!Util.isFullClass(className))
{
- String importedName = (String)_fqcnMap.get(className);
+ String importedName = _fqcnMap.get(className);
if (importedName != null)
className = importedName;
}
@@ -119,12 +119,9 @@ public class SourceTemplate
private String _substitute(String in)
{
- Iterator keys = _substitutions.keySet().iterator();
- while (keys.hasNext())
+ for (Map.Entry<String, String> entry : _substitutions.entrySet())
{
- String key = (String) keys.next();
- String value = (String) _substitutions.get(key);
- in = _substitute(in, key, value);
+ in = _substitute(in, entry.getKey(), entry.getValue());
}
return in;
@@ -150,13 +147,13 @@ public class SourceTemplate
return _ignoreMethods;
}
- private File _file;
- private BufferedReader _reader;
- private Set _imports = new HashSet();
- private Map _fqcnMap = new HashMap();
- private Set _implements = new HashSet();
- private Map _substitutions = new HashMap();
- private Set _ignoreMethods = new HashSet();
+ private File _file;
+ private BufferedReader _reader;
+ private Set<String> _imports = new HashSet<String>();
+ private Map<String, String> _fqcnMap = new HashMap<String, String>();
+ private Set<String> _implements = new HashSet<String>();
+ private Map<String, String> _substitutions = new HashMap<String, String>();
+ private Set<String> _ignoreMethods = new HashSet<String>();
// Magic syntax indicating "please ignore this line"
static private final String _IGNORE_PREFIX = "/**/";
Modified: myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/11.1.2.0.0/workspace.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/11.1.2.0.0/workspace.xml?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/11.1.2.0.0/workspace.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/11.1.2.0.0/workspace.xml Fri Mar 23 01:11:01 2012
@@ -28,4 +28,3 @@
</hash>
<list n="listOfChildren" />
</jws:workspace>
-</jws:workspace>
Modified: myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.1.0.0/workspace.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.1.0.0/workspace.xml?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.1.0.0/workspace.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.1.0.0/workspace.xml Fri Mar 23 01:11:01 2012
@@ -28,4 +28,3 @@
</hash>
<list n="listOfChildren" />
</jws:workspace>
-</jws:workspace>
Modified: myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.2.0.0/workspace.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.2.0.0/workspace.xml?rev=1304157&r1=1304156&r2=1304157&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.2.0.0/workspace.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-jdev-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/jdeveloper/12.1.2.0.0/workspace.xml Fri Mar 23 01:11:01 2012
@@ -28,4 +28,3 @@
</hash>
<list n="listOfChildren" />
</jws:workspace>
-</jws:workspace>