You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2013/08/08 18:40:06 UTC
svn commit: r1511859 - in /myfaces/trinidad-maven/trunk: ./
maven-faces-plugin/
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/
maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/fa...
Author: jwaldman
Date: Thu Aug 8 16:40:06 2013
New Revision: 1511859
URL: http://svn.apache.org/r1511859
Log:
TRINIDAD-2405 Allow numberConverter to specify roundingmode
This checkin is to the trinidad-maven/trunk branch
Thanks to Yee-Wah Lee for the patch
Added:
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ClassLoaderUtils.java
Modified:
myfaces/trinidad-maven/trunk/maven-faces-plugin/pom.xml
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
myfaces/trinidad-maven/trunk/maven-i18n-plugin/pom.xml
myfaces/trinidad-maven/trunk/maven-javacc-plugin/pom.xml
myfaces/trinidad-maven/trunk/maven-javascript-plugin/pom.xml
myfaces/trinidad-maven/trunk/maven-jdev-plugin/pom.xml
myfaces/trinidad-maven/trunk/maven-tagdoc-plugin/pom.xml
myfaces/trinidad-maven/trunk/maven-xrts-plugin/pom.xml
myfaces/trinidad-maven/trunk/pom.xml
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/AbstractTagGenerator.java Thu Aug 8 16:40:06 2013
@@ -19,19 +19,21 @@
package org.apache.myfaces.trinidadbuild.plugin.faces.generator.taglib;
import org.apache.myfaces.trinidadbuild.plugin.faces.io.PrettyWriter;
+import org.apache.myfaces.trinidadbuild.plugin.faces.util.ClassLoaderUtils;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
import org.apache.myfaces.trinidadbuild.plugin.faces.util.FilteredIterator;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.AbstractTagBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
import org.apache.myfaces.trinidadbuild.plugin.faces.generator.GeneratorHelper;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import java.util.Map;
-import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.Collections;
public abstract class AbstractTagGenerator {
@@ -234,7 +236,29 @@ public abstract class AbstractTagGenerat
protected String resolveType(String className)
{
- return (String)_RESOLVABLE_TYPES.get(className);
+ String type = (String)_RESOLVABLE_TYPES.get(className);
+
+ if (type != null)
+ return (String)_RESOLVABLE_TYPES.get(className);
+
+ try
+ {
+ // Enums may be set using String, add those as discovered.
+ if (ClassLoaderUtils.loadClass (className).isEnum())
+ {
+ _RESOLVABLE_TYPES .put (className, "Enum");
+ return "Enum";
+ }
+ }
+ catch (LinkageError le)
+ {
+ getLog().info("Linkage error resolving type " + className, le);
+ }
+ catch (ClassNotFoundException ce)
+ {
+ getLog().info ("ClassNotFound error resolving type " + className, ce);
+ }
+ return null;
}
// TODO: for everything but Locale, String[], Date, and TimeZone,
@@ -242,7 +266,7 @@ public abstract class AbstractTagGenerat
// not need any of the "TagUtils" functions
private Map<String, String> _createResolvableTypes()
{
- Map<String, String> resolvableTypes = new HashMap<String, String>();
+ Map<String, String> resolvableTypes = new ConcurrentHashMap<String, String>();
resolvableTypes.put("boolean", "Boolean");
resolvableTypes.put("char", "Character");
@@ -256,9 +280,8 @@ public abstract class AbstractTagGenerat
resolvableTypes.put("java.lang.String[]", "StringArray");
resolvableTypes.put("java.util.TimeZone", "TimeZone");
- return Collections.unmodifiableMap(resolvableTypes);
+ return (resolvableTypes);
}
- final private Map _RESOLVABLE_TYPES = _createResolvableTypes();
-
+ private Map _RESOLVABLE_TYPES = _createResolvableTypes();
}
Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadConverterTagGenerator.java Thu Aug 8 16:40:06 2013
@@ -114,13 +114,21 @@ public class TrinidadConverterTagGenerat
out.println("else");
out.println("{");
out.indent();
+
if ("StringArray".equals(propType))
{
out.println("try");
out.println("{");
}
- out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ".getValue(null));");
+ if ("Enum".equals (propType))
+ {
+ out.println(propClass + " value = Enum.valueOf(" + propClass + ".class, " + propVar + ".getExpressionString());");
+ }
+ else
+ {
+ out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ".getValue(null));");
+ }
String setMethod = Util.getPrefixedPropertyName("set", propName);
out.println("converter." + setMethod + "(value);");
if ("StringArray".equals(propType))
@@ -158,7 +166,15 @@ public class TrinidadConverterTagGenerat
out.println("try");
out.println("{");
}
- out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ");");
+
+ if ("Enum".equals (propType))
+ {
+ out.println(propClass + " value = Enum.valueOf(" + propClass + ".class, " + propVar + ");");
+ }
+ else
+ {
+ out.println(propClass + " value = TagUtils.get" + propType + "(" + propVar + ");");
+ }
String setMethod = Util.getPrefixedPropertyName("set", propName);
out.println("converter." + setMethod + "(value);");
if ("StringArray".equals(propType))
Added: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ClassLoaderUtils.java?rev=1511859&view=auto
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ClassLoaderUtils.java (added)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/ClassLoaderUtils.java Thu Aug 8 16:40:06 2013
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.trinidadbuild.plugin.faces.util;
+
+
+/**
+ * Utility methods for accessing classes and resources using an appropriate
+ * class loader.
+ *
+ */
+public final class ClassLoaderUtils
+{
+ // Utility class only, no instances
+ private ClassLoaderUtils()
+ {
+ }
+
+ /**
+ * Loads the class with the specified name. For Java 2 callers, the
+ * current thread's context class loader is preferred, falling back on the
+ * system class loader of the caller when the current thread's context is not
+ * set, or the caller is pre Java 2.
+ *
+ * @param name the name of the class
+ * @return the resulting <code>Class</code> object
+ * @exception ClassNotFoundException if the class was not found
+ */
+ public static Class<?> loadClass(
+ String name) throws ClassNotFoundException
+ {
+ return loadClass(name, null);
+ }
+
+ /**
+ * Loads the class with the specified name. For Java 2 callers, the
+ * current thread's context class loader is preferred, falling back on the
+ * class loader of the caller when the current thread's context is not set,
+ * or the caller is pre Java 2. If the callerClassLoader is null, then
+ * fall back on the system class loader.
+ *
+ * @param name the name of the class
+ * @param callerClassLoader the calling class loader context
+ * @return the resulting <code>Class</code> object
+ * @exception ClassNotFoundException if the class was not found
+ */
+ public static Class<?> loadClass(
+ String name,
+ ClassLoader callerClassLoader) throws ClassNotFoundException
+ {
+ Class<?> clazz = null;
+
+ try
+ {
+ ClassLoader loader = getContextClassLoader();
+
+ if (loader != null)
+ clazz = loader.loadClass(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // treat as though loader not set
+ ;
+ }
+
+ if (clazz == null)
+ {
+ if (callerClassLoader != null)
+ clazz = callerClassLoader.loadClass(name);
+ else
+ clazz = Class.forName(name);
+ }
+
+ return clazz;
+ }
+
+ /**
+ * Dynamically accesses the current context class loader.
+ * Returns null if there is no per-thread context class loader.
+ */
+ public static ClassLoader getContextClassLoader()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+}
Modified: myfaces/trinidad-maven/trunk/maven-i18n-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-i18n-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-i18n-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-i18n-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/maven-javacc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-javacc-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-javacc-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-javacc-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/maven-javascript-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-javascript-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-javascript-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-javascript-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/maven-jdev-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-jdev-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-jdev-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-jdev-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/maven-tagdoc-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-tagdoc-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-tagdoc-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-tagdoc-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/maven-xrts-plugin/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-xrts-plugin/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-xrts-plugin/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/maven-xrts-plugin/pom.xml Thu Aug 8 16:40:06 2013
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
</parent>
<groupId>org.apache.myfaces.trinidadbuild</groupId>
Modified: myfaces/trinidad-maven/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/pom.xml?rev=1511859&r1=1511858&r2=1511859&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/pom.xml (original)
+++ myfaces/trinidad-maven/trunk/pom.xml Thu Aug 8 16:40:06 2013
@@ -25,7 +25,7 @@
<groupId>org.apache.myfaces.trinidadbuild</groupId>
<artifactId>maven-plugin-parent</artifactId>
- <version>2.0.8-SNAPSHOT</version>
+ <version>2.0.9-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Apache Trinidad Maven Plugin Parent</name>