Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
[JAVASERVERFACES-13] Taglib generator enhancements Created: 15/Jul/04 26/Jun/12 Resolved: 19/Apr/06 Status: Project: Component/s: Affects Version/s: Fix Version/s: Closed javaserverfaces build 1.1 Type: Reporter: Resolution: Labels: Remaining Estimate: Time Spent: Original Estimate: Environment: Improvement jayashri Fixed None Not Specified Issuezilla Id: 13 2.0 Priority: Assignee: Votes: Minor Ryan Lubke 0 Not Specified Not Specified Operating System: All Platform: All Description Make the Taglib generator generic so that it can accept an XML file containing metadata about the component and generate the tag handler for it. Currently, the tag handler needs some more information than just the metadata which is hardcoded in the generator itself. Ultimately, it would be nice to make it standalone application with its own installer. Comments Comment by Ed Burns [ 23/Aug/04 ] Issue: 13 This change-bundle provides an Ant task for doing the taglib generation. This just extends the Java task and makes the UI slightly more production quality. Updated: Section: RI Changes A src/com/sun/faces/ant/TaglibGenTask.java Extend the java task and call the taglib generator. M build.xml build, define, and leverage the new task SECTION: RI Diffs Index: build.xml =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-tools/build.xml,v retrieving revision 1.32 diff -u -r1.32 build.xml — build.xml 12 May 2004 03:08:49 -0000 1.32 +++ build.xml 23 Aug 2004 15:59:33 -0000 @@ -16,6 +16,7 @@ <property file="build.properties"/> <!-- Component local --> <property file="../build.properties"/> <!-- Commons local --> <property file="$ {user.home} /build.properties"/> <!-- User local --> + <property environment="myenv" /> <property name="Name" value="JavaServer Faces Tools"/> <property name="name" value="jsf-tools"/> @@ -36,6 +37,8 @@ <!-- The locations of necessary jar files --> <property name="junit.jar" value="$ {tomcat.home}/../junit3.8.1/junit.jar"/> + <property name="ant.jar" + value="${myenv.ANT_HOME}/lib/ant.jar" /> <property name="servlet.jar" value="${tomcat.home} /common/lib/servlet-api.jar"/> <property name="jsp.jar" value="$ {tomcat.home}/common/lib/jsp-api.jar"/> <property name="commons-logging.jar" @@ -82,6 +85,7 @@ <pathelement location="${build.classes}"/> <pathelement location="${servlet.jar}"/> <pathelement location="${jsp.jar}"/> + <pathelement location="${ant.jar}"/> </path> <path id="run.classpath"> @@ -221,13 +225,12 @@ if="standard-html-renderkit-impl" unless="skip.taglib.generation"> - <java fork="yes" - classname="com.sun.faces.generate.HtmlTaglibGenerator"> - <!-- <jvmarg line="${debug.jvm.args}"/> --> - <classpath refid="compile.classpath" /> - <classpath refid="run.classpath" /> + <generateTaglib inputfile="${build.temp}/standard-html-renderkit.xml" + tlddir="${build.generate.tld}" + destdir="${build.generate}" fork="yes" + dtd="-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN|${jsf-api.dir}/doc/web-facesconfig_1_0.dtd|-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN|${jsf-api.dir}/doc/web-facesconfig_1_1.dtd" + copyright="${basedir}/COPYRIGHT" + tagdef="${basedir}/TAG-DEF"> <sysproperty key="java.endorsed.dirs" value="${tomcat.home} /jaxp/lib/endorsed"/> @@ -241,21 +244,11 @@ value="$ {log.digester} "/> <sysproperty key="org.apache.commons.logging.simplelog.log.org.apache.commons.digester.Digester.sax" value="$ {log.sax} "/> + <!-- <jvmarg line="$ {debug.jvm.args} "/> --> + <classpath refid="compile.classpath" /> + <classpath refid="run.classpath" /> <arg value="--config"/> <arg value="$ {build.temp} /standard-html-renderkit.xml"/> <arg value="--tlddir"/> <arg value="$ {build.generate.tld} "/> <arg value="--dir"/> <arg value="$ {build.generate} "/> <arg value="--dtd"/> <arg value="-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN|$ {jsf-api.dir}/doc/web-facesconfig_1_0.dtd|-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN|${jsf-api.dir} /doc/web-facesconfig_1_1.dtd"/> <arg value="--copyright"/> <arg value="$ {basedir}/COPYRIGHT"/> - <arg value="--tagdef"/> - <arg value="${basedir} /TAG-DEF"/> - </java> + </generateTaglib> </target> @@ -270,6 +263,12 @@ <classpath refid="compile.classpath" /> <classpath refid="run.classpath" /> </javac> + + <taskdef name="generateTaglib" classname="com.sun.faces.ant.TaglibGenTask"> + <classpath> + <pathelement location="$ {build.classes}" /> + </classpath> + </taskdef> <copy todir="${build.classes} "> <fileset dir="$ {src.dir} "> SECTION: RI New Files /* Copyright 2004 Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package com.sun.faces.ant; import java.util.List; import java.util.Map; import java.util.ArrayList; import java.util.Iterator; import java.util.HashMap; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.taskdefs.Java; public class TaglibGenTask extends Java { private Map arguments; public TaglibGenTask() { arguments = new HashMap(); } public void setInputFile(String newInputFile) { arguments.put("--config", newInputFile); } public void setDestdir(String newDir) { arguments.put("--dir", newDir); } public void setTlddir(String newTlddir) { arguments.put("--tlddir", newTlddir); } public void setDtd(String newDtd) { arguments.put("--dtd", newDtd); } public void setTagdef(String newTagdef) { arguments.put("--tagdef", newTagdef); } public void setCopyright(String newCopyright) { arguments.put("--copyright", newCopyright); } public void execute() throws BuildException { Iterator iter = null; Object curObj = null; Commandline.Argument arg = null; iter = arguments.keySet().iterator(); while (iter.hasNext()) { curObj = iter.next(); arg = super.createArg(); arg.setValue(curObj.toString()); arg = super.createArg(); arg.setValue(arguments.get(curObj).toString()); } super.setClassname("com.sun.faces.generate.HtmlTaglibGenerator"); super.execute(); } } Comment by Ryan Lubke [ 23/Aug/04 ] Can we get rid of the dtd argument? Maybe just include the DTDs with the distribution jar of the final prodcut and register them internally (similar to what is done in the RI). Comment by Ed Burns [ 24/Aug/04 ] Issue: 13 This change-bundle provides an Ant task for doing the taglib generation. This just extends the Java task and makes the UI slightly more production quality. Section: Tools Changes M build.xml run the built classes from jsf-tools.jar, not from build/classes copy the DTDs from jsf-api to META-INF in the jsf-tools.jar A src/com/sun/faces/ant/TaglibGenTask.java Java.java extension that runs the HtmlTaglibGenerator M src/com/sun/faces/generate/AbstractGenerator.java modify the digester() method to take an array of DTD/URL.toString() pairs instead of taking DTD/absoluteFile pairs. This is necessary because the default DTDs come from the jsf-tools.jar. M src/com/sun/faces/generate/HtmlComponentGenerator.java M src/com/sun/faces/generate/HtmlTaglibGenerator.java take the mods of the digester() method into account and pass in an array of DTD/URL.toString() pairs, instead of passing in an array of DTD/absoluteFile pairs. SECTION: Tools Diffs Index: build.xml =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-tools/build.xml,v retrieving revision 1.32 diff -u -r1.32 build.xml — build.xml 12 May 2004 03:08:49 -0000 1.32 +++ build.xml 24 Aug 2004 16:17:42 -0000 @@ -16,6 +16,7 @@ <property file="build.properties"/> <!-- Component local --> <property file="../build.properties"/> <!-- Commons local --> <property file="$ {user.home} /build.properties"/> <!-- User local --> + <property environment="myenv" /> <property name="Name" value="JavaServer Faces Tools"/> <property name="name" value="jsf-tools"/> @@ -36,6 +37,8 @@ <!-- The locations of necessary jar files --> <property name="junit.jar" value="$ {tomcat.home}/../junit3.8.1/junit.jar"/> + <property name="ant.jar" + value="${myenv.ANT_HOME}/lib/ant.jar" /> <property name="servlet.jar" value="${tomcat.home} /common/lib/servlet-api.jar"/> <property name="jsp.jar" value="$ {tomcat.home}/common/lib/jsp-api.jar"/> <property name="commons-logging.jar" @@ -82,10 +85,11 @@ <pathelement location="${build.classes}"/> <pathelement location="${servlet.jar}"/> <pathelement location="${jsp.jar}"/> + <pathelement location="${ant.jar}"/> </path> <path id="run.classpath"> - <pathelement location="${build.classes}"/> + <pathelement location="${build.dir}/${name}.jar"/> <pathelement location="${build.test}"/> <pathelement location="${junit.jar}"/> <pathelement location="${servlet.jar}"/> @@ -113,10 +117,14 @@ <mkdir dir="${build.generate}"/> <mkdir dir="${build.generate.facesdoc}"/> <mkdir dir="${build.generate.tld}"/> + <mkdir dir="${build.classes}/META-INF"/> <mkdir dir="${build.temp}"/> <copy todir="${build.temp}"> <fileset dir="${jsf-api.dir}/doc" includes="*.xml"/> </copy> + <copy todir="${build.classes}/META-INF"> + <fileset dir="${jsf-api.dir}/doc" includes="*.dtd"/> + </copy> <copy todir="${build.temp}" file="${standard-html-renderkit-impl}"/> </target> @@ -221,13 +229,11 @@ if="standard-html-renderkit-impl" unless="skip.taglib.generation"> - <java fork="yes" - classname="com.sun.faces.generate.HtmlTaglibGenerator"> - <!-- <jvmarg line="${debug.jvm.args}"/> --> - <classpath refid="compile.classpath" /> - <classpath refid="run.classpath" /> + <generateTaglib inputfile="${build.temp}/standard-html-renderkit.xml" + tlddir="${build.generate.tld}" + destdir="${build.generate}" fork="yes" + copyright="${basedir}/COPYRIGHT" + tagdef="${basedir}/TAG-DEF"> <sysproperty key="java.endorsed.dirs" value="${tomcat.home} /jaxp/lib/endorsed"/> @@ -241,21 +247,10 @@ value="$ {log.digester} "/> <sysproperty key="org.apache.commons.logging.simplelog.log.org.apache.commons.digester.Digester.sax" value="$ {log.sax} "/> + <!-- <jvmarg line="$ {debug.jvm.args} "/> --> + <classpath refid="run.classpath" /> <arg value="--config"/> <arg value="$ {build.temp} /standard-html-renderkit.xml"/> <arg value="--tlddir"/> <arg value="$ {build.generate.tld} "/> <arg value="--dir"/> <arg value="$ {build.generate} "/> <arg value="--dtd"/> <arg value="-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN|$ {jsf-api.dir}/doc/web-facesconfig_1_0.dtd|-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN|${jsf-api.dir} /doc/web-facesconfig_1_1.dtd"/> <arg value="--copyright"/> <arg value="$ {basedir}/COPYRIGHT"/> - <arg value="--tagdef"/> - <arg value="${basedir} /TAG-DEF"/> - </java> + </generateTaglib> </target> @@ -271,12 +266,22 @@ <classpath refid="run.classpath" /> </javac> + <echo file="$ {build.classes}/com/sun/faces/whaat" message="cosby" /> + + <taskdef name="generateTaglib" classname="com.sun.faces.ant.TaglibGenTask"> + <classpath> + <pathelement location="${build.classes} " /> + </classpath> + </taskdef> + <copy todir="$ {build.classes}"> <fileset dir="${src.dir}"> <exclude name="*/.java" /> </fileset> </copy> + <jar destfile="${build.dir}/${name}.jar" basedir="${build.classes} " /> + </target> <target name="jcov.tools" > @@ -477,5 +482,6 @@ </zip> </target> + </project> Index: src/com/sun/faces/generate/AbstractGenerator.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-tools/src/com/sun/faces/generate/AbstractGenerator.java,v retrieving revision 1.5 diff -u -r1.5 AbstractGenerator.java — src/com/sun/faces/generate/AbstractGenerator.java 12 May 2004 03:08:49 -0000 1.5 +++ src/com/sun/faces/generate/AbstractGenerator.java 24 Aug 2004 16:17:44 -0000 @@ -1,5 +1,5 @@ /* * $Id: AbstractGenerator.java,v 1.5 2004/05/12 03:08:49 rkitain Exp $ + * $Id: AbstractGenerator.java,v 1.5.22.1 2004/08/24 00:09:53 edburns Exp $ */ /* @@ -202,8 +202,8 @@ <p>Configure and return a <code>Digester</code> instance suitable for use in the environment specified by our parameter flags.</p> * * @param dtd[] array of absolute pathnames of the DTDs to be registered (if any) * and their corresponding public identifiers + * @param dtd[] array of toString()'d URLs to DTDs to be registered + * (if any) and their corresponding public identifiers @param design Include rules suitable for design time use in a tool @param generate Include rules suitable for generating component, renderer, and tag classes @@ -229,7 +229,7 @@ int i = 0; while (dtd.length > 0) { if (dtd[i] != null && dtd[i+1] != null) { - digester.register(dtd[i], (new File(dtd[i+1])).toURL().toString()); + digester.register(dtd[i], dtd[i+1]); } i += 2; if (i >= dtd.length) { Index: src/com/sun/faces/generate/HtmlComponentGenerator.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsftools/src/com/sun/faces/generate/HtmlComponentGenerator.java,v retrieving revision 1.7 diff -u -r1.7 HtmlComponentGenerator.java src/com/sun/faces/generate/HtmlComponentGenerator.java 12 May 2004 03:08:49 -0000 1.7 +++ src/com/sun/faces/generate/HtmlComponentGenerator.java 24 Aug 2004 16:17:47 -0000 @@ -1,5 +1,5 @@ /* * $Id: HtmlComponentGenerator.java,v 1.7 2004/05/12 03:08:49 rkitain Exp $ + * $Id: HtmlComponentGenerator.java,v 1.7.22.1 2004/08/24 00:09:53 edburns Exp $ */ /* @@ -535,7 +535,15 @@ String[] dtds = new String[arrayLen]; int i=0; while (st.hasMoreTokens()) { dtds[i] = st.nextToken(); + // even numbered elements are left alone + if (0 == (i % 2)) { + dtds[i] = st.nextToken(); + } + else { + // odd numbered elements are treated as absolute + // filenames + dtds[i] =(new File(st.nextToken())).toURL().toString(); + } i++; } Index: src/com/sun/faces/generate/HtmlTaglibGenerator.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-tools/src/com/sun/faces/generate/HtmlTaglibGenerator.java,v retrieving revision 1.26 diff -u -r1.26 HtmlTaglibGenerator.java — src/com/sun/faces/generate/HtmlTaglibGenerator.java 12 May 2004 03:08:50 -0000 1.26 +++ src/com/sun/faces/generate/HtmlTaglibGenerator.java 24 Aug 2004 16:17:52 -0000 @@ -28,6 +28,8 @@ import java.util.StringTokenizer; import java.util.TreeMap; +import java.net.URL; + import org.apache.commons.digester.Digester; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -1195,18 +1197,43 @@ log.debug("Configuring digester instance with public identifiers and DTD '" + dtd + "'"); } StringTokenizer st = new StringTokenizer(dtd, "|"); int arrayLen = st.countTokens(); if (arrayLen == 0) { // PENDING I18n throw new Exception("No DTDs specified"); + + String[] dtds = null; + + // this if-else block populates the dtds array according to + // the expectations of the digester() method. + if (null == dtd) { + ClassLoader cl =Thread.currentThread().getContextClassLoader(); + dtds = new String[4]; + dtds[0] = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"; + dtds[1] = ((URL)cl.getResource("META-INF/webfacesconfig_1_0.dtd")).toString(); + dtds[2] = "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN|"; + dtds[3] = ((URL) cl.getResource("META-INF/webfacesconfig_1_1.dtd")).toString(); + } String[] dtds = new String[arrayLen]; int i=0; while (st.hasMoreTokens()) { dtds[i] = st.nextToken(); i++; + else { + StringTokenizer st = new StringTokenizer(dtd, "|"); + int arrayLen = st.countTokens(); + if (arrayLen == 0) { + // PENDING I18n + throw new Exception("No DTDs specified"); + } + dtds = new String[arrayLen]; + int i=0; + while (st.hasMoreTokens()) Unknown macro: {+ // even numbered elements are left alone+ if (0 == (i % 2)) { + dtds[i] = st.nextToken(); + }+ else { + // odd numbered elements are treated as absolute + // filenames + dtds[i] =(new File(st.nextToken())).toURL().toString(); + }+ i++;+ } } + copyright((String) options.get("--copyright")); directories((String) options.get("--tlddir"), false); Digester digester = digester(dtds, false, true, false); SECTION: Tools new files /* Copyright 2004 Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package com.sun.faces.ant; import java.util.List; import java.util.Map; import java.util.ArrayList; import java.util.Iterator; import java.util.HashMap; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.taskdefs.Java; public class TaglibGenTask extends Java { private Map arguments; public TaglibGenTask() { arguments = new HashMap(); } public void setInputFile(String newInputFile) { arguments.put("--config", newInputFile); } public void setDestdir(String newDir) { arguments.put("--dir", newDir); } public void setTlddir(String newTlddir) { arguments.put("--tlddir", newTlddir); } public void setDtd(String newDtd) { arguments.put("--dtd", newDtd); } public void setTagdef(String newTagdef) { arguments.put("--tagdef", newTagdef); } public void setCopyright(String newCopyright) { arguments.put("--copyright", newCopyright); } public void execute() throws BuildException { Iterator iter = null; Object curObj = null; Commandline.Argument arg = null; iter = arguments.keySet().iterator(); while (iter.hasNext()) { curObj = iter.next(); arg = super.createArg(); arg.setValue(curObj.toString()); arg = super.createArg(); arg.setValue(arguments.get(curObj).toString()); } super.setClassname("com.sun.faces.generate.HtmlTaglibGenerator"); super.execute(); } } Comment by Ryan Lubke [ 24/Aug/04 ] r=rlubke Comment by jayashri [ 13/Oct/04 ] This feature is targeted for JSF 2.0 Comment by jayashri [ 13/Apr/05 ] Ryan, could you please a brief description of the changes and close this issue. Thanks Comment by Ryan Lubke [ 14/Apr/05 ] Brief summary of changes: moved triggers for special case logic from being hard coded in classes to being configured in property files (next rev will have the triggers present in the metadata within standard-html-renderkit.xml) added simple ant tasks for each of the generators Updated generator code to be a little more extensible so it should be easier to update based on needs Comment by Manfred Riem [ 10/Feb/12 ] Closing out issue Generated at Thu May 11 22:25:52 UTC 2017 using JIRA 6.2.3#6260sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.