struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject svn commit: r375191 - in /struts/shale/trunk: tiger/ tiger/src/java/org/apache/shale/tiger/faces/ tiger/src/test/org/apache/shale/tiger/faces/ xdocs/
Date Mon, 06 Feb 2006 05:40:58 GMT
Author: craigmcc
Date: Sun Feb  5 21:40:57 2006
New Revision: 375191

URL: http://svn.apache.org/viewcvs?rev=375191&view=rev
Log:
Commit the code that actually implements all of the fix for issue 38487
(narrow the set of jars scanned for annotations to those that have a
META-INF/faces-config.xml resource), plus fix a bug that caused the
actual parsing of such resources to be skipped.

Modified:
    struts/shale/trunk/tiger/build.xml
    struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/LifecycleListener.java
    struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
    struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
    struts/shale/trunk/xdocs/features-tiger-extensions.xml

Modified: struts/shale/trunk/tiger/build.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/tiger/build.xml?rev=375191&r1=375190&r2=375191&view=diff
==============================================================================
--- struts/shale/trunk/tiger/build.xml (original)
+++ struts/shale/trunk/tiger/build.xml Sun Feb  5 21:40:57 2006
@@ -263,10 +263,15 @@
     <!-- Copy non-Java Sources -->
     <copy        todir="${build.home}/test-classes">
       <fileset     dir="src/test">
-        <exclude  name="**/*.java"/>
+        <exclude  name="**/*.java **/faces-config.xml"/>
       </fileset>
     </copy>
 
+    <!-- Copy manifest for jar file -->
+    <mkdir         dir="${build.home}/test-classes/META-INF"/>
+    <copy        todir="${build.home}/test-classes/META-INF"
+                  file="src/test/org/apache/shale/tiger/faces/faces-config.xml"/>
+
     <!-- Copy runtime objects to webapp structure -->
     <mkdir         dir="${build.home}/test-webapp/WEB-INF/classes/org/apache/shale/tiger/faces"/>
     <copy        todir="${build.home}/test-webapp/WEB-INF/classes/org/apache/shale/tiger/faces">
@@ -293,7 +298,7 @@
     <mkdir         dir="${build.home}/test-webapp/WEB-INF/lib"/>
     <jar      destfile="${build.home}/test-webapp/WEB-INF/lib/test.jar"
                basedir="${build.home}/test-classes"
-              includes="org/apache/shale/tiger/config/TestBean3.class"/>
+              includes="org/apache/shale/tiger/config/TestBean3.class META-INF/faces-config.xml"/>
 
   </target>
 

Modified: struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/LifecycleListener.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/LifecycleListener.java?rev=375191&r1=375190&r2=375191&view=diff
==============================================================================
--- struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/LifecycleListener.java
(original)
+++ struts/shale/trunk/tiger/src/java/org/apache/shale/tiger/faces/LifecycleListener.java
Sun Feb  5 21:40:57 2006
@@ -113,7 +113,7 @@
      * inside application JARs.</p>
      */
     private static final String FACES_CONFIG_IMPLICIT =
-            "META_INF/faces-config.xml";
+            "META-INF/faces-config.xml";
 
 
     /**
@@ -157,7 +157,17 @@
     /**
      * <p>Configure a {@link FacesConfigConfig} bean representing metadata
      * from the <code>faces-config.xml</code> resource(s) for this
-     * application, and store it in an application scope attribute.</p>
+     * application, and store it in an application scope attribute.  In
+     * addition, scan classes in the following locations for Shale Tiger
+     * Extensions specific runtime annotations:</p>
+     * <ul>
+     * <li>All classes under <code>/WEB-INF/classes</code>.</li>
+     * <li>All classes in JAR files under <code>/WEB-INF/lib</code> that
+     *     contain an embedded <code>META-INF/faces-config.xml</code>
+     *     resource (the contents of that resource are irrelevant; it is
+     *     simply used to flag a JAR file as containing JavaServer Faces
+     *     related artifacts).</li>
+     * </ul>
      *
      * @param event <code>ServletContextEvent</code. representing the
      *  application that is starting up
@@ -274,8 +284,8 @@
 
 
     /**
-     * <p>Return a list of classes from the specified JAR archive.  If this
-     * archive has no classes in it, a zero-length list is returned.</p>
+     * <p>Return a list of classes to examine from the specified JAR archive.
+     * If this archive has no classes in it, a zero-length list is returned.</p>
      *
      * @param context <code>ServletContext</code> instance for
      *  this application
@@ -286,11 +296,12 @@
     private List<Class> archiveClasses(ServletContext context, JarFile jar)
         throws ClassNotFoundException {
 
+        // Accumulate and return a list of classes in this JAR file
+        List<Class> list = new ArrayList<Class>();
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         if (loader == null) {
             loader = this.getClass().getClassLoader();
         }
-        List<Class> list = new ArrayList<Class>();
         Enumeration<JarEntry> entries = jar.entries();
         while (entries.hasMoreElements()) {
             JarEntry entry = entries.nextElement();
@@ -612,9 +623,10 @@
 
     /**
      * <p>Return a list of the JAR archives defined under the
-     * <code>/WEB-INF/lib</code> directory of this web application.
-     * If there are no such JAR archives, a zero-length list
-     * will be returned.</p>
+     * <code>/WEB-INF/lib</code> directory of this web application
+     * that contain a <code>META-INF/faces-config.xml</code> resource
+     * (even if that resource is empty).  If there are no such JAR archives,
+     * a zero-length list will be returned.</p>
      *
      * @param servletContext <code>ServletContext</code> instance for
      *  this application
@@ -635,6 +647,15 @@
             String jarURLString = "jar:" + url.toString() + "!/";
             url = new URL(jarURLString);
             JarFile jarFile = ((JarURLConnection) url.openConnection()).getJarFile();
+            // Skip this JAR file if it does not have a META-INF/faces-config.xml
+            // resource (even if that resource is empty)
+            JarEntry signal = jarFile.getJarEntry(FACES_CONFIG_IMPLICIT);
+            if (signal == null) {
+                if (log().isTraceEnabled()) {
+                    log().trace("Skip JAR file " + path + " because it has no META-INF/faces-config.xml
resource");
+                }
+                continue;
+            }
             list.add(jarFile);
         }
         return list;

Modified: struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java?rev=375191&r1=375190&r2=375191&view=diff
==============================================================================
--- struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
(original)
+++ struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/LifecycleListenerTestCase.java
Sun Feb  5 21:40:57 2006
@@ -126,7 +126,7 @@
         assertNotNull(config);
         Map<String,ManagedBeanConfig> mbMap = fcConfig.getManagedBeans();
         assertNotNull(mbMap);
-        assertEquals(4, mbMap.size());
+        assertEquals(5, mbMap.size());
 
         ManagedPropertyConfig mpConfig = null;
 
@@ -264,6 +264,87 @@
         assertEquals("java.lang.String", mpConfig.getType());
         assertEquals("Override The Annotation", mpConfig.getValue());
         assertTrue(!mpConfig.isNullValue());
+
+        // Validate configuration of bean3
+        ManagedBeanConfig bean3 = fcConfig.getManagedBean("bean3");
+        assertNotNull(bean3);
+        assertTrue(bean3 == mbMap.get("bean3"));
+        assertEquals("bean3", bean3.getName());
+        assertEquals("org.apache.shale.tiger.config.TestBean3", bean3.getType());
+        assertEquals("session", bean3.getScope());
+        assertNull(bean3.getListEntries());
+        assertNull(bean3.getMapEntries());
+        Map<String,ManagedPropertyConfig> bean3Map = bean3.getProperties();
+        assertNotNull(bean3Map);
+        assertEquals(8, bean3Map.size());
+
+        mpConfig = bean3.getProperty("byteProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("byteProperty"));
+        assertEquals("byteProperty", mpConfig.getName());
+        assertEquals("byte", mpConfig.getType());
+        assertEquals("-1", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("charProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("charProperty"));
+        assertEquals("charProperty", mpConfig.getName());
+        assertEquals("char", mpConfig.getType());
+        assertEquals("z", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("doubleProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("doubleProperty"));
+        assertEquals("doubleProperty", mpConfig.getName());
+        assertEquals("double", mpConfig.getType());
+        assertEquals("-2.0", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("floatProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("floatProperty"));
+        assertEquals("floatProperty", mpConfig.getName());
+        assertEquals("float", mpConfig.getType());
+        assertEquals("-3.0", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("intProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("intProperty"));
+        assertEquals("intProperty", mpConfig.getName());
+        assertEquals("int", mpConfig.getType());
+        assertEquals("-4", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("longProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("longProperty"));
+        assertEquals("longProperty", mpConfig.getName());
+        assertEquals("long", mpConfig.getType());
+        assertEquals("-5", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("shortProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("shortProperty"));
+        assertEquals("shortProperty", mpConfig.getName());
+        assertEquals("short", mpConfig.getType());
+        assertEquals("-6", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        mpConfig = bean3.getProperty("stringProperty");
+        assertNotNull(mpConfig);
+        assertTrue(mpConfig == bean3Map.get("stringProperty"));
+        assertEquals("stringProperty", mpConfig.getName());
+        assertEquals("java.lang.String", mpConfig.getType());
+        assertEquals("Annotated", mpConfig.getValue());
+        assertTrue(!mpConfig.isNullValue());
+
+        // Test existence of "org.apache.shale.TAG_UTILITY_BEAN" managed bean
+        ManagedBeanConfig tagUtilityBean = fcConfig.getManagedBean("org.apache.shale.TAG_UTILITY_BEAN");
+        assertNotNull(tagUtilityBean);
 
         // Finalize the servlet context listener
         listener.contextDestroyed(event);

Modified: struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java?rev=375191&r1=375190&r2=375191&view=diff
==============================================================================
--- struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
(original)
+++ struts/shale/trunk/tiger/src/test/org/apache/shale/tiger/faces/VariableResolverImplTestCase.java
Sun Feb  5 21:40:57 2006
@@ -221,7 +221,7 @@
             externalContext.getApplicationMap().
             get(LifecycleListener.FACES_CONFIG_CONFIG);
         assertNotNull(config);
-        assertEquals(4, config.getManagedBeans().size());
+        assertEquals(5, config.getManagedBeans().size());
 
     }
 

Modified: struts/shale/trunk/xdocs/features-tiger-extensions.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/xdocs/features-tiger-extensions.xml?rev=375191&r1=375190&r2=375191&view=diff
==============================================================================
--- struts/shale/trunk/xdocs/features-tiger-extensions.xml (original)
+++ struts/shale/trunk/xdocs/features-tiger-extensions.xml Sun Feb  5 21:40:57 2006
@@ -138,6 +138,16 @@
         or later container, and <strong>MUST</strong> include the
         <code>shale-tiger.jar</code> resource in your web application.</p>
 
+        <p>To optimize performance at application startup, the Shale Tiger
+        Extensions will <strong>ONLY</strong> examine classes (to see if
+        they include the appropriate annotations) in the following lcoations:</p>
+        <ul>
+            <li>Any class under <code>/WEB-INF/classes</code>.</li>
+            <li>Any class in a JAR file under <code>/WEB-INF/lib</code>
that
+                includes a <code>META-INF/faces-config.xml</code> resource,
+                indicating that this JAR file is relevant to JavaServer Faces.</li>
+        </ul>
+
         <h4>Using Annotated Managed Beans</h4>
 
         <p>To use the <em>Annotated Managed Beans</em> feature, you must



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message