JBoss Rich Faces SVN: r17338 - root/docs/trunk/Developer_Guide/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-05-28 03:03:55 -0400 (Fri, 28 May 2010)
New Revision: 17338
Modified:
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml
Log:
Revising Maven archetype sections: RF-8648
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml 2010-05-28 01:40:33 UTC (rev 17337)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml 2010-05-28 07:03:55 UTC (rev 17338)
@@ -167,11 +167,17 @@
</section>
<section id="sect-Component_Reference-Using_RichFaces_with_Maven-Using_the_RichFaces_project_archetype">
<title>Using the <productname>RichFaces</productname> project archetype</title>
+ <para>
+ A Maven archetype is a template for creating projects. <productname>Maven</productname> uses an archetype to generate a directory structure and files for a particular project, as well as creating <filename>pom.xml</filename> files that contain build instructions.
+ </para>
+ <para>
+ The RichFaces Component Development Kit includes a Maven archetype for generating the basic structure and requirements for a RichFaces application project. The archetype is named <filename>richfaces-archetype-simpleapp</filename> and is included as part of the RichFaces Component Development Kit (<acronym>CDK</acronym>), but Maven can obtain it from the JBoss repository at <filename>https://repository.jboss.org/nexus/content/groups/public/</filename>. Follow the procedure in this section to generate a new Maven-based RichFaces project using the archetype.
+ </para>
<procedure>
<step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories">
- <title>Add required repositories</title>
+ <title>Add required repository</title>
<para>
- A structure for the project with minimal content can be created with the Maven archetype named <filename>maven-archetype-jsfwebapp</filename> <remark>(may be renamed in a later release)</remark> included as part of the RichFaces Component Development Kit (<acronym>CDK</acronym>). The archetype and the project itself require the JBoss repository to be provided (<filename>https://repository.jboss.org/nexus/content/groups/public/</filename>). To make the repositories accessible to Maven, add a profile in the <filename><replaceable>maven_installation_folder</replaceable>/conf/settings.xml</filename> file under the <sgmltag><profiles></sgmltag> element:
+ The details for the JBoss repository need to be added to <productname>Maven</productname> so it can access the archetype. Add a profile in the <filename><replaceable>maven_installation_folder</replaceable>/conf/settings.xml</filename> file under the <sgmltag><profiles></sgmltag> element:
</para>
<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
@@ -185,19 +191,17 @@
</step>
<step id="step-Developer_Guide-Using_RichFaces_with_Maven-Generate_the_project_from_the_archetype">
<title>Generate the project from the archetype</title>
-
- <!--
- <remark>ONCE 4.0 ARCHETYPE IS COMPLETE:</remark>
<para>
- The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> <remark>(may be renamed in a later release)</remark> archetype. Create a new directory for your project, then run the following Maven command:
+ The project can now be generated with the <filename>richfaces-archetype-simpleapp</filename> archetype. Create a new directory for your project, then run the following Maven command in the directory:
</para>
- <screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=4.0.0-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable></screen>
- -->
+ <screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.archetypes -DarchetypeArtifactId=richfaces-archetype-simpleapp -DarchetypeVersion=4.0.0-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>new_project</replaceable></screen>
+<!--
<para>
- The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> archetype. The archetype for <productname>RichFaces 4.0</productname> is still in development; use the archetype for <productname>RichFaces 3.3.3</productname> to generate a project until the 4.0 archetype is released. Create a new directory for your project, then run the following Maven command:
+ The project can now be generated with the <filename>richfaces-archetype-simpleapp</filename> archetype. The archetype for <productname>RichFaces 4.0</productname> is still in development; use the archetype for <productname>RichFaces 3.3.3</productname> to generate a project until the 4.0 archetype is released. Create a new directory for your project, then run the following Maven command:
</para>
<screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=3.3.3-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable></screen>
+-->
<para>
The following parameters can be used to customize your project:
</para>
@@ -220,49 +224,51 @@
</varlistentry>
</variablelist>
<para>
- The command generates a JSF project with the following structure:
+ The command generates a new RichFaces project with the following structure:
</para>
- <screen><replaceable>jsf-app</replaceable>
+ <screen><replaceable>new_project</replaceable>
├── <filename>pom.xml</filename>
└── <filename>src</filename>
- ├── <filename>main</filename>
- │ ├── <filename>java</filename>
- │ │ └── <filename>org</filename>
- │ │ └── <filename>docs</filename>
- │ │ └── <filename>richfaces</filename>
- │ │ └── <filename>Bean.java</filename>
- │ ├── <filename>resources</filename>
- │ └── <filename>webapp</filename>
- │ ├── <filename>WEB-INF</filename>
- │ │ ├── <filename>faces-config.xml</filename>
- │ │ └── <filename>web.xml</filename>
- │ ├── <filename>index.xhtml</filename>
- │ └── <filename>pages</filename>
- │ └── <filename>index.xhtml</filename>
+ └── <filename>main</filename>
+ ├── <filename>java</filename>
+ │ └── <filename>org</filename>
+ │ └── <filename>docs</filename>
+ │ └── <filename>richfaces</filename>
+ │ └── <filename>RichBean.java</filename>
+ └── <filename>webapp</filename>
+ ├── <filename>index.xhtml</filename>
+ ├── <filename>templates</filename>
+ │ └── <filename>template.xhtml</filename>
+ └── <filename>WEB-INF</filename>
+ ├── <filename>faces-config.xml</filename>
+ └── <filename>web.xml</filename><!--
└── <filename>test</filename>
└── <filename>java</filename>
└── <filename>org</filename>
└── <filename>docs</filename>
└── <filename>richfaces</filename>
- └── <filename>BeanTest.java</filename></screen>
+ └── <filename>BeanTest.java</filename>--></screen>
</step>
+
<step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_dependencies">
- <title>Add dependencies</title>
+ <!-- Remove this step for Enterprise documentation -->
+ <title>Add test dependencies (optional)</title>
<para>
- Your root directory of your project contains a project descriptor file, <filename>pom.xml</filename>. To add RichFaces libraries to your project, edit the project descriptor to add dependencies to the <sgmltag><dependencies></sgmltag> element as follows:
+ Your root directory of your project contains a project descriptor file, <filename>pom.xml</filename>.
+<!--
+ To add RichFaces libraries to your project, edit the project descriptor to add dependencies to the <sgmltag><dependencies></sgmltag> element as follows:
</para>
<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Add_dependencies.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
- <!-- Remove the following for Enterprise documentation -->
+
<para>
+-->
If you wish to include modules for test-driven JSF development, add any dependencies for the tests to the <filename>pom.xml</filename> file. For full details on how to use the <productname>jsf-test</productname> project, refer to <ulink url="http://community.jboss.org/docs/DOC-13155">http://community.jboss.org/wiki/TestDrivenJSFDevelopment</ulink>.
</para>
</step>
- <!--
- <remark>REMOVE ONCE 4.0 ARCHETYPE IS COMPLETE</remark>
- -->
+<!--
<step id="step-Developer_Guide-Using_RichFaces_with_Maven-Update_the_generated_project">
<title>Update the generated project</title>
<para>
@@ -271,7 +277,6 @@
<para>
RichFaces &VERSION; uses Facelets and does not support JSP. Any <filename>index.jsp</filename> pages that were generated need to forward <filename>home.jsf</filename> page equivalents.
</para>
- <!--
<substeps>
<step>
<title>Deactivate the VDL view handler</title>
@@ -281,8 +286,8 @@
<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Update_the_generated_project.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</step>
</substeps>
- -->
</step>
+-->
<step id="step-Developer_Guide-Using_RichFaces_with_Maven-Build_the_project">
<title>Build the project</title>
@@ -290,15 +295,19 @@
Build the project from the command line by entering the <command>mvn install</command> command.
</para>
<para>
- The <computeroutput>BUILD SUCCESSFUL</computeroutput> message indicates the project has been assembled and is ready to import into an IDE (integrated development environment).
+ The <computeroutput>BUILD SUCCESSFUL</computeroutput> message indicates the project has been assembled and is ready to import into an IDE (integrated development environment), such as <productname>JBoss Tools</productname>.
</para>
</step>
<step id="step-Developer_Guide-Build_the_project-Building_for_Eclipse_and_JBoss_Tools">
<title>Import the project into an IDE</title>
<para>
- Import the Maven project into your IDE. For <application>Eclipse</application> and <application>JBoss Tools</application>, you can either use <application>Maven</application> to prepare the project, or import the project using the <productname>M2Eclipse</productname> plug-in.
+ Import the Maven project into your IDE. For <application>Eclipse</application> and <application>JBoss Tools</application>, you can import the project using the <productname>M2Eclipse</productname> plug-in.
</para>
+ <para>
+ To install the plug-in, choose <menuchoice><guimenu>Help</guimenu><guimenuitem>Install New Software</guimenuitem></menuchoice> from the menu. Type <literal>Maven</literal> to locate the <guilabel>Maven Integration for Eclipse Update Site</guilabel> entry, then type <literal>Maven</literal> in the filter to show the available plug-ins. Follow the prompts to install the <guilabel>Maven Integration for Eclipse</guilabel> plug-in.
+ </para>
+ <!--
<stepalternatives>
<step>
<title>Using <application>Maven</application> to prepare the project for <application>Eclipse</application></title>
@@ -313,19 +322,24 @@
<step>
<title>Using the <productname>M2Eclipse</productname> plug-in</title>
<para>
- Alternatively, you can import a <application>Maven</application> project into <application>Eclipse</application> and <application>JBoss Tools</application> using the <productname>M2Eclipse</productname> plug-in. With the plug-in installed, open the importing wizard by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Import</guimenuitem></menuchoice> from the menu. Select <menuchoice><guimenu>Maven</guimenu><guimenuitem>Existing Maven Projects</guimenuitem></menuchoice> as the import source and choose the <filename>pom.xml</filename> file for your project.
+ Alternatively, you can import a <application>Maven</application> project into <application>Eclipse</application> and <application>JBoss Tools</application> using the <productname>M2Eclipse</productname> plug-in.
+-->
+ <para>
+ With the plug-in installed, open the importing wizard by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Import</guimenuitem></menuchoice> from the menu. Select <menuchoice><guimenu>Maven</guimenu><guimenuitem>Existing Maven Projects</guimenuitem></menuchoice> as the import source and choose the <filename>pom.xml</filename> file for your project.
</para>
+<!--
</step>
</stepalternatives>
+-->
</step>
- <!--
+<!--
<step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_tag_library_references">
<title>Add tag library references</title>
<para>
After importing, edit the <filename><replaceable>jsf-app</replaceable>/src/main/webapp/pages/index.xhtml</filename> file to include the tag library declaration as described in <xref linkend="step-Developer_Guide-Creating_a_project-Reference_the_tag_libraries" /> of <xref linkend="sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project" />.
</para>
</step>
- -->
+-->
</procedure>
<para>
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml 2010-05-28 01:40:33 UTC (rev 17337)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml 2010-05-28 07:03:55 UTC (rev 17338)
@@ -542,7 +542,7 @@
</step>
</procedure>
<para>
- You can now add the compiled libraries to your project as described in <xref linkend="step-Developer_Guide-Creating_a_project-Add_the_RichFaces_libraries_to_the_project" />.
+ You can now add the compiled libraries to your project as described in <xref linkend="step-Developer_Guide-Creating_a_project-Add_the_RichFaces_libraries_to_the_project" /> of <xref linkend="sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project_with_JBoss_Tools" />.
</para>
</section>
15 years, 4 months
JBoss Rich Faces SVN: r17337 - in root/ui/dist/trunk: richfaces-components-impl and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-27 21:40:33 -0400 (Thu, 27 May 2010)
New Revision: 17337
Modified:
root/ui/dist/trunk/richfaces-components-api/pom.xml
root/ui/dist/trunk/richfaces-components-impl/pom.xml
root/ui/dist/trunk/richfaces-components-ui/pom.xml
Log:
faces-shade-transformers module initial check-in
Modified: root/ui/dist/trunk/richfaces-components-api/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-api/pom.xml 2010-05-28 01:39:29 UTC (rev 17336)
+++ root/ui/dist/trunk/richfaces-components-api/pom.xml 2010-05-28 01:40:33 UTC (rev 17337)
@@ -37,6 +37,7 @@
<properties>
<assembly.projects.group>org.richfaces.ui</assembly.projects.group>
+ <faces-shade-transformers.version>4.0.0-SNAPSHOT</faces-shade-transformers.version>
</properties>
<dependencyManagement>
@@ -132,6 +133,13 @@
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.build.resources</groupId>
+ <artifactId>faces-shade-transformers</artifactId>
+ <version>${faces-shade-transformers.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
<!-- unpack necessary dependencies for collecting javadocs -->
Modified: root/ui/dist/trunk/richfaces-components-impl/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-impl/pom.xml 2010-05-28 01:39:29 UTC (rev 17336)
+++ root/ui/dist/trunk/richfaces-components-impl/pom.xml 2010-05-28 01:40:33 UTC (rev 17337)
@@ -35,6 +35,10 @@
<packaging>jar</packaging>
<name>Richfaces UI Components Impl</name>
+ <properties>
+ <faces-shade-transformers.version>4.0.0-SNAPSHOT</faces-shade-transformers.version>
+ </properties>
+
<dependencyManagement>
<dependencies>
<dependency>
@@ -164,6 +168,13 @@
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.build.resources</groupId>
+ <artifactId>faces-shade-transformers</artifactId>
+ <version>${faces-shade-transformers.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
Modified: root/ui/dist/trunk/richfaces-components-ui/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-ui/pom.xml 2010-05-28 01:39:29 UTC (rev 17336)
+++ root/ui/dist/trunk/richfaces-components-ui/pom.xml 2010-05-28 01:40:33 UTC (rev 17337)
@@ -35,7 +35,8 @@
<packaging>jar</packaging>
<name>Richfaces UI Components UI</name>
- <properties>
+ <properties>
+ <faces-shade-transformers.version>4.0.0-SNAPSHOT</faces-shade-transformers.version>
<assembly.projects.group>org.richfaces.ui</assembly.projects.group>
</properties>
@@ -153,9 +154,30 @@
</includes>
</artifactSet>
<createSourcesJar>true</createSourcesJar>
+ <transformers>
+ <transformer implementation="org.richfaces.build.shade.resource.TaglibXmlResourceTransformer">
+ <taglibs>
+ <taglib>
+ <targetNamespace>http://richfaces.org/a4j</targetNamespace>
+ </taglib>
+ <taglib>
+ <targetNamespace>http://richfaces.org/rich</targetNamespace>
+ <sourceNamespacesPattern>.*</sourceNamespacesPattern>
+ </taglib>
+ </taglibs>
+ </transformer>
+ <transformer implementation="org.richfaces.build.shade.resource.FacesConfigXmlResourceTransformer" />
+ </transformers>
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.build.resources</groupId>
+ <artifactId>faces-shade-transformers</artifactId>
+ <version>${faces-shade-transformers.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
<!-- unpack necessary dependencies for collecting jsdoc and javadocs -->
15 years, 4 months
JBoss Rich Faces SVN: r17336 - in root: build/resources/trunk and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-05-27 21:39:29 -0400 (Thu, 27 May 2010)
New Revision: 17336
Added:
root/build/resources/trunk/faces-shade-transformers/
root/build/resources/trunk/faces-shade-transformers/pom.xml
root/build/resources/trunk/faces-shade-transformers/src/
root/build/resources/trunk/faces-shade-transformers/src/main/
root/build/resources/trunk/faces-shade-transformers/src/main/java/
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/BaseFacesResourceTransformer.java
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/ElementsComparator.java
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/FacesConfigXmlResourceTransformer.java
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/Taglib.java
root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/TaglibXmlResourceTransformer.java
Modified:
root/pom.xml
Log:
faces-shade-transformers module initial check-in
Added: root/build/resources/trunk/faces-shade-transformers/pom.xml
===================================================================
--- root/build/resources/trunk/faces-shade-transformers/pom.xml (rev 0)
+++ root/build/resources/trunk/faces-shade-transformers/pom.xml 2010-05-28 01:39:29 UTC (rev 17336)
@@ -0,0 +1,46 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-parent</artifactId>
+ <version>6</version>
+ </parent>
+
+ <groupId>org.richfaces.build.resources</groupId>
+ <artifactId>faces-shade-transformers</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>JSF configuration files ransformers for maven-shade-plugin</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ </dependencies>
+</project>
Added: root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/BaseFacesResourceTransformer.java
===================================================================
--- root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/BaseFacesResourceTransformer.java (rev 0)
+++ root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/BaseFacesResourceTransformer.java 2010-05-28 01:39:29 UTC (rev 17336)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.build.shade.resource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.apache.maven.plugins.shade.resource.ResourceTransformer;
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.Namespace;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.jdom.xpath.XPath;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class BaseFacesResourceTransformer implements ResourceTransformer {
+
+ protected static final String META_INF_PATH = "META-INF/";
+
+ protected static final String JAVAEE_URI = "http://java.sun.com/xml/ns/javaee";
+
+ protected static final String JAVAEE_PREFIX = "javaee";
+
+ protected static final Namespace JAVAEE_NAMESPACE = Namespace.getNamespace(JAVAEE_PREFIX, JAVAEE_URI);
+
+ protected static final Namespace XSI_NAMESPACE = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
+
+ protected static XPath createXPath(String path) throws JDOMException {
+ XPath xPath = XPath.newInstance(path);
+ xPath.addNamespace(JAVAEE_NAMESPACE);
+ xPath.addNamespace(XSI_NAMESPACE);
+
+ return xPath;
+ }
+
+ protected void addSchemaLocation(Element element, String schemaLocation) {
+ if (schemaLocation != null && schemaLocation.length() != 0) {
+ element.setAttribute("schemaLocation", JAVAEE_URI + " " + schemaLocation, XSI_NAMESPACE);
+ }
+ }
+
+ private void updateNamespaceRecursively(Object object) {
+ if (object instanceof Element) {
+ Element element = (Element) object;
+
+ if (JAVAEE_URI.equals(element.getNamespaceURI())) {
+ element.setNamespace(JAVAEE_NAMESPACE);
+ }
+
+ for (Object attributeObject : element.getAttributes()) {
+ Attribute attribute = (Attribute) attributeObject;
+
+ if (JAVAEE_URI.equals(attribute.getNamespaceURI())) {
+ attribute.setNamespace(JAVAEE_NAMESPACE);
+ }
+ }
+
+ for (Object child : element.getChildren()) {
+ updateNamespaceRecursively(child);
+ }
+ }
+ }
+
+ protected boolean isJavaEEOrDefaultNamespace(Element element) {
+ String namespaceURI = element.getNamespaceURI();
+ if (namespaceURI == null || namespaceURI.length() == 0) {
+ return true;
+ }
+
+ return JAVAEE_URI.equals(namespaceURI);
+ }
+
+ protected Element cloneAndImportElement(Element element) {
+ Element clonedElement = (Element) element.clone();
+ updateNamespaceRecursively(clonedElement);
+ return clonedElement;
+ }
+
+ protected List<Element> cloneAndImportElements(List<Element> elements) {
+ List<Element> result = new ArrayList<Element>(elements.size());
+ for (Element element : elements) {
+ result.add(cloneAndImportElement(element));
+ }
+
+ return result;
+ }
+
+ protected void appendToStream(String resourceName, Document document, JarOutputStream jos) throws IOException {
+ jos.putNextEntry(new JarEntry(resourceName));
+ Format prettyFormat = Format.getPrettyFormat();
+ prettyFormat.setIndent(" ");
+ new XMLOutputter(prettyFormat).output(document, jos);
+ }
+
+ protected abstract void processDocument(String resource, Document document, List relocators) throws JDOMException;
+
+ protected String getMetaInfResourceName(String resource) {
+ if (!resource.startsWith(META_INF_PATH)) {
+ return null;
+ }
+
+ String subPath = resource.substring(META_INF_PATH.length());
+ if (subPath.contains("/")) {
+ return null;
+ }
+
+ return subPath;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> List<T> checkedList(List<?> list, Class<T> clazz) {
+ for (Object o: list) {
+ if (!clazz.isInstance(o)) {
+ throw new ClassCastException(o.toString());
+ }
+ }
+
+ return (List<T>) list;
+ }
+
+ public void processResource(String resource, InputStream is, List relocators) throws IOException {
+ try {
+ SAXBuilder builder = new SAXBuilder(false);
+ builder.setExpandEntities(false);
+ //TODO nick - namespace aware?
+ builder.setEntityResolver(new EntityResolver() {
+
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+ });
+ Document document = builder.build(is);
+ processDocument(resource, document, relocators);
+ } catch (JDOMException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // TODO: handle exception
+ }
+ }
+ }
+
+}
Added: root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/ElementsComparator.java
===================================================================
--- root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/ElementsComparator.java (rev 0)
+++ root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/ElementsComparator.java 2010-05-28 01:39:29 UTC (rev 17336)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.build.shade.resource;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.xpath.XPath;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+class ElementsComparator implements Comparator<Element> {
+
+ private String namespaceUri;
+
+ private List<String> orderedElementNames;
+
+ private Map<String, XPath> comparisonPaths;
+
+ public ElementsComparator(String namespaceUri, List<String> orderedElementNames, Map<String, XPath> comparisonPaths) {
+ super();
+ this.namespaceUri = namespaceUri;
+ this.orderedElementNames = orderedElementNames;
+ this.comparisonPaths = comparisonPaths;
+ }
+
+ private String maskNullString(String s) {
+ return s != null ? s : "";
+ }
+
+ public int compare(Element o1, Element o2) {
+ if (!namespaceUri.equals(o1.getNamespaceURI()) || !namespaceUri.equals(o2.getNamespaceURI())) {
+ return 0;
+ }
+
+ String firstName = o1.getName();
+ String secondName = o2.getName();
+
+ if (firstName.equals(secondName)) {
+ XPath comparisonPath = comparisonPaths.get(firstName);
+
+ if (comparisonPath != null) {
+ try {
+ String firstEltValue = maskNullString(comparisonPath.valueOf(o1));
+ String secondEltValue = maskNullString(comparisonPath.valueOf(o2));
+
+ return firstEltValue.compareToIgnoreCase(secondEltValue);
+ } catch (JDOMException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ return 0;
+ } else {
+ int firstNameIdx = orderedElementNames.indexOf(firstName);
+ int secondNameIdx = orderedElementNames.indexOf(secondName);
+
+ if (firstNameIdx < secondNameIdx) {
+ return -1;
+ } else if (firstNameIdx == secondNameIdx) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+
+}
Added: root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/FacesConfigXmlResourceTransformer.java
===================================================================
--- root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/FacesConfigXmlResourceTransformer.java (rev 0)
+++ root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/FacesConfigXmlResourceTransformer.java 2010-05-28 01:39:29 UTC (rev 17336)
@@ -0,0 +1,283 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.build.shade.resource;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarOutputStream;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.filter.ElementFilter;
+import org.jdom.filter.Filter;
+import org.jdom.xpath.XPath;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class FacesConfigXmlResourceTransformer extends BaseFacesResourceTransformer {
+
+ private static final String BEHAVIOR_ID = "behavior-id";
+ private static final String VALIDATOR_ID = "validator-id";
+ private static final String CONVERTER_ID = "converter-id";
+ private static final String COMPONENT_TYPE = "component-type";
+ private static final String RENDER_KIT_EXTENSION = "render-kit-extension";
+ private static final String CLIENT_BEHAVIOR_RENDERER = "client-behavior-renderer";
+ private static final String ICON = "icon";
+ private static final String DISPLAY_NAME = "display-name";
+ private static final String DESCRIPTION = "description";
+ private static final String LIFECYCLE_EXTENSION = "lifecycle-extension";
+ private static final String PHASE_LISTENER = "phase-listener";
+ private static final String FACES_CONFIG_EXTENSION = "faces-config-extension";
+ private static final String BEHAVIOR = "behavior";
+ private static final String VALIDATOR = "validator";
+ private static final String LIFECYCLE = "lifecycle";
+ private static final String REFERENCED_BEAN = "referenced-bean";
+ private static final String NAVIGATION_RULE = "navigation-rule";
+ private static final String NAME = "name";
+ private static final String MANAGED_BEAN = "managed-bean";
+ private static final String CONVERTER = "converter";
+ private static final String COMPONENT = "component";
+ private static final String FACTORY = "factory";
+ private static final String ABSOLUTE_ORDERING = "absolute-ordering";
+ private static final String ORDERING = "ordering";
+ private static final String APPLICATION = "application";
+ private static final String RENDERER = "renderer";
+ private static final String RENDER_KIT_CLASS = "render-kit-class";
+ private static final String RENDER_KIT_ID = "render-kit-id";
+ private static final String RENDER_KIT = "render-kit";
+ private static final String FACES_CONFIG = "faces-config";
+ private static final String METADATA_COMPLETE = "metadata-complete";
+ private static final String CURRENT_VERSION = "2.0";
+ private static final String VERSION = "version";
+ private static final String FACES_CONFIG_FILE_NAME = "faces-config.xml";
+
+ private static final Set<String> AGGREGATOR_ELEMENTS_NAME_SET = new HashSet<String>(Arrays.asList(APPLICATION,
+ FACTORY, LIFECYCLE));
+
+ private static final Set<String> UNHANDLED_ELEMENTS_NAME_SET = new HashSet<String>(Arrays.asList(ORDERING,
+ ABSOLUTE_ORDERING, NAME));
+
+ private static final String RENDER_KIT_ID_EXPRESSION = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX,
+ RENDER_KIT_ID);
+
+ private static final String FACES_CONFIG_FILE_PATH = META_INF_PATH + FACES_CONFIG_FILE_NAME;
+
+ private enum ThreeState {
+ UNDEFINED, FALSE, TRUE
+ }
+
+ private Map<String, List<Element>> aggregatorElements = new HashMap<String, List<Element>>();
+
+ private Map<String, List<Element>> renderkitElements = new HashMap<String, List<Element>>();
+
+ private List<Element> simpleElements = new ArrayList<Element>();
+
+ private boolean hasProcessedConfigFiles;
+
+ private ThreeState metadataComplete = ThreeState.UNDEFINED;
+
+ private Comparator<Element> createElementsComparator() throws JDOMException {
+ List<String> elements = Arrays.asList(APPLICATION, ORDERING, ABSOLUTE_ORDERING, FACTORY,
+ COMPONENT, CONVERTER, MANAGED_BEAN, NAME, NAVIGATION_RULE, REFERENCED_BEAN,
+ RENDER_KIT, LIFECYCLE, VALIDATOR, BEHAVIOR, FACES_CONFIG_EXTENSION,
+ /* lifecycle inners */ PHASE_LISTENER, LIFECYCLE_EXTENSION, /* lifecycle inners end */
+ /* render-kit inners */ DESCRIPTION, DISPLAY_NAME, ICON, RENDER_KIT_ID,
+ RENDER_KIT_CLASS, RENDERER, CLIENT_BEHAVIOR_RENDERER, RENDER_KIT_EXTENSION /* render-kit inners end*/);
+
+ Map<String, XPath> elementNameExpressions = new HashMap<String, XPath>();
+
+ String componentTypeExpr = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX, COMPONENT_TYPE);
+ elementNameExpressions.put(COMPONENT, createXPath(componentTypeExpr));
+
+ String converterIdExpr = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX, CONVERTER_ID);
+ elementNameExpressions.put(CONVERTER, createXPath(converterIdExpr));
+
+ String validatorIdExpr = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX, VALIDATOR_ID);
+ elementNameExpressions.put(VALIDATOR, createXPath(validatorIdExpr));
+
+ String behaviorIdExpr = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX, BEHAVIOR_ID);
+ elementNameExpressions.put(BEHAVIOR, createXPath(behaviorIdExpr));
+
+ //renderer | client-behavior-renderer
+
+ return new ElementsComparator(JAVAEE_URI, elements, elementNameExpressions);
+ }
+
+ private void checkRootElement(Element element) {
+ if (!FACES_CONFIG.equals(element.getName())) {
+ throw new IllegalArgumentException("Root element name: " + element.getName());
+ }
+
+ if (!isJavaEEOrDefaultNamespace(element)) {
+ throw new IllegalArgumentException("Root element namespace: " + element.getNamespaceURI());
+ }
+ }
+
+ @Override
+ protected void processDocument(String resource, Document document, List relocators) throws JDOMException {
+ hasProcessedConfigFiles = true;
+
+ Element rootElement = document.getRootElement();
+ checkRootElement(rootElement);
+
+ if (metadataComplete == ThreeState.UNDEFINED || Boolean.TRUE.equals(metadataComplete)) {
+ String metadataCompleteString = rootElement.getAttributeValue(METADATA_COMPLETE);
+ if (!"true".equals(metadataCompleteString)) {
+ metadataComplete = ThreeState.FALSE;
+ }
+ }
+
+ Filter renderkitIdFilter = new ElementFilter().and(new ElementFilter(RENDER_KIT_ID, JAVAEE_NAMESPACE).negate());
+ XPath renderKitIdXPath = createXPath(RENDER_KIT_ID_EXPRESSION);
+ List<Element> children = checkedList(rootElement.getChildren(), Element.class);
+ for (Element child : children) {
+ if (!JAVAEE_URI.equals(child.getNamespaceURI())) {
+ simpleElements.add(child);
+ } else {
+ String name = child.getName();
+
+ if (UNHANDLED_ELEMENTS_NAME_SET.contains(name)) {
+ //TODO nick - log
+ continue;
+ }
+
+ if (AGGREGATOR_ELEMENTS_NAME_SET.contains(name)) {
+ List<Element> elementsList = aggregatorElements.get(name);
+ if (elementsList == null) {
+ elementsList = new ArrayList<Element>();
+ aggregatorElements.put(name, elementsList);
+ }
+
+ List<Element> aggregatorChildren = checkedList(child.getChildren(), Element.class);
+ elementsList.addAll(cloneAndImportElements(aggregatorChildren));
+ } else if (RENDER_KIT.equals(name)) {
+ String renderkitId = renderKitIdXPath.valueOf(child);
+ if (renderkitId == null) {
+ renderkitId = "";
+ }
+
+ List<Element> elementsList = renderkitElements.get(renderkitId);
+ if (elementsList == null) {
+ elementsList = new ArrayList<Element>();
+ renderkitElements.put(renderkitId, elementsList);
+ }
+
+ List<Element> renderkitChildren = checkedList(child.getContent(renderkitIdFilter), Element.class);
+ elementsList.addAll(cloneAndImportElements(renderkitChildren));
+ } else {
+ simpleElements.add(cloneAndImportElement(child));
+ }
+ }
+ }
+ }
+
+ public boolean canTransformResource(String resource) {
+ String name = getMetaInfResourceName(resource);
+ if (name == null) {
+ return false;
+ }
+
+ return name.equals(FACES_CONFIG_FILE_NAME);
+ }
+
+ public boolean hasTransformedResource() {
+ return hasProcessedConfigFiles;
+ }
+
+ public void modifyOutputStream(JarOutputStream os) throws IOException {
+ try {
+ Comparator<Element> comparator;
+ try {
+ comparator = createElementsComparator();
+ } catch (JDOMException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ Document document = new Document();
+ Element rootElement = new Element(FACES_CONFIG, JAVAEE_NAMESPACE);
+ rootElement.setAttribute(VERSION, CURRENT_VERSION);
+
+ if (metadataComplete != ThreeState.UNDEFINED) {
+ rootElement.setAttribute(METADATA_COMPLETE, String.valueOf(metadataComplete == ThreeState.TRUE));
+ }
+ addSchemaLocation(rootElement, "http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd");
+ document.addContent(rootElement);
+
+ List<Element> rootElementChildren = new ArrayList<Element>();
+ rootElementChildren.addAll(simpleElements);
+
+ for (Map.Entry<String, List<Element>> entry: aggregatorElements.entrySet()) {
+ String elementName = entry.getKey();
+ List<Element> aggregatorElementChildren = entry.getValue();
+
+ Element aggregatorElement = new Element(elementName, JAVAEE_NAMESPACE);
+ rootElementChildren.add(aggregatorElement);
+
+ Collections.sort(aggregatorElementChildren, comparator);
+ aggregatorElement.addContent(aggregatorElementChildren);
+ }
+
+ for (Map.Entry<String, List<Element>> entry: renderkitElements.entrySet()) {
+ String renderkitId = entry.getKey();
+ List<Element> renderkitElementChildren = entry.getValue();
+
+ Element renderkitElement = new Element(RENDER_KIT, JAVAEE_NAMESPACE);
+ rootElementChildren.add(renderkitElement);
+
+ if (renderkitId.length() != 0) {
+ Element renderkitIdElement = new Element(RENDER_KIT_ID, JAVAEE_NAMESPACE);
+ renderkitIdElement.setText(renderkitId);
+ renderkitElementChildren.add(renderkitIdElement);
+ }
+
+ Collections.sort(renderkitElementChildren, comparator);
+ renderkitElement.addContent(renderkitElementChildren);
+ }
+
+ Collections.sort(rootElementChildren, comparator);
+
+ rootElement.addContent(rootElementChildren);
+
+ appendToStream(FACES_CONFIG_FILE_PATH, document, os);
+ } finally {
+ hasProcessedConfigFiles = false;
+ metadataComplete = ThreeState.UNDEFINED;
+
+ simpleElements.clear();
+ aggregatorElements.clear();
+ renderkitElements.clear();
+ }
+ }
+
+}
Added: root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/Taglib.java
===================================================================
--- root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/Taglib.java (rev 0)
+++ root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/Taglib.java 2010-05-28 01:39:29 UTC (rev 17336)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.build.shade.resource;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class Taglib {
+
+ private String targetNamespace;
+
+ private String sourceNamespacesPattern;
+
+ public String getTargetNamespace() {
+ return targetNamespace;
+ }
+
+ public void setTargetNamespace(String targetNamespace) {
+ this.targetNamespace = targetNamespace;
+ }
+
+ public String getSourceNamespacesPattern() {
+ return sourceNamespacesPattern;
+ }
+
+ public void setSourceNamespacesPattern(String sourceNamespacesPattern) {
+ this.sourceNamespacesPattern = sourceNamespacesPattern;
+ }
+
+ public boolean matches(String namespace) {
+ if (sourceNamespacesPattern == null || sourceNamespacesPattern.length() == 0) {
+ return targetNamespace.equals(namespace);
+ }
+
+ return namespace.matches(sourceNamespacesPattern);
+ }
+}
Added: root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/TaglibXmlResourceTransformer.java
===================================================================
--- root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/TaglibXmlResourceTransformer.java (rev 0)
+++ root/build/resources/trunk/faces-shade-transformers/src/main/java/org/richfaces/build/shade/resource/TaglibXmlResourceTransformer.java 2010-05-28 01:39:29 UTC (rev 17336)
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.build.shade.resource;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarOutputStream;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.filter.ElementFilter;
+import org.jdom.filter.Filter;
+import org.jdom.xpath.XPath;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TaglibXmlResourceTransformer extends BaseFacesResourceTransformer {
+
+ private static final String ID = "id";
+ private static final String CURRENT_VERSION = "2.0";
+ private static final String VERSION = "version";
+ private static final String NAMESPACE = "namespace";
+ private static final String FUNCTION = "function";
+ private static final String TAG = "tag";
+ private static final String FUNCTION_NAME = "function-name";
+ private static final String TAG_NAME = "tag-name";
+ private static final String FACELET_TAGLIB = "facelet-taglib";
+
+ private static final String TAGLIB_XML_FILE_EXTENSION = ".taglib.xml";
+
+ private static final String NAMESPACE_EXPRESSION = MessageFormat.format(
+ "/{0}:{1}/{0}:{2}|/{1}/{2}", JAVAEE_PREFIX, FACELET_TAGLIB, NAMESPACE);
+
+ private Map<String, List<Document>> tagLibraries = new HashMap<String, List<Document>>();
+
+ private Map<String, Document> passThroughLibraries = new HashMap<String, Document>();
+
+ private Taglib[] taglibs = new Taglib[0];
+
+ private Comparator<Element> createElementsComparator() throws JDOMException {
+ List<String> elements = Arrays.asList("description", "display-name", "icon",
+ "library-class", NAMESPACE, "composite-library-name", TAG, FUNCTION, "taglib-extension");
+
+ Map<String, XPath> elementNameExpressions = new HashMap<String, XPath>();
+ String tagPathExpr = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX, TAG_NAME);
+ elementNameExpressions.put(TAG, createXPath(tagPathExpr));
+
+ String fnPathExpr = MessageFormat.format("./{0}:{1}|./{1}", JAVAEE_PREFIX, FUNCTION_NAME);
+ elementNameExpressions.put(FUNCTION, createXPath(fnPathExpr));
+
+ return new ElementsComparator(JAVAEE_URI, elements, elementNameExpressions);
+ }
+
+ private String getShortName(String namespaceUri) {
+ int idx = namespaceUri.lastIndexOf('/');
+ if (idx < 0) {
+ return namespaceUri;
+ } else {
+ return namespaceUri.substring(idx + 1);
+ }
+ }
+
+ private Element createNamespaceElement(String namespaceUri) {
+ Element nsElement = new Element(NAMESPACE, JAVAEE_NAMESPACE);
+ nsElement.setText(namespaceUri);
+ return nsElement;
+ }
+
+ private String getFileName(String shortName) {
+ return META_INF_PATH + shortName + TAGLIB_XML_FILE_EXTENSION;
+ }
+
+ public boolean canTransformResource(String resource) {
+ String name = getMetaInfResourceName(resource);
+ return name != null && name.endsWith(TAGLIB_XML_FILE_EXTENSION);
+ }
+
+ private void checkRootElement(Element element) {
+ if (!FACELET_TAGLIB.equals(element.getName())) {
+ throw new IllegalArgumentException("Root element name: " + element.getName());
+ }
+
+ if (!isJavaEEOrDefaultNamespace(element)) {
+ throw new IllegalArgumentException("Root element namespace: " + element.getNamespaceURI());
+ }
+ }
+
+ public boolean hasTransformedResource() {
+ return !tagLibraries.isEmpty() || !passThroughLibraries.isEmpty();
+ }
+
+ public void modifyOutputStream(JarOutputStream os) throws IOException {
+ try {
+ for (Map.Entry<String, Document> entry : passThroughLibraries.entrySet()) {
+ String resourceName = entry.getKey();
+ Document document = entry.getValue();
+
+ appendToStream(resourceName, document, os);
+ }
+ } finally {
+ passThroughLibraries.clear();
+ }
+
+ if (!tagLibraries.isEmpty()) {
+ Comparator<Element> elementsComparator;
+ try {
+ elementsComparator = createElementsComparator();
+ } catch (JDOMException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ Filter filter = new ElementFilter().and(new ElementFilter(NAMESPACE, JAVAEE_NAMESPACE).negate());
+
+ try {
+ for (Map.Entry<String, List<Document>> entry : tagLibraries.entrySet()) {
+ String namespaceUri = entry.getKey();
+ String shortName = getShortName(namespaceUri);
+ List<Document> sourceDocuments = entry.getValue();
+
+ Document document = new org.jdom.Document();
+
+ Element rootElement = new Element(FACELET_TAGLIB, JAVAEE_NAMESPACE);
+ rootElement.setAttribute(VERSION, CURRENT_VERSION);
+ addSchemaLocation(rootElement, "http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
+ rootElement.setAttribute(ID, shortName);
+
+ document.addContent(rootElement);
+
+ List<Element> elements = new ArrayList<Element>();
+ elements.add(createNamespaceElement(namespaceUri));
+
+ for (Document sourceDocument : sourceDocuments) {
+ Element sourceRootElement = sourceDocument.getRootElement();
+ checkRootElement(sourceRootElement);
+
+ List<Element> tagsContent = checkedList(sourceRootElement.getContent(filter), Element.class);
+ for (Element tagElement: tagsContent) {
+ Element clonedElement = cloneAndImportElement(tagElement);
+ elements.add(clonedElement);
+ }
+ }
+
+ Collections.sort(elements, elementsComparator);
+ rootElement.addContent(elements);
+
+ String fileName = getFileName(shortName);
+ appendToStream(fileName, document, os);
+ }
+ } finally {
+ tagLibraries.clear();
+ }
+ }
+ }
+
+ @Override
+ protected void processDocument(String resource, Document document, List relocators) throws JDOMException {
+ String namespaceUri = (String) createXPath(NAMESPACE_EXPRESSION).valueOf(document);
+ if (namespaceUri == null || namespaceUri.length() == 0) {
+ passThroughLibraries.put(resource, document);
+ } else {
+ for (Taglib taglib : taglibs) {
+ if (taglib.matches(namespaceUri)) {
+ namespaceUri = taglib.getTargetNamespace();
+ break;
+ }
+ }
+
+ List<Document> documents = tagLibraries.get(namespaceUri);
+ if (documents == null) {
+ documents = new ArrayList<Document>();
+ tagLibraries.put(namespaceUri, documents);
+ }
+
+ documents.add(document);
+ }
+ }
+
+ public Taglib[] getTaglibs() {
+ return taglibs;
+ }
+
+ public void setTaglibs(Taglib[] taglibs) {
+ this.taglibs = taglibs;
+ }
+}
Modified: root/pom.xml
===================================================================
--- root/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
+++ root/pom.xml 2010-05-28 01:39:29 UTC (rev 17336)
@@ -33,6 +33,7 @@
<module>build/parent/tags/richfaces-parent-5</module>
<module>build/bom/trunk</module>
<!--<module>build/resources/trunk/checkstyle</module>-->
+ <module>build/resources/trunk/faces-shade-transformers</module>
<module>commons/${commons.svn.dir}</module>
<module>core/${core.svn.dir}</module>
<module>cdk/${cdk.svn.dir}</module>
15 years, 4 months
JBoss Rich Faces SVN: r17335 - in root: build/bom/trunk and 34 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-05-27 21:07:12 -0400 (Thu, 27 May 2010)
New Revision: 17335
Modified:
root/archetypes/pom.xml
root/build/bom/trunk/pom.xml
root/build/resources/trunk/checkstyle/pom.xml
root/cdk/trunk/bom/pom.xml
root/commons/trunk/bom/pom.xml
root/commons/trunk/parent/pom.xml
root/commons/trunk/pom.xml
root/core/trunk/bom/pom.xml
root/core/trunk/parent/pom.xml
root/core/trunk/pom.xml
root/dist/trunk/pom.xml
root/examples-sandbox/trunk/pom.xml
root/examples/pom.xml
root/ui-sandbox/pom.xml
root/ui-sandbox/tables/trunk/bom/pom.xml
root/ui-sandbox/tables/trunk/parent/pom.xml
root/ui-sandbox/tables/trunk/pom.xml
root/ui/core/trunk/bom/pom.xml
root/ui/core/trunk/parent/pom.xml
root/ui/core/trunk/pom.xml
root/ui/dist/trunk/pom.xml
root/ui/dist/trunk/richfaces-components-api/pom.xml
root/ui/dist/trunk/richfaces-components-impl/pom.xml
root/ui/dist/trunk/richfaces-components-ui/pom.xml
root/ui/iteration/trunk/bom/pom.xml
root/ui/iteration/trunk/datascroller/pom.xml
root/ui/iteration/trunk/dist/pom.xml
root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml
root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml
root/ui/iteration/trunk/parent/pom.xml
root/ui/iteration/trunk/pom.xml
root/ui/misc/trunk/bom/pom.xml
root/ui/misc/trunk/dist/pom.xml
root/ui/misc/trunk/dist/richfaces-ui-misc-ui/pom.xml
root/ui/misc/trunk/parent/pom.xml
root/ui/misc/trunk/pom.xml
Log:
Updated to latest richfaces-parent
Modified: root/archetypes/pom.xml
===================================================================
--- root/archetypes/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/archetypes/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.archetypes</groupId>
Modified: root/build/bom/trunk/pom.xml
===================================================================
--- root/build/bom/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/build/bom/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -28,7 +28,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<description>
Modified: root/build/resources/trunk/checkstyle/pom.xml
===================================================================
--- root/build/resources/trunk/checkstyle/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/build/resources/trunk/checkstyle/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -21,7 +21,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces</groupId>
Modified: root/cdk/trunk/bom/pom.xml
===================================================================
--- root/cdk/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/cdk/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -7,7 +7,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: root/commons/trunk/bom/pom.xml
===================================================================
--- root/commons/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/commons/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -30,7 +30,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<description>
Modified: root/commons/trunk/parent/pom.xml
===================================================================
--- root/commons/trunk/parent/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/commons/trunk/parent/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -28,7 +28,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<description>
Modified: root/commons/trunk/pom.xml
===================================================================
--- root/commons/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/commons/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.commons</groupId>
Modified: root/core/trunk/bom/pom.xml
===================================================================
--- root/core/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/core/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -29,7 +29,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<description>
Modified: root/core/trunk/parent/pom.xml
===================================================================
--- root/core/trunk/parent/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/core/trunk/parent/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -30,7 +30,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<description>
Modified: root/core/trunk/pom.xml
===================================================================
--- root/core/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/core/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -25,7 +25,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.core</groupId>
Modified: root/dist/trunk/pom.xml
===================================================================
--- root/dist/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/dist/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces</groupId>
Modified: root/examples/pom.xml
===================================================================
--- root/examples/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/examples/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.examples</groupId>
Modified: root/examples-sandbox/trunk/pom.xml
===================================================================
--- root/examples-sandbox/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/examples-sandbox/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces</groupId>
Modified: root/ui/core/trunk/bom/pom.xml
===================================================================
--- root/ui/core/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/core/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/core/trunk/parent/pom.xml
===================================================================
--- root/ui/core/trunk/parent/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/core/trunk/parent/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/core/trunk/pom.xml
===================================================================
--- root/ui/core/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/core/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/dist/trunk/pom.xml
===================================================================
--- root/ui/dist/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/dist/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/dist/trunk/richfaces-components-api/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-api/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/dist/trunk/richfaces-components-api/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/dist/trunk/richfaces-components-impl/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-impl/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/dist/trunk/richfaces-components-impl/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/dist/trunk/richfaces-components-ui/pom.xml
===================================================================
--- root/ui/dist/trunk/richfaces-components-ui/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/dist/trunk/richfaces-components-ui/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/iteration/trunk/bom/pom.xml
===================================================================
--- root/ui/iteration/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/iteration/trunk/datascroller/pom.xml
===================================================================
--- root/ui/iteration/trunk/datascroller/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/datascroller/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -28,7 +28,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui.iteration</groupId>
Modified: root/ui/iteration/trunk/dist/pom.xml
===================================================================
--- root/ui/iteration/trunk/dist/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/dist/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml
===================================================================
--- root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml
===================================================================
--- root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/iteration/trunk/parent/pom.xml
===================================================================
--- root/ui/iteration/trunk/parent/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/parent/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/iteration/trunk/pom.xml
===================================================================
--- root/ui/iteration/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/iteration/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/misc/trunk/bom/pom.xml
===================================================================
--- root/ui/misc/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/misc/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/misc/trunk/dist/pom.xml
===================================================================
--- root/ui/misc/trunk/dist/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/misc/trunk/dist/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/misc/trunk/dist/richfaces-ui-misc-ui/pom.xml
===================================================================
--- root/ui/misc/trunk/dist/richfaces-ui-misc-ui/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/misc/trunk/dist/richfaces-ui-misc-ui/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/misc/trunk/parent/pom.xml
===================================================================
--- root/ui/misc/trunk/parent/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/misc/trunk/parent/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui/misc/trunk/pom.xml
===================================================================
--- root/ui/misc/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui/misc/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui</groupId>
Modified: root/ui-sandbox/pom.xml
===================================================================
--- root/ui-sandbox/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui-sandbox/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui-sandbox</groupId>
Modified: root/ui-sandbox/tables/trunk/bom/pom.xml
===================================================================
--- root/ui-sandbox/tables/trunk/bom/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui-sandbox/tables/trunk/bom/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui-sandbox</groupId>
Modified: root/ui-sandbox/tables/trunk/parent/pom.xml
===================================================================
--- root/ui-sandbox/tables/trunk/parent/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui-sandbox/tables/trunk/parent/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui-sandbox</groupId>
Modified: root/ui-sandbox/tables/trunk/pom.xml
===================================================================
--- root/ui-sandbox/tables/trunk/pom.xml 2010-05-28 00:56:58 UTC (rev 17334)
+++ root/ui-sandbox/tables/trunk/pom.xml 2010-05-28 01:07:12 UTC (rev 17335)
@@ -26,7 +26,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>5</version>
+ <version>6</version>
</parent>
<groupId>org.richfaces.ui-sandbox</groupId>
15 years, 4 months
JBoss Rich Faces SVN: r17334 - in root/cdk/trunk/plugins: generator/src/main/java/org/richfaces/cdk/generate/java/taghandler and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-05-27 20:56:58 -0400 (Thu, 27 May 2010)
New Revision: 17334
Added:
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listenerTagHandler.ftl
root/cdk/trunk/plugins/maven-cdk-plugin/.checkstyle
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/event/TestEvent.java
Log:
CODING IN PROGRESS - issue RF-7789: Process JSF events.
https://jira.jboss.org/browse/RF-7789
OPEN - issue RF-8568: Improve FreeMarker generator.
https://jira.jboss.org/browse/RF-8568
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/ComponentProcessor.java 2010-05-28 00:56:58 UTC (rev 17334)
@@ -59,9 +59,9 @@
* That class process component-related annotations such as {@link org.richfaces.cdk.annotations.JsfComponent} or
* {@link javax.faces.component.FacesComponent} and stores information in model.
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class ComponentProcessor extends ProcessorBase implements CdkAnnotationProcessor {
@@ -95,18 +95,21 @@
subcomponentModel.setGenerate(!Strings.isEmpty(subcomponent.generate()));
setComponentProperties(null, subcomponentModel, subAnnotation);
library.getComponents().add(subcomponentModel);
- }
+ }
}
/**
- * <p class="changed_added_4_0">process annotation and set component model properties.</p>
+ * <p class="changed_added_4_0">
+ * process annotation and set component model properties.
+ * </p>
+ *
* @param componentElement
* @param component
* @param annotation
* @throws CdkException
*/
- void setComponentProperties(TypeElement componentElement, ComponentModel component,
- JsfComponent annotation) throws CdkException {
+ void setComponentProperties(TypeElement componentElement, ComponentModel component, JsfComponent annotation)
+ throws CdkException {
setComponentType(componentElement, component, annotation.type());
setComponeneFamily(componentElement, component, annotation.family());
@@ -115,7 +118,7 @@
processFacets(componentElement, component, annotation);
processAttributes(componentElement, component, annotation);
-
+ processEvents(componentElement, component, annotation);
for (Tag tag : annotation.tag()) {
setTagInfo(tag, component);
}
@@ -184,8 +187,7 @@
final void processFacets(TypeElement componentElement, ComponentModel component, JsfComponent annotation) {
if (null != componentElement) {
SourceUtils sourceUtils = getSourceUtils();
- Set<BeanProperty> properties =
- sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, componentElement);
+ Set<BeanProperty> properties = sourceUtils.getBeanPropertiesAnnotatedWith(Facet.class, componentElement);
// TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
@@ -231,20 +233,27 @@
}
final void processEvents(TypeElement componentElement, ComponentModel component, JsfComponent annotation) {
- Class<? extends FacesEvent>[] fires = annotation.fires();
+ try {
+ Class<? extends FacesEvent>[] fires = annotation.fires();
- for (Class<? extends FacesEvent> event : fires) {
- try {
-// component.addEvent(event.value().getName());
- } catch (MirroredTypesException mirror) {
- for (TypeMirror eventType : mirror.getTypeMirrors()) {
- component.addEvent(eventType.toString());
- // TODO - check does component already implement eventSource interface
+ for (Class<? extends FacesEvent> event : fires) {
+ try {
+ component.addEvent(event.getName());
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+ }
+ } catch (MirroredTypeException mirror) {
+ component.addEvent(mirror.getTypeMirror().toString());
}
- } catch (MirroredTypeException mirror) {
- component.addEvent(mirror.getTypeMirror().toString());
+
}
-
+ } catch (MirroredTypesException mirror) {
+ for (TypeMirror eventType : mirror.getTypeMirrors()) {
+ component.addEvent(eventType.toString());
+ }
+ } catch (MirroredTypeException mirror) {
+ component.addEvent(mirror.getTypeMirror().toString());
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerModule.java 2010-05-28 00:56:58 UTC (rev 17334)
@@ -35,7 +35,10 @@
@Override
protected void configure() {
- Multibinder.newSetBinder(binder(), CdkWriter.class)
+ Multibinder<CdkWriter> multibinder = Multibinder.newSetBinder(binder(), CdkWriter.class);
+ multibinder
.addBinding().to(TagHandlerWriter.class);
+ multibinder
+ .addBinding().to(ListenerTagHandlerGenerator.class);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-05-28 00:56:58 UTC (rev 17334)
@@ -32,6 +32,7 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.ConverterModel;
import org.richfaces.cdk.model.DescriptionGroup;
+import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.FunctionModel;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.SimpleVisitor;
@@ -250,6 +251,16 @@
return null;
}
+ @Override
+ public Boolean visitEvent(EventModel model, ComponentLibrary param) {
+ for (TagModel tagModel : model.getTags()) {
+ if (TagType.Facelets.equals(tagModel.getType())) {
+ Element tag = createTag(tagModel.getName());
+ addTagHandler(tag, tagModel);
+ }
+ }
+ return null;
+ }
/**
* <p class="changed_added_4_0">Add common description elements.</p>
* @param parant
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_attributes_import.ftl 2010-05-28 00:56:58 UTC (rev 17334)
@@ -1,2 +1,2 @@
-<#list importClasses as imp>import ${imp};
+<#list importClasses as imp>import ${imp.name};
</#list>
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl 2010-05-28 00:56:58 UTC (rev 17334)
@@ -1,4 +1,4 @@
-<#assign listener=event.listenerInterface.shortName>
+<#assign listener=event.listenerInterface.simpleName>
public void add${listener}(${listener} listener) {
addFacesListener(listener);
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-05-28 00:56:58 UTC (rev 17334)
@@ -27,7 +27,7 @@
**/
@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
public class ${targetClass.simpleName} extends ${baseClass.simpleName}
- <#if (implemented?size > 0)>implements <@concat seq=implemented ; interface>${interface}</@concat></#if> {
+ <#if (implemented?size > 0)>implements <@concat seq=implemented ; interface>${interface.simpleName}</@concat></#if> {
public static final String COMPONENT_TYPE="${type}";
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/listenerTagHandler.ftl
===================================================================
Added: root/cdk/trunk/plugins/maven-cdk-plugin/.checkstyle
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/.checkstyle (rev 0)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/.checkstyle 2010-05-28 00:56:58 UTC (rev 17334)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="false">
+ <fileset name="java sources" enabled="true" check-config-name="RichFaces" local="false">
+ <file-match-pattern match-pattern="src/main/java" include-pattern="true"/>
+ </fileset>
+ <filter name="NonSrcDirs" enabled="true"/>
+</fileset-config>
Modified: root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/event/TestEvent.java
===================================================================
--- root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/event/TestEvent.java 2010-05-28 00:44:13 UTC (rev 17333)
+++ root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/event/TestEvent.java 2010-05-28 00:56:58 UTC (rev 17334)
@@ -37,7 +37,7 @@
* @author asmirnov(a)exadel.com
*
*/
-@Event(listener = TestListener.class, listenerWrapper = "org.richfaces.cdk.test.event.TestWrapper", source = "org.richfaces.cdk.test.event.TestSource", tag = @Tag(name = "testListener"))
+@Event(listener = TestListener.class, source = "org.richfaces.cdk.test.event.TestSource", tag = @Tag(name = "testListener"))
public class TestEvent extends FacesEvent {
/**
15 years, 4 months
JBoss Rich Faces SVN: r17332 - root/build/parent/tags.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-05-27 20:44:07 -0400 (Thu, 27 May 2010)
New Revision: 17332
Added:
root/build/parent/tags/richfaces-parent-6/
Log:
[maven-release-plugin] copy for tag richfaces-parent-6
Copied: root/build/parent/tags/richfaces-parent-6 (from rev 17331, root/build/parent/trunk)
15 years, 4 months
JBoss Rich Faces SVN: r17330 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/generate/java/taghandler and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-05-27 20:21:19 -0400 (Thu, 27 May 2010)
New Revision: 17330
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/EventTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/JavaSourceParser.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMakerUtils.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/PropertyModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/TagTemplateModel.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
Log:
CODING IN PROGRESS - issue RF-8568: Improve FreeMarker generator.
https://jira.jboss.org/browse/RF-8568
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/EventTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/EventTemplateModel.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/EventTemplateModel.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.cdk.generate.freemarker;
+
+import org.richfaces.cdk.model.EventModel;
+
+import freemarker.ext.beans.BeanModel;
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.util.ModelFactory;
+import freemarker.template.ObjectWrapper;
+import freemarker.template.TemplateModel;
+import freemarker.template.TemplateModelException;
+
+/**
+ * @author akolonitsky
+ * @since Feb 23, 2010
+ */
+public class EventTemplateModel extends BeanModel implements TemplateModel{
+
+ static final ModelFactory FACTORY = new ModelFactory() {
+ public TemplateModel create(Object object, ObjectWrapper wrapper) {
+ return new EventTemplateModel((EventModel) object, (BeansWrapper) wrapper);
+ }
+ };
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param object
+ * @param wrapper
+ */
+ public EventTemplateModel(EventModel object, BeansWrapper wrapper) {
+ super(object, wrapper);
+ }
+
+ @Override
+ public TemplateModel get(String key) throws TemplateModelException {
+
+ return super.get(key);
+ }
+
+
+
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/EventTemplateModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMakerUtils.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMakerUtils.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/FreeMakerUtils.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -25,8 +25,11 @@
import java.util.List;
+import org.richfaces.cdk.util.Strings;
+
import com.google.common.collect.ImmutableMap;
+import freemarker.template.SimpleScalar;
import freemarker.template.TemplateHashModel;
import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateMethodModelEx;
@@ -40,21 +43,32 @@
*/
public class FreeMakerUtils implements TemplateHashModel {
- ImmutableMap<String, ? extends TemplateMethodModel> functions = ImmutableMap.<String, TemplateMethodModel>builder().
+ private static final ImmutableMap<String, ? extends TemplateMethodModel> FUNCTIONS = ImmutableMap.<String, TemplateMethodModel>builder().
put("version", new TemplateMethodModelEx() {
-
+ @SuppressWarnings("unchecked")
@Override
public Object exec(List arguments) throws TemplateModelException {
- return "4.0.0";
+ return new SimpleScalar("4.0.0");
}
}).
+ put("capitaliyze", new TemplateMethodModel() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object exec(List arguments) throws TemplateModelException {
+ if (arguments.size() == 1) {
+ return new SimpleScalar(Strings.firstToUpperCase(arguments.get(0).toString()));
+ } else {
+ return null;
+ }
+ }
+ }).
build();
/* (non-Javadoc)
* @see freemarker.template.TemplateHashModel#get(java.lang.String)
*/
@Override
public TemplateModel get(String key) throws TemplateModelException {
- return functions.get(key);
+ return FUNCTIONS.get(key);
}
/* (non-Javadoc)
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/LibraryModelWrapper.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -26,8 +26,10 @@
package org.richfaces.cdk.generate.freemarker;
import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.model.TagModel;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
@@ -52,11 +54,15 @@
@Override
public TemplateModel wrap(Object obj) throws TemplateModelException {
if (obj instanceof PropertyBase) {
- return new PropertyModel((PropertyBase) obj, this);
+ return create(obj, PropertyModel.FACTORY);
} else if (obj instanceof ClassName) {
return create(obj, ClassNameModel.FACTORY);
+ } else if (obj instanceof EventModel) {
+ return create(obj, EventTemplateModel.FACTORY);
+ } else if (obj instanceof TagModel) {
+ return create(obj, TagTemplateModel.FACTORY);
} else if (obj instanceof ModelElementBase) {
- return new ModelElementBaseTemplateModel((ModelElementBase) obj, this);
+ return create(obj,ModelElementBaseTemplateModel.FACTORY);
} else {
return super.wrap(obj);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/ModelElementBaseTemplateModel.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -21,89 +21,138 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.cdk.generate.freemarker;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.NoSuchElementException;
import java.util.Set;
-import java.util.TreeSet;
+import org.richfaces.cdk.model.BehaviorModel;
import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.ComponentModel;
+import org.richfaces.cdk.model.ConverterModel;
+import org.richfaces.cdk.model.EventModel;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.PropertyBase;
+import org.richfaces.cdk.model.ValidatorModel;
import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
-import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.beans.StringModel;
+import freemarker.ext.util.ModelFactory;
+import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
-public class ModelElementBaseTemplateModel extends BeanModel implements TemplateModel {
+public class ModelElementBaseTemplateModel extends StringModel implements TemplateModel {
+ static final ModelFactory FACTORY = new ModelFactory() {
+ public TemplateModel create(Object object, ObjectWrapper wrapper) {
+ return new ModelElementBaseTemplateModel((ModelElementBase) object, (BeansWrapper) wrapper);
+ }
+ };
+
private final ModelElementBase model;
private Set<EventName> eventNames;
+ private final String name;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @param object
* @param wrapper
*/
public ModelElementBaseTemplateModel(ModelElementBase object, BeansWrapper wrapper) {
super(object, wrapper);
model = object;
+ if (model instanceof ComponentModel) {
+ this.name = "Component";
+ } else if (model instanceof BehaviorModel) {
+ this.name = "Behavior";
+ } else if (model instanceof ConverterModel) {
+ this.name = "Converter";
+ } else if (model instanceof ValidatorModel) {
+ this.name = "Validator";
+ } else {
+ this.name = "UnknownModelElement";
+ }
}
@Override
+ public String getAsString() {
+ return name;
+ }
+
+ @Override
public TemplateModel get(String key) throws TemplateModelException {
- if ("attributes".equals(key)) {
- return attributes();
- } else if ("requiredAttributes".equals(key)) {
+ if ("requiredAttributes".equals(key)) {
return requiredAttributes();
} else if ("generatedAttributes".equals(key)) {
return generatedAttributes();
+ } else if ("tagAttributes".equals(key)) {
+ return tagAttributes();
} else if ("eventNames".equals(key)) {
return eventNames();
} else if ("defaultEvent".equals(key)) {
return defaultEvent();
} else if ("importClasses".equals(key)) {
return getImportClasses();
+ } else if ("implemented".equals(key)) {
+ return getImplementedInterfaces();
}
return super.get(key);
}
public TemplateModel getImportClasses() throws TemplateModelException {
- Set<String> result = new TreeSet<String>();
+ Set<ClassName> result = Sets.newTreeSet();
for (PropertyBase entry : model.getAttributes()) {
if (entry.isGenerate() && !isPredefined(entry)) {
- result.add(entry.getType().getName());
-// System.out.println(entry.getType().getTypeParameters());
+ result.add(entry.getType());
}
}
// Import all interfaces implemented by the generated class.
- for (ClassName imlements : model.getInterfaces()) {
- result.add(imlements.toString());
+ result.addAll(model.getInterfaces());
+ if (model instanceof ComponentModel) {
+ ComponentModel component = (ComponentModel) model;
+ for(EventModel event :component.getEvents()){
+ result.add(event.getSourceInterface());
+ result.add(event.getListenerInterface());
+ }
}
-// Collection<String> list = new ArrayList<String>(result);
+ // Collection<String> list = new ArrayList<String>(result);
return this.wrapper.wrap(result);
}
+ public TemplateModel getImplementedInterfaces() throws TemplateModelException {
+ Set<ClassName> result = Sets.newTreeSet();
+ if(getEventNames().size()>0){
+ result.add(ClassName.parseName("javax.faces.component.behavior.ClientBehaviorHolder"));
+ }
+ // Import all interfaces implemented by the generated class.
+ result.addAll(model.getInterfaces());
+ if (model instanceof ComponentModel) {
+ ComponentModel component = (ComponentModel) model;
+ for(EventModel event :component.getEvents()){
+ result.add(event.getSourceInterface());
+ }
+ }
+ // Collection<String> list = new ArrayList<String>(result);
+ return this.wrapper.wrap(result);
+ }
+
public boolean isPredefined(PropertyBase property) {
return property.isPrimitive() || isFromJavaLang(property.getType());
}
@@ -146,35 +195,33 @@
}
private TemplateModel requiredAttributes() throws TemplateModelException {
- Collection<PropertyBase> attributes = model.getAttributes();
- Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (PropertyBase entry : attributes) {
- if (entry.isGenerate() && entry.isRequired()) {
- PropertyModel propertyModel = new PropertyModel(entry, wrapper);
- models.add(propertyModel);
+ return wrapper.wrap(Collections2.filter(model.getAttributes(), new Predicate<PropertyBase>() {
+
+ @Override
+ public boolean apply(PropertyBase input) {
+ return input.isRequired();
}
- }
- return wrapper.wrap(models);
+ }));
}
-
+
private TemplateModel generatedAttributes() throws TemplateModelException {
- Collection<PropertyBase> attributes = model.getAttributes();
- Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (PropertyBase entry : attributes) {
- if (entry.isGenerate()) {
- PropertyModel propertyModel = new PropertyModel(entry, wrapper);
- models.add(propertyModel);
+ return wrapper.wrap(Collections2.filter(model.getAttributes(), new Predicate<PropertyBase>() {
+
+ @Override
+ public boolean apply(PropertyBase input) {
+ return input.isGenerate();
}
- }
- return wrapper.wrap(models);
+ }));
}
- private TemplateModel attributes() throws TemplateModelException {
- Collection<PropertyBase> attributes = model.getAttributes();
- Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (PropertyBase entry : attributes) {
- models.add(new PropertyModel(entry, wrapper));
- }
- return wrapper.wrap(models);
+
+ private TemplateModel tagAttributes() throws TemplateModelException {
+ return wrapper.wrap(Collections2.filter(model.getAttributes(), new Predicate<PropertyBase>() {
+
+ @Override
+ public boolean apply(PropertyBase input) {
+ return !(input.isHidden()||input.isReadOnly());
+ }
+ }));
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/PropertyModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/PropertyModel.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/PropertyModel.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -29,8 +29,10 @@
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.util.Strings;
-import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.beans.StringModel;
+import freemarker.ext.util.ModelFactory;
+import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
@@ -39,7 +41,12 @@
* @author asmirnov(a)exadel.com
*
*/
-public class PropertyModel extends BeanModel implements TemplateModel {
+public class PropertyModel extends StringModel implements TemplateModel {
+ static final ModelFactory FACTORY = new ModelFactory() {
+ public TemplateModel create(Object object, ObjectWrapper wrapper) {
+ return new PropertyModel((PropertyBase) object, (BeansWrapper) wrapper);
+ }
+ };
private final PropertyBase property;
/**
@@ -56,7 +63,7 @@
* <p class="changed_added_4_0"></p>
* @return the name
*/
- public String getName() {
+ public String getAsString() {
return property.getName();
}
@@ -69,7 +76,7 @@
} else if ("setterName".equals(key)) {
value = getSetterName();
} else if ("name".equals(key)) {
- value = getName();
+ value = getAsString();
} else if ("capitalizeName".equals(key)) {
value = capitalizeName();
} else if ("typeForCasting".equals(key)) {
@@ -116,7 +123,7 @@
}
public String capitalizeName() {
- return Strings.firstToUpperCase(getName());
+ return Strings.firstToUpperCase(getAsString());
}
public boolean isFromJavaLang(ClassName type) {
@@ -129,30 +136,4 @@
}
-/* public String getMethodArgsClasses(){
- if(null != this._methodargs){
- StringBuffer result = new StringBuffer();
- String[] classes = SEPARATOR_PATTERN.split(this._methodargs.trim());
- for (int i = 0; i < classes.length; i++) {
- String argumentClass = classes[i];
-
- if (argumentClass.length() != 0) {
- if(i!=0){
- result.append(',');
- }
- result.append(argumentClass).append(".class");
- } else {
- if (classes.length == 1) {
- //no arguments
- break;
- } else {
- throw new IllegalArgumentException("Error parsing methodargs: " + this._methodargs);
- }
- }
- }
- return result.toString();
- } else {
- return null;
- }
- }*/
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/TagTemplateModel.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/TagTemplateModel.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/freemarker/TagTemplateModel.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -22,26 +22,12 @@
package org.richfaces.cdk.generate.freemarker;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.richfaces.cdk.model.BehaviorModel;
-import org.richfaces.cdk.model.ComponentModel;
-import org.richfaces.cdk.model.ConverterModel;
-import org.richfaces.cdk.model.EventName;
-import org.richfaces.cdk.model.ModelElementBase;
-import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.TagModel;
-import org.richfaces.cdk.model.ValidatorModel;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
import freemarker.ext.beans.BeanModel;
import freemarker.ext.beans.BeansWrapper;
+import freemarker.ext.util.ModelFactory;
+import freemarker.template.ObjectWrapper;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
@@ -50,10 +36,12 @@
* @since Feb 23, 2010
*/
public class TagTemplateModel extends BeanModel implements TemplateModel{
-// private final TagModel tagModel;
- private Set<EventName> eventNames;
- private final ModelElementBase model;
+ static final ModelFactory FACTORY = new ModelFactory() {
+ public TemplateModel create(Object object, ObjectWrapper wrapper) {
+ return new TagTemplateModel((TagModel) object, (BeansWrapper) wrapper);
+ }
+ };
/**
* <p class="changed_added_4_0">
* </p>
@@ -61,117 +49,17 @@
* @param object
* @param wrapper
*/
- public TagTemplateModel(ModelElementBase model,TagModel object, BeansWrapper wrapper) {
+ public TagTemplateModel(TagModel object, BeansWrapper wrapper) {
super(object, wrapper);
- this.model = model;
-// this.tagModel = object;
}
@Override
public TemplateModel get(String key) throws TemplateModelException {
- if ("attributes".equals(key)) {
- return attributes();
- } else if ("requiredAttributes".equals(key)) {
- return requiredAttributes();
- } else if ("generatedAttributes".equals(key)) {
- return generatedAttributes();
- } else if ("eventNames".equals(key)) {
- return eventNames();
- } else if ("defaultEvent".equals(key)) {
- return defaultEvent();
- } else if ("objectType".equals(key)) {
- return getObjectType();
- } else if ("model".equals(key)) {
- return wrapper.wrap(model);
- }
return super.get(key);
}
- private TemplateModel getObjectType() throws TemplateModelException {
- ModelElementBase modelElementBase = this.model;
- if (modelElementBase instanceof ComponentModel) {
- return wrapper.wrap("Component");
- }
- if (modelElementBase instanceof BehaviorModel) {
- return wrapper.wrap("Behavior");
- }
- if (modelElementBase instanceof ConverterModel) {
- return wrapper.wrap("Converter");
- }
- if (modelElementBase instanceof ValidatorModel) {
- return wrapper.wrap("Validator");
- }
-
- return null;
- }
-
- private TemplateModel eventNames() throws TemplateModelException {
- return wrapper.wrap(getEventNames());
- }
-
- private TemplateModel defaultEvent() throws TemplateModelException {
- Set<EventName> names = getEventNames();
-
- try {
- EventName defaultEvent = Iterables.find(names, new Predicate<EventName>() {
- @Override
- public boolean apply(EventName event) {
- return event.isDefaultEvent();
- }
- });
-
- return wrapper.wrap(defaultEvent);
- } catch (NoSuchElementException e) {
- return wrapper.wrap(null);
- }
- }
-
- private Set<EventName> getEventNames() {
- if (null == eventNames) {
- eventNames = Sets.newHashSet();
-
- for (PropertyBase property : this.model.getAttributes()) {
- eventNames.addAll(property.getEventNames());
- }
- }
-
- return eventNames;
- }
-
- private TemplateModel requiredAttributes() throws TemplateModelException {
- Collection<PropertyBase> attributes = this.model.getAttributes();
- Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (PropertyBase entry : attributes) {
- if (entry.isGenerate() && entry.isRequired()) {
- PropertyModel propertyModel = new PropertyModel(entry, wrapper);
- models.add(propertyModel);
- }
- }
- return wrapper.wrap(models);
- }
-
- private TemplateModel generatedAttributes() throws TemplateModelException {
- Collection<PropertyBase> attributes = this.model.getAttributes();
- Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (PropertyBase entry : attributes) {
- if (entry.isGenerate() && entry.isBindingAttribute()) {
- PropertyModel propertyModel = new PropertyModel(entry, wrapper);
- models.add(propertyModel);
- }
- }
- return wrapper.wrap(models);
- }
- private TemplateModel attributes() throws TemplateModelException {
- Collection<PropertyBase> attributes = this.model.getAttributes();
- Collection<PropertyModel> models = new ArrayList<PropertyModel>(attributes.size());
- for (PropertyBase entry : attributes) {
- models.add(new PropertyModel(entry, wrapper));
- }
- return wrapper.wrap(models);
- }
-
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/taghandler/TagHandlerClassGenerator.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -30,16 +30,13 @@
import org.richfaces.cdk.FileManager;
import org.richfaces.cdk.Output;
import org.richfaces.cdk.Outputs;
-import org.richfaces.cdk.generate.freemarker.TagTemplateModel;
import org.richfaces.cdk.model.ModelElementBase;
import org.richfaces.cdk.model.TagModel;
import org.richfaces.cdk.model.Trackable;
import com.google.inject.Inject;
-import freemarker.ext.beans.BeansWrapper;
import freemarker.template.Configuration;
-import freemarker.template.Template;
import freemarker.template.TemplateException;
/**
@@ -50,28 +47,21 @@
private static final String TAGHANDLER_TEMPLATE = "taghandler.ftl";
- private final Template template;
-
private final FileManager output;
private final Configuration configuration;
@Inject
- public TagHandlerClassGenerator(Configuration configuration,
- @Output(Outputs.JAVA_CLASSES) FileManager output) {
+ public TagHandlerClassGenerator(Configuration configuration, @Output(Outputs.JAVA_CLASSES) FileManager output) {
this.configuration = configuration;
this.output = output;
- try {
- template = configuration.getTemplate(TAGHANDLER_TEMPLATE);
- } catch (IOException e) {
- throw new CdkException(e);
- }
}
public boolean process(ModelElementBase model, TagModel tag) throws CdkException {
try {
- Writer writer = getOutput(tag);
- template.process(new TagTemplateModel(model, tag, (BeansWrapper) configuration.getObjectWrapper()), writer);
+ Writer writer = getOutput(tag);
+ configuration.getTemplate(TAGHANDLER_TEMPLATE).process(new TagWithModel<ModelElementBase>(tag, model),
+ writer);
writer.close();
} catch (IOException e) {
throw new CdkException(e);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -36,7 +36,7 @@
*
* @author asmirnov(a)exadel.com
*/
-public class ClassName implements Serializable {
+public class ClassName implements Serializable,Comparable<ClassName> {
private static final long serialVersionUID = -846623207703750456L;
@@ -261,4 +261,9 @@
return true;
}
+
+ @Override
+ public int compareTo(ClassName o) {
+ return getName().compareTo(o.getName());
+ }
}
Added: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/_event_source_accessors.ftl 2010-05-28 00:21:19 UTC (rev 17330)
@@ -0,0 +1,20 @@
+<#assign listener=event.listenerInterface.shortName>
+ public void add${listener}(${listener} listener) {
+
+ addFacesListener(listener);
+
+ }
+
+ public ${listener}[] get${listener}s() {
+
+ ${listener} al[] = (${listener} [])
+ getFacesListeners(${listener}.class);
+ return (al);
+
+ }
+
+ public void remove${listener}(${listener} listener) {
+
+ removeFacesListener(listener);
+
+ }
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/component.ftl 2010-05-28 00:21:19 UTC (rev 17330)
@@ -25,11 +25,6 @@
/**
* ${description?if_exists}
**/
-<#if (eventNames?size > 0)>
-<#assign implemented=interfaces +["ClientBehaviorHolder"]>
-<#else>
-<#assign implemented=interfaces>
-</#if>
@Generated({"RichFaces CDK", "4.0.0-SNAPSHOT"})
public class ${targetClass.simpleName} extends ${baseClass.simpleName}
<#if (implemented?size > 0)>implements <@concat seq=implemented ; interface>${interface}</@concat></#if> {
@@ -69,4 +64,8 @@
<#list generatedAttributes as attribute>
<#include "_attribute_accessors.ftl">
</#list>
+ <#list events as event>
+ <#include "_event_source_accessors.ftl">
+ </#list>
+
}
\ No newline at end of file
Modified: root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/main/resources/META-INF/templates/taghandler.ftl 2010-05-28 00:21:19 UTC (rev 17330)
@@ -1,21 +1,21 @@
<#include "_copyright.ftl">
-package ${targetClass.package};
+package ${tag.targetClass.package};
import javax.faces.view.facelets.*;
import org.richfaces.MethodMetadata;
import ${model.targetClass};
-<#list generatedAttributes as prop><#if (!prop.signature.empty)><#list prop.signature as class>import ${class.name};
+<#list model.generatedAttributes as prop><#if (!prop.signature.empty)><#list prop.signature as class>import ${class.name};
</#list></#if></#list>
-public class ${targetClass.simpleName} extends ${baseClass.simpleName} {
+public class ${tag.targetClass.simpleName} extends ${tag.baseClass.simpleName} {
- private static final ${targetClass.simpleName}MetaRule META_RULE = new ${targetClass.simpleName}MetaRule();
+ private static final ${tag.targetClass.simpleName}MetaRule META_RULE = new ${tag.targetClass.simpleName}MetaRule();
- public ${targetClass.simpleName}(${objectType}Config config) {
+ public ${tag.targetClass.simpleName}(${model}Config config) {
super(config);
- <#list requiredAttributes as prop>getRequiredAttribute("${prop.name}");
+ <#list model.requiredAttributes as prop>getRequiredAttribute("${prop.name}");
</#list>
}
@@ -26,11 +26,11 @@
return m;
}
- static class ${targetClass.simpleName}MetaRule extends MetaRule{
+ static class ${tag.targetClass.simpleName}MetaRule extends MetaRule{
public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
if (meta.isTargetInstanceOf(${model.targetClass.simpleName}.class)) {
- <#list generatedAttributes as prop>
+ <#list model.tagAttributes as prop><#if (prop.binding || prop.bindingAttribute)>
if ("${prop.name}".equals(name)) {
return new MethodMetadata(attribute<#if (!prop.signature.empty)><#list prop.signature as class>, ${class.simpleName}.class</#list></#if>) {
public void applyMetadata(FaceletContext ctx, Object instance) {
@@ -38,8 +38,7 @@
}
};
}
-
- </#list>
+ </#if></#list>
}
return null;
}
Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/JavaSourceParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/JavaSourceParser.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/JavaSourceParser.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -0,0 +1,132 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import static org.junit.Assert.*;
+import japa.parser.JavaParser;
+import japa.parser.ParseException;
+import japa.parser.ast.CompilationUnit;
+import japa.parser.ast.ImportDeclaration;
+import japa.parser.ast.body.FieldDeclaration;
+import japa.parser.ast.body.MethodDeclaration;
+import japa.parser.ast.body.TypeDeclaration;
+import japa.parser.ast.body.VariableDeclarator;
+import japa.parser.ast.visitor.VoidVisitorAdapter;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public final class JavaSourceParser {
+
+ final class MethodNameVisitor extends VoidVisitorAdapter<String> {
+
+ boolean found = false;
+
+ @Override
+ public void visit(MethodDeclaration n, String arg) {
+ if (arg.equals(n.getName())) {
+ this.found = true;
+ }
+ }
+ }
+
+ final class ImportVisitor extends VoidVisitorAdapter<String> {
+
+ boolean found = false;
+
+ @Override
+ public void visit(ImportDeclaration n, String arg) {
+ if (arg.equals(n.getName().getName())) {
+ this.found = true;
+ }
+ }
+ }
+
+ final class FieldVisitor extends VoidVisitorAdapter<String> {
+
+ boolean found = false;
+
+ @Override
+ public void visit( FieldDeclaration n, String arg) {
+ for (VariableDeclarator declarator : n.getVariables()) {
+ if (arg.equals(declarator.getId().getName())) {
+ this.found = true;
+ }
+ }
+ }
+ }
+
+ private final CompilationUnit compiledSource;
+
+ private JavaSourceParser(CompilationUnit compiledSource) {
+ this.compiledSource = compiledSource;
+ }
+
+ public static JavaSourceParser parse(String javaSource) throws ParseException {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(javaSource.getBytes());
+ CompilationUnit compilationUnit = JavaParser.parse(inputStream);
+ assertNotNull(compilationUnit);
+ return new JavaSourceParser(compilationUnit);
+ }
+
+ public boolean containsMethod(String methodName) {
+ MethodNameVisitor visitorAdapterExtension = new MethodNameVisitor();
+ this.compiledSource.accept(visitorAdapterExtension, methodName);
+ return visitorAdapterExtension.found;
+ }
+
+ public boolean containsImport(String packageName) {
+ ImportVisitor visitorAdapterExtension = new ImportVisitor();
+ this.compiledSource.accept(visitorAdapterExtension, packageName);
+ return visitorAdapterExtension.found;
+ }
+
+ public boolean containsField(String fieldName) {
+ FieldVisitor visitorAdapterExtension = new FieldVisitor();
+ this.compiledSource.accept(visitorAdapterExtension, fieldName);
+ return visitorAdapterExtension.found;
+ }
+
+ public String getPackageName(){
+ return this.compiledSource.getPakage().getName().getName();
+ }
+
+ public Iterable<String> getClassNames() {
+ List<String> classNames = Lists.newArrayList();
+ List<TypeDeclaration> types = compiledSource.getTypes();
+ for (TypeDeclaration typeDeclaration : types) {
+ classNames.add(typeDeclaration.getName());
+ }
+ return classNames;
+ }
+}
Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/JavaSourceParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -25,12 +25,7 @@
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
-import japa.parser.JavaParser;
-import japa.parser.ast.CompilationUnit;
-import japa.parser.ast.body.MethodDeclaration;
-import japa.parser.ast.visitor.VoidVisitorAdapter;
-import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,6 +38,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.JavaSourceParser;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.EventName;
@@ -62,17 +58,6 @@
@RunWith(CdkTestRunner.class)
public class ComponentClassGeneratorTest extends AbstractClassGeneratorTest {
- private final class VoidVisitorAdapterExtension extends VoidVisitorAdapter<String> {
- private boolean found = false;
-
- @Override
- public void visit(MethodDeclaration n, String arg) {
- if (arg.equals(n.getName())) {
- this.found = true;
- }
- }
- }
-
@Inject
private ComponentClassGenerator generator;
@@ -150,13 +135,7 @@
verify(output);
- // TODO - any change in the template breaks test, make comperison more intellectual ?
- ByteArrayInputStream inputStream = new ByteArrayInputStream(outputWriter.toString().getBytes());
- CompilationUnit compilationUnit = JavaParser.parse(inputStream);
- assertNotNull(compilationUnit);
- VoidVisitorAdapterExtension visitorAdapter = new VoidVisitorAdapterExtension();
- compilationUnit.accept(visitorAdapter, "isTestFlag");
- assertTrue(visitorAdapter.found);
- // compare(outputWriter, "GeneratedComponent.java");
+ JavaSourceParser sourceParser = JavaSourceParser.parse(outputWriter.toString());
+ assertTrue(sourceParser.containsMethod("isTestFlag"));
}
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-05-28 00:18:50 UTC (rev 17329)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/TagHandlerClassGeneratorTest.java 2010-05-28 00:21:19 UTC (rev 17330)
@@ -79,6 +79,6 @@
log.debug(outputWriter.toString());
verify(output);
- compare(outputWriter, "GeneratedTagHandler.java");
+ // TODO - check generated class.
}
}
15 years, 4 months
JBoss Rich Faces SVN: r17329 - root/docs/trunk/Developer_Guide/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-05-27 20:18:50 -0400 (Thu, 27 May 2010)
New Revision: 17329
Modified:
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml
root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml
Log:
Added Maven install instructions: RF-8040
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml 2010-05-27 18:19:39 UTC (rev 17328)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-Getting_started_with_RichFaces.xml 2010-05-28 00:18:50 UTC (rev 17329)
@@ -154,173 +154,185 @@
<section id="sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project_with_Maven">
<title>Creating a project with <productname>Maven</productname></title>
<para>
- <productname>Maven</productname> is a build automation and project management tool for Java projects. Follow the instructions in this section to create a Maven project for RichFaces.
+ <productname>Apache Maven</productname> is a build automation and project management tool for Java projects. Follow the instructions in this section to create a <productname>Maven</productname> project for <productname>RichFaces</productname>.
</para>
- <procedure>
- <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories">
- <title>Add required repositories</title>
- <para>
- A structure for the Maven project with minimal content can be created with the Maven archetype named <filename>maven-archetype-jsfwebapp</filename> <remark>(may be renamed in a later release)</remark> included as part of the RichFaces Component Development Kit (<acronym>CDK</acronym>). The archetype and the project itself require the JBoss repository to be provided (<filename>https://repository.jboss.org/nexus/content/groups/public/</filename>). To make the repositories accessible to Maven, add a profile in the <filename><replaceable>maven_installation_folder</replaceable>/conf/settings.xml</filename> file under the <sgmltag><profiles></sgmltag> element:
- </para>
+ <section id="sect-Component_Using_RichFaces_with_Maven-Setting_up_Maven">
+ <title>Setting up <productname>Maven</productname></title>
+ <para>
+ <productname>Maven</productname> can be downloaded and installed from Apache's website at <ulink url="http://maven.apache.org/download.html">http://maven.apache.org/download.html</ulink>. Version 2.2.1 is recommended.
+ </para>
+ <para>
+ Once <productname>Maven</productname> has been installed, no further configuration is required to begin building Maven projects.
+ </para>
+ </section>
+ <section id="sect-Component_Reference-Using_RichFaces_with_Maven-Using_the_RichFaces_project_archetype">
+ <title>Using the <productname>RichFaces</productname> project archetype</title>
+ <procedure>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories">
+ <title>Add required repositories</title>
+ <para>
+ A structure for the project with minimal content can be created with the Maven archetype named <filename>maven-archetype-jsfwebapp</filename> <remark>(may be renamed in a later release)</remark> included as part of the RichFaces Component Development Kit (<acronym>CDK</acronym>). The archetype and the project itself require the JBoss repository to be provided (<filename>https://repository.jboss.org/nexus/content/groups/public/</filename>). To make the repositories accessible to Maven, add a profile in the <filename><replaceable>maven_installation_folder</replaceable>/conf/settings.xml</filename> file under the <sgmltag><profiles></sgmltag> element:
+ </para>
-<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
- <para>
- The profile then needs to be activated in the <sgmltag><activeProfiles></sgmltag> element:
- </para>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Add_required_repositories.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The profile then needs to be activated in the <sgmltag><activeProfiles></sgmltag> element:
+ </para>
<programlisting language="XML" role="XML"><activeProfiles>
- <activeProfile>jboss-public-repository</activeProfile>
-</activeProfiles>
-</programlisting>
- </step>
- <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Generate_the_project_from_the_archetype">
- <title>Generate the project from the archetype</title>
+ <activeProfile>jboss-public-repository</activeProfile>
+</activeProfiles></programlisting>
+ </step>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Generate_the_project_from_the_archetype">
+ <title>Generate the project from the archetype</title>
-<!--
-<remark>ONCE 4.0 ARCHETYPE IS COMPLETE:</remark>
- <para>
- The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> <remark>(may be renamed in a later release)</remark> archetype. Create a new directory for your project, then run the following Maven command:
- </para>
-<screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=4.0.0-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable></screen>
--->
+ <!--
+ <remark>ONCE 4.0 ARCHETYPE IS COMPLETE:</remark>
+ <para>
+ The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> <remark>(may be renamed in a later release)</remark> archetype. Create a new directory for your project, then run the following Maven command:
+ </para>
+ <screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=4.0.0-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable></screen>
+ -->
- <para>
- The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> archetype. The archetype for RichFaces 4.0 is still in development; use the archetype for RichFaces 3.3.3 to generate a project until the 4.0 archetype is released. Create a new directory for your project, then run the following Maven command:
- </para>
-<screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=3.3.3-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable></screen>
- <para>
- The following parameters can be used to customize your project:
- </para>
- <variablelist>
- <varlistentry>
- <term><command>-DgroupId</command></term>
- <listitem>
+ <para>
+ The project can now be generated with the <filename>maven-archetype-jsfwebapp</filename> archetype. The archetype for <productname>RichFaces 4.0</productname> is still in development; use the archetype for <productname>RichFaces 3.3.3</productname> to generate a project until the 4.0 archetype is released. Create a new directory for your project, then run the following Maven command:
+ </para>
+ <screen>mvn archetype:generate -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=3.3.3-SNAPSHOT -DgroupId=<replaceable>org.docs.richfaces</replaceable> -DartifactId=<replaceable>jsf-app</replaceable></screen>
+ <para>
+ The following parameters can be used to customize your project:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><command>-DgroupId</command></term>
+ <listitem>
+ <para>
+ Defines the package for the Managed Beans
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><command>-DartifactId</command></term>
+ <listitem>
+ <para>
+ Defines the name of the project
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ The command generates a JSF project with the following structure:
+ </para>
+ <screen><replaceable>jsf-app</replaceable>
+ ├── <filename>pom.xml</filename>
+ └── <filename>src</filename>
+ ├── <filename>main</filename>
+ │ ├── <filename>java</filename>
+ │ │ └── <filename>org</filename>
+ │ │ └── <filename>docs</filename>
+ │ │ └── <filename>richfaces</filename>
+ │ │ └── <filename>Bean.java</filename>
+ │ ├── <filename>resources</filename>
+ │ └── <filename>webapp</filename>
+ │ ├── <filename>WEB-INF</filename>
+ │ │ ├── <filename>faces-config.xml</filename>
+ │ │ └── <filename>web.xml</filename>
+ │ ├── <filename>index.xhtml</filename>
+ │ └── <filename>pages</filename>
+ │ └── <filename>index.xhtml</filename>
+ └── <filename>test</filename>
+ └── <filename>java</filename>
+ └── <filename>org</filename>
+ └── <filename>docs</filename>
+ └── <filename>richfaces</filename>
+ └── <filename>BeanTest.java</filename></screen>
+ </step>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_dependencies">
+ <title>Add dependencies</title>
+ <para>
+ Your root directory of your project contains a project descriptor file, <filename>pom.xml</filename>. To add RichFaces libraries to your project, edit the project descriptor to add dependencies to the <sgmltag><dependencies></sgmltag> element as follows:
+ </para>
+
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Add_dependencies.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+
+ <!-- Remove the following for Enterprise documentation -->
+ <para>
+ If you wish to include modules for test-driven JSF development, add any dependencies for the tests to the <filename>pom.xml</filename> file. For full details on how to use the <productname>jsf-test</productname> project, refer to <ulink url="http://community.jboss.org/docs/DOC-13155">http://community.jboss.org/wiki/TestDrivenJSFDevelopment</ulink>.
+ </para>
+ </step>
+
+ <!--
+ <remark>REMOVE ONCE 4.0 ARCHETYPE IS COMPLETE</remark>
+ -->
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Update_the_generated_project">
+ <title>Update the generated project</title>
+ <para>
+ After the project has been generated from the old archetype, it must be updated to use RichFaces &VERSION; and JSF 2.
+ </para>
+ <para>
+ RichFaces &VERSION; uses Facelets and does not support JSP. Any <filename>index.jsp</filename> pages that were generated need to forward <filename>home.jsf</filename> page equivalents.
+ </para>
+ <!--
+ <substeps>
+ <step>
+ <title>Deactivate the VDL view handler</title>
<para>
- Defines the package for the Managed Beans
+ The <acronym>VDL</acronym> (View Definition Language) view handler must be deactivated for your project to work with JSF 2. To deactivate the viewhandler, edit the project's <filename>web.xml</filename> settings file with the following context parameter:
</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><command>-DartifactId</command></term>
- <listitem>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Update_the_generated_project.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </step>
+ </substeps>
+ -->
+ </step>
+
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Build_the_project">
+ <title>Build the project</title>
+ <para>
+ Build the project from the command line by entering the <command>mvn install</command> command.
+ </para>
+ <para>
+ The <computeroutput>BUILD SUCCESSFUL</computeroutput> message indicates the project has been assembled and is ready to import into an IDE (integrated development environment).
+ </para>
+ </step>
+
+ <step id="step-Developer_Guide-Build_the_project-Building_for_Eclipse_and_JBoss_Tools">
+ <title>Import the project into an IDE</title>
+ <para>
+ Import the Maven project into your IDE. For <application>Eclipse</application> and <application>JBoss Tools</application>, you can either use <application>Maven</application> to prepare the project, or import the project using the <productname>M2Eclipse</productname> plug-in.
+ </para>
+ <stepalternatives>
+ <step>
+ <title>Using <application>Maven</application> to prepare the project for <application>Eclipse</application></title>
<para>
- Defines the name of the project
+ Enter the following command in the root directory of the project:
</para>
- </listitem>
- </varlistentry>
- </variablelist>
- <para>
- The command generates a JSF project with the following structure:
- </para>
-<screen><replaceable>jsf-app</replaceable>
-├── <filename>pom.xml</filename>
-└── <filename>src</filename>
- ├── <filename>main</filename>
- │ ├── <filename>java</filename>
- │ │ └── <filename>org</filename>
- │ │ └── <filename>docs</filename>
- │ │ └── <filename>richfaces</filename>
- │ │ └── <filename>Bean.java</filename>
- │ ├── <filename>resources</filename>
- │ └── <filename>webapp</filename>
- │ ├── <filename>WEB-INF</filename>
- │ │ ├── <filename>faces-config.xml</filename>
- │ │ └── <filename>web.xml</filename>
- │ ├── <filename>index.xhtml</filename>
- │ └── <filename>pages</filename>
- │ └── <filename>index.xhtml</filename>
- └── <filename>test</filename>
- └── <filename>java</filename>
- └── <filename>org</filename>
- └── <filename>docs</filename>
- └── <filename>richfaces</filename>
- └── <filename>BeanTest.java</filename></screen>
- </step>
- <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_dependencies">
- <title>Add dependencies</title>
- <para>
- Your root directory of your project contains a project descriptor file, <filename>pom.xml</filename>. To add RichFaces libraries to your project, edit the project descriptor to add dependencies to the <sgmltag><dependencies></sgmltag> element as follows:
- </para>
-
-<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Add_dependencies.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
-
- <!-- Remove the following for Enterprise documentation -->
- <para>
- If you wish to include modules for test-driven JSF development, add any dependencies for the tests to the <filename>pom.xml</filename> file. For full details on how to use the <productname>jsf-test</productname> project, refer to <ulink url="http://community.jboss.org/docs/DOC-13155">http://community.jboss.org/wiki/TestDrivenJSFDevelopment</ulink>.
- </para>
- </step>
-
-<!--
-<remark>REMOVE ONCE 4.0 ARCHETYPE IS COMPLETE</remark>
--->
- <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Update_the_generated_project">
- <title>Update the generated project</title>
- <para>
- After the project has been generated from the old archetype, it must be updated to use RichFaces &VERSION; and JSF 2.
- </para>
- <para>
- RichFaces &VERSION; uses Facelets and does not support JSP. Any <filename>index.jsp</filename> pages that were generated need to forward <filename>home.jsf</filename> page equivalents.
- </para>
+ <screen>mvn eclipse:eclipse -DdownloadSources=true -Dwtpversion=2.0</screen>
+ <para>
+ The command generates the required <application>Eclipse</application> project files. You can then import the project into <application>Eclipse</application> and <application>JBoss Tools</application> through the importing wizard by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Import</guimenuitem></menuchoice> from the menu. Select <menuchoice><guimenu>General</guimenu><guimenuitem>Existing Projects into Workspace</guimenuitem></menuchoice> as the import source and choose the root directory for your project.
+ </para>
+ </step>
+ <step>
+ <title>Using the <productname>M2Eclipse</productname> plug-in</title>
+ <para>
+ Alternatively, you can import a <application>Maven</application> project into <application>Eclipse</application> and <application>JBoss Tools</application> using the <productname>M2Eclipse</productname> plug-in. With the plug-in installed, open the importing wizard by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Import</guimenuitem></menuchoice> from the menu. Select <menuchoice><guimenu>Maven</guimenu><guimenuitem>Existing Maven Projects</guimenuitem></menuchoice> as the import source and choose the <filename>pom.xml</filename> file for your project.
+ </para>
+ </step>
+ </stepalternatives>
+ </step>
<!--
- <substeps>
- <step>
- <title>Deactivate the VDL view handler</title>
- <para>
- The <acronym>VDL</acronym> (View Definition Language) view handler must be deactivated for your project to work with JSF 2. To deactivate the viewhandler, edit the project's <filename>web.xml</filename> settings file with the following context parameter:
- </para>
-<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/prog-Developer_Guide-Using_RichFaces_with_Maven-Update_the_generated_project.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
- </step>
- </substeps>
+ <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_tag_library_references">
+ <title>Add tag library references</title>
+ <para>
+ After importing, edit the <filename><replaceable>jsf-app</replaceable>/src/main/webapp/pages/index.xhtml</filename> file to include the tag library declaration as described in <xref linkend="step-Developer_Guide-Creating_a_project-Reference_the_tag_libraries" /> of <xref linkend="sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project" />.
+ </para>
+ </step>
-->
- </step>
-
- <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Build_the_project">
- <title>Build the project</title>
- <para>
- Build the project from the command line by entering the <command>mvn install</command> command.
- </para>
- <para>
- The <computeroutput>BUILD SUCCESSFUL</computeroutput> message indicates the project has been assembled and is ready to import into an IDE (integrated development environment).
- </para>
- </step>
-
- <step id="step-Developer_Guide-Build_the_project-Building_for_Eclipse_and_JBoss_Tools">
- <title>Import the project into an IDE</title>
- <para>
- Import the Maven project into your IDE. For <application>Eclipse</application> and <application>JBoss Tools</application>, you can either use <application>Maven</application> to prepare the project, or import the project using the <productname>M2Eclipse</productname> plug-in.
- </para>
- <stepalternatives>
- <step>
- <title>Using <application>Maven</application> to prepare the project for <application>Eclipse</application></title>
- <para>
- Enter the following command in the root directory of the project:
- </para>
-<screen>mvn eclipse:eclipse -DdownloadSources=true -Dwtpversion=2.0</screen>
- <para>
- The command generates the required <application>Eclipse</application> project files. You can then import the project into <application>Eclipse</application> and <application>JBoss Tools</application> through the importing wizard by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Import</guimenuitem></menuchoice> from the menu. Select <menuchoice><guimenu>General</guimenu><guimenuitem>Existing Projects into Workspace</guimenuitem></menuchoice> as the import source and choose the root directory for your project.
- </para>
- </step>
- <step>
- <title>Using the <productname>M2Eclipse</productname> plug-in</title>
- <para>
- Alternatively, you can import a <application>Maven</application> project into <application>Eclipse</application> and <application>JBoss Tools</application> using the <productname>M2Eclipse</productname> plug-in. With the plug-in installed, open the importing wizard by choosing <menuchoice><guimenu>File</guimenu><guimenuitem>Import</guimenuitem></menuchoice> from the menu. Select <menuchoice><guimenu>Maven</guimenu><guimenuitem>Existing Maven Projects</guimenuitem></menuchoice> as the import source and choose the <filename>pom.xml</filename> file for your project.
- </para>
- </step>
- </stepalternatives>
- </step>
- <!--
- <step id="step-Developer_Guide-Using_RichFaces_with_Maven-Add_tag_library_references">
- <title>Add tag library references</title>
- <para>
- After importing, edit the <filename><replaceable>jsf-app</replaceable>/src/main/webapp/pages/index.xhtml</filename> file to include the tag library declaration as described in <xref linkend="step-Developer_Guide-Creating_a_project-Reference_the_tag_libraries" /> of <xref linkend="sect-Developer_Guide-Getting_started_with_RichFaces-Creating_a_project" />.
- </para>
- </step>
- -->
- </procedure>
+ </procedure>
- <para>
- Your project is now ready to use. Once components and functionality have been added, you can run the application on a server and access it through a web browser at the address <filename>http://localhost:8080/<replaceable>jsf-app</replaceable>/</filename>.
- </para>
+ <para>
+ Your project is now ready to use. Once components and functionality have been added, you can run the application on a server and access it through a web browser at the address <filename>http://localhost:8080/<replaceable>jsf-app</replaceable>/</filename>.
+ </para>
+ </section>
+
</section>
<section id="sect-Developer_Guide-Getting_started_with_RichFaces-Using_RichFaces_in_existing_JSF2_projects">
Modified: root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml
===================================================================
--- root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml 2010-05-27 18:19:39 UTC (rev 17328)
+++ root/docs/trunk/Developer_Guide/en-US/chap-Developer_Guide-RichFaces_overview.xml 2010-05-28 00:18:50 UTC (rev 17329)
@@ -217,7 +217,7 @@
</listitem>
<listitem>
<para>
- Maven 2.1.0 and higher
+ Maven 2.1.0 and higher (2.2.1 recommended)
</para>
</listitem>
</itemizedlist>
15 years, 4 months