You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 18:05:44 UTC

[myfaces-trinidad-maven] 07/17: TRINIDAD-1461 - Build framework for jsr-276 metadata

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1.2.10.1-branch
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad-maven.git

commit 24745d534793bfe656c2e76317b3311271256297
Author: Matthias Wessendorf <ma...@apache.org>
AuthorDate: Mon May 4 06:11:35 2009 +0000

    TRINIDAD-1461 - Build framework for jsr-276 metadata
    
    Thanks to Bill Baggett for the patch
---
 .../plugin/faces/GenerateJspTaglibsMojo.java       |   3 +-
 .../plugin/faces/parse/FacesConfigParser.java      |   4 +
 .../plugin/faces/parse/PropertyBean.java           |  19 +++
 .../plugin/faces/resources/transform12.xsl         | 137 ++++++++++++++++++++-
 4 files changed, 159 insertions(+), 4 deletions(-)

diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
index 3fbecae..3bd4825 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
@@ -610,7 +610,8 @@ public class GenerateJspTaglibsMojo extends AbstractFacesMojo
           }
           stream.writeEndElement();
         }
-        else if (!property.isLiteralOnly() ||
+        else if ((!property.isLiteralOnly() &&
+                (!(property.getValueExpression() != null && property.getValueExpression().equals("PROHIBITED")))) ||
                  // "binding" is always a deferred-value
                  "binding".equals(propertyName))
         {
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
index 0de5e3f..404a484 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/FacesConfigParser.java
@@ -252,6 +252,10 @@ public class FacesConfigParser
     digester.addBeanPropertySetter("faces-config/component/property/property-extension/property-metadata/deprecated");
     digester.addCallMethod("faces-config/component/property/property-extension/property-metadata/no-op", "makeNoOp");
 
+    // jsr-276 metadata rules
+    digester.setRuleNamespaceURI("http://java.sun.com/xml/ns/javaee/faces/design-time-metadata");
+    digester.addBeanPropertySetter("faces-config/component/property/property-extension/property-metadata/required");
+    digester.addBeanPropertySetter("faces-config/component/property/property-extension/property-metadata/value-expression", "valueExpression");
 
     // XInclude rules
     digester.setRuleNamespaceURI(XIncludeFilter.XINCLUDE_NAMESPACE);
diff --git a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/PropertyBean.java b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/PropertyBean.java
index d641ea1..1f1a36d 100644
--- a/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/PropertyBean.java
+++ b/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/parse/PropertyBean.java
@@ -500,6 +500,24 @@ public class PropertyBean extends AttributeBean
     this._noOp = true;
   }
 
+  /**
+   * Sets the property valueExpression
+   * @param valueExpression
+   */
+  public void setValueExpression(String valueExpression)
+  {
+    this._valueExpression = valueExpression;
+  }
+
+  /**
+   * Value is provided through the valueExpression property metadata.
+   * @return valueExpression of the property
+   */
+  public String getValueExpression()
+  {
+    return _valueExpression;
+  }
+
   private String  _aliasOf;
   private String  _jspPropertyName;
   private String  _fieldPropertyName;
@@ -518,6 +536,7 @@ public class PropertyBean extends AttributeBean
   private String[] _unsupportedRenderKits = _EMPTY_ARRAY;
   private String _deprecated;
   private boolean _noOp = false;
+  private String _valueExpression;
 
   static private String[] _EMPTY_ARRAY = new String[0];
 
diff --git a/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl b/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
index 06152ed..6ca5f27 100644
--- a/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
+++ b/maven-faces-plugin/src/main/resources/org/apache/myfaces/trinidadbuild/plugin/faces/resources/transform12.xsl
@@ -24,8 +24,10 @@
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:javaee="http://java.sun.com/xml/ns/javaee"
                 xmlns:mfp="http://myfaces.apache.org/maven-faces-plugin"
-                exclude-result-prefixes="xsl xs javaee mfp"
-                version="1.0" >
+                xmlns:fmd="http://java.sun.com/xml/ns/javaee/faces/design-time-metadata"
+                xmlns:exsl="http://exslt.org/common"
+                exclude-result-prefixes="xsl xs javaee mfp fmd"
+                version="1.0">
 
   <xsl:output method="xml" indent="yes"/>
   <xsl:param name="packageContains" />
@@ -47,9 +49,24 @@
   <!-- switch off default text processing -->
   <xsl:template match="//text()" />
 
+  <!-- these are used for inserting a namespace declaration in xslt 1.0 -->
+  <xsl:variable name="fmd">
+    <xsl:element name="fmd:xxx" namespace="http://java.sun.com/xml/ns/javaee/faces/design-time-metadata"/>
+  </xsl:variable>
+  <xsl:variable name="mfp">
+    <xsl:element name="mfp:xxx" namespace="http://myfaces.apache.org/maven-faces-plugin"/>
+  </xsl:variable>
+  <xsl:variable name="mafp">
+    <xsl:element name="mafp:xxx" namespace="http://xmlns.oracle.com/maven-adf-faces-plugin"/>
+  </xsl:variable>
+
   <xsl:template match="/javaee:faces-config" >
     <xsl:element name="faces-config"
                  namespace="http://java.sun.com/xml/ns/javaee" >
+      <!-- Add namespace declarations at root element, so they don't show up at lower elements when we change namespaces -->
+      <xsl:copy-of select="exsl:node-set($fmd)//namespace::*"/>
+      <xsl:copy-of select="exsl:node-set($mfp)//namespace::*"/>
+      <xsl:copy-of select="exsl:node-set($mafp)//namespace::*"/>
       <xsl:attribute name="xsi:schemaLocation">http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd</xsl:attribute>
       <xsl:attribute name="version">1.2</xsl:attribute>
       <xsl:apply-templates select="javaee:application" />
@@ -78,6 +95,7 @@
       </xsl:for-each>
       <xsl:apply-templates select="javaee:lifecycle[contains(javaee:phase-listener, $packageContains)]" />
       <xsl:apply-templates select="javaee:validator[contains(javaee:validator-class, $validatorPackageContains)]" />
+      <xsl:apply-templates select="javaee:faces-config-extension" />
     </xsl:element>
   </xsl:template>
 
@@ -362,12 +380,14 @@
       <xsl:element name="facet-extension">
         <!-- Check for possible children of the metadata -->
         <xsl:if test="*[namespace-uri() != 'http://java.sun.com/xml/ns/javaee']">
+          <xsl:apply-templates select="fmd:facet-metadata"/>
           <xsl:element name="facet-metadata">
             <!-- Select metadata children -->
             <xsl:apply-templates select="mfp:facet-metadata/*[
               namespace-uri() != 'http://java.sun.com/xml/ns/javaee']" />
             <!-- Add non-metadata children under the metadata -->
             <xsl:apply-templates select="*[namespace-uri() != 'http://java.sun.com/xml/ns/javaee'
+              and namespace-uri() != 'http://java.sun.com/xml/ns/javaee/faces/design-time-metadata'
               and (
                 namespace-uri() != 'http://myfaces.apache.org/maven-faces-plugin'
                 or name() != 'mfp:facet-metadata'
@@ -460,12 +480,14 @@
       <xsl:element name="property-extension">
         <!-- Check for possible children of the metadata -->
         <xsl:if test="*[namespace-uri() != 'http://java.sun.com/xml/ns/javaee']">
+          <xsl:apply-templates select="fmd:property-metadata"/>
           <xsl:element name="property-metadata">
             <!-- Select metadata children -->
             <xsl:apply-templates select="mfp:property-metadata/*[
               namespace-uri() != 'http://java.sun.com/xml/ns/javaee']" />
             <!-- Add non-metadata children under the metadata -->
             <xsl:apply-templates select="*[namespace-uri() != 'http://java.sun.com/xml/ns/javaee'
+              and namespace-uri() != 'http://java.sun.com/xml/ns/javaee/faces/design-time-metadata'
               and (
                 namespace-uri() != 'http://myfaces.apache.org/maven-faces-plugin'
                 or name() != 'mfp:property-metadata'
@@ -876,7 +898,8 @@
    See JIRA issues ADFFACES-358, ADFFACES-361 and ADFFACES-472 -->
   <xsl:template match="javaee:property-extension/*[
     namespace-uri() != 'http://java.sun.com/xml/ns/javaee'
-    and namespace-uri() !='http://myfaces.apache.org/maven-faces-plugin']">
+    and namespace-uri() !='http://myfaces.apache.org/maven-faces-plugin'
+    and namespace-uri() !='http://java.sun.com/xml/ns/javaee/faces/design-time-metadata']">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
       <xsl:value-of select="text()"/>
@@ -901,6 +924,114 @@
     </xsl:element>
   </xsl:template>
 
+  <!-- Rule for the jsr-276 (top level) component metadata, just copy the whole thing -->
+  <xsl:template match="//fmd:component-metadata">
+    <xsl:element name="fmd:component-metadata">
+     <xsl:copy-of select="*"/>
+    </xsl:element>
+  </xsl:template>
+
+  <!-- Rule for the jsr-276 (top level) property metadata, just copy the whole thing -->
+  <xsl:template match="//fmd:property-metadata">
+    <xsl:element name="fmd:property-metadata">
+     <xsl:copy-of select="*"/>
+    </xsl:element>
+  </xsl:template>
+
+  <!-- Rule for the jsr-276 (top level) facet metadata, just copy the whole thing -->
+  <xsl:template match="//fmd:facet-metadata">
+    <xsl:element name="fmd:facet-metadata">
+     <xsl:copy-of select="*"/>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="//javaee:faces-config-extension">
+        <xsl:apply-templates select="fmd:global-metadata"/>
+  </xsl:template>
+
+  <!-- Rule for the jsr-276 (top level) global metadata extension -->
+  <xsl:template match="//fmd:global-metadata">
+    <xsl:element name="faces-config-extension">
+      <xsl:element name="fmd:global-metadata">
+        <xsl:apply-templates select="fmd:contract-definitions"/>
+        <xsl:apply-templates select="fmd:component-category-definitions"/>
+        <xsl:apply-templates select="fmd:property-category-definitions"/>
+        <xsl:apply-templates select="fmd:faces-taglib-definitions"/>
+      </xsl:element>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="//fmd:contract-definitions">
+    <xsl:element name="fmd:contract-definitions">
+      <xsl:copy-of select="*"/>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="//fmd:component-category-definitions">
+    <xsl:element name="fmd:component-category-definitions">
+      <xsl:copy-of select="*"/>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="//fmd:property-category-definitions">
+    <xsl:element name="fmd:property-category-definitions">
+      <xsl:copy-of select="*"/>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="//fmd:faces-taglib-definitions">
+    <xsl:element name="fmd:faces-taglib-definitions">
+      <xsl:apply-templates select="fmd:faces-taglib"/>
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="//fmd:faces-taglib">
+    <xsl:element name="fmd:faces-taglib">
+      <xsl:copy-of select="*"/>
+      <xsl:variable name="tagPrefix" select="fmd:short-name/text()"/>
+      <xsl:apply-templates select="*"/>
+        <xsl:for-each select="//javaee:validator">
+          <xsl:if test="starts-with(javaee:validator-extension/mfp:tag-name/text(), $tagPrefix)" >
+            <xsl:element name="fmd:tag">
+              <xsl:element name="fmd:name">
+                <xsl:value-of select="substring-after(javaee:validator-extension/mfp:tag-name/text(), ':')"/>
+              </xsl:element>
+              <xsl:element name="fmd:validator-id">
+                <xsl:value-of select="javaee:validator-id/text()"/>
+              </xsl:element>
+            </xsl:element>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:for-each select="//javaee:converter" >
+          <xsl:if test="starts-with(javaee:converter-extension/mfp:tag-name/text(), $tagPrefix)" >
+            <xsl:element name="fmd:tag">
+              <xsl:element name="fmd:name">
+                <xsl:value-of select="substring-after(javaee:converter-extension/mfp:tag-name/text(), ':')"/>
+              </xsl:element>
+              <xsl:element name="fmd:converter-id">
+                <xsl:value-of select="javaee:converter-id/text()"/>
+              </xsl:element>
+            </xsl:element>
+          </xsl:if>
+        </xsl:for-each>
+        <xsl:for-each select="//javaee:component" >
+          <xsl:if test="starts-with(javaee:component-extension/mfp:tag-name/text(), $tagPrefix)" >
+            <xsl:element name="fmd:tag">
+              <xsl:element name="fmd:name">
+                <xsl:value-of select="substring-after(javaee:component-extension/mfp:tag-name/text(), ':')"/>
+              </xsl:element>
+              <xsl:element name="fmd:component-type">
+                <xsl:value-of select="javaee:component-type/text()"/>
+              </xsl:element>
+              <xsl:element name="fmd:renderer-type">
+                <xsl:value-of select="javaee:component-extension/mfp:renderer-type/text()"/>
+              </xsl:element>
+            </xsl:element>
+          </xsl:if>
+        </xsl:for-each>
+    </xsl:element>
+  </xsl:template>
+
   <!-- Blacklisted mfp: that should not be copied over into the faces-config.xml: -->
   <xsl:template match="//mfp:alternate-class" />
   <xsl:template match="//mfp:author" />

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.