myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1516844 [1/2] - in /myfaces/tobago/trunk: ./ src/docbook/ tobago-core/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ tobago-core/src/test/java/org...
Date Fri, 23 Aug 2013 13:27:57 GMT
Author: lofwyr
Date: Fri Aug 23 13:27:56 2013
New Revision: 1516844

URL: http://svn.apache.org/r1516844
Log:
TOBAGO-1298: Re-implement TobagoConfigParser
 now parsing with SAXParser
 no longer need commons-digester

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigVersion.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParserUnitTest.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java
      - copied, changed from r1515387, myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserTest.java
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.0.30.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.5.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-2.0.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.0.30.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.5.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-2.0.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-unknown-version.xml
Removed:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ThemeParser.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserTest.java
Modified:
    myfaces/tobago/trunk/pom.xml
    myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml
    myfaces/tobago/trunk/tobago-core/pom.xml
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RendererConfig.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfig.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfigImpl.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeBuilder.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java
    myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml
    myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml

Modified: myfaces/tobago/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/pom.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/pom.xml (original)
+++ myfaces/tobago/trunk/pom.xml Fri Aug 23 13:27:56 2013
@@ -183,8 +183,6 @@
             <link>http://jakarta.apache.org/commons/collections/api-${commons-collection.version}/</link>
             <link>http://jakarta.apache.org/commons/lang/api-${commons-lang.version}/</link>
             <link>http://jakarta.apache.org/commons/fileupload/apidocs</link>
-            <link>http://jakarta.apache.org/commons/digester/commons-digester-${commons-digester.version}/docs/api/
-            </link>
             <link>http://jakarta.apache.org/commons/io/api-${commons-io.version}/</link>
             <link>http://jakarta.apache.org/commons/logging/commons-logging-${commons-logging.version}/apidocs/</link>
             <link>http://www.slf4j.org/apidocs</link>
@@ -476,11 +474,6 @@
         <scope>provided</scope>        
       </dependency>
       <dependency>
-        <groupId>commons-digester</groupId>
-        <artifactId>commons-digester</artifactId>
-        <version>${commons-digester.version}</version>
-      </dependency>
-      <dependency>
         <groupId>commons-fileupload</groupId>
         <artifactId>commons-fileupload</artifactId>
         <version>1.2.2</version>
@@ -883,10 +876,14 @@
           <artifactId>maven-surefire-plugin</artifactId>
           <version>2.9</version>
           <configuration>
-            <!--childDelegation>false</childDelegation>
+            <!--
+            <childDelegation>false</childDelegation>
             <forkMode>perTest</forkMode>
+            -->
+<!--
             <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE
-            -Xrunjdwp:transport=dt_socket,address=2111,server=y,suspend=y</argLine-->
+            -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y</argLine>
+-->
           </configuration>
         </plugin>
         <plugin>
@@ -1752,8 +1749,6 @@
     <commons-io.version>2.4</commons-io.version>
     <commons-lang.version>2.6</commons-lang.version>
     <commons-logging.version>1.1.1</commons-logging.version>
-    <!-- XXX digester 2.1 doesn't work -->
-    <commons-digester.version>1.8.1</commons-digester.version>
     <commons-collection.version>3.2.1</commons-collection.version>
     <maven.compile.source>1.5</maven.compile.source>
     <maven.compile.target>1.5</maven.compile.target>

Modified: myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml (original)
+++ myfaces/tobago/trunk/src/docbook/tobago-tutorial.xml Fri Aug 23 13:27:56 2013
@@ -107,12 +107,12 @@
   &lt;/theme-config&gt;
 &lt;/tobago-config&gt;</programlisting>
 
-    <para>A Tobago web application needs to package many libraries. First of
+    <para>A Tobago web application needs to package some libraries. First of
     all, the Tobago core jar and theme jars should be made available in the
     application. Some themes depend on each other, for example to be able to
     use the Speyside theme the Scarborough theme and Standard theme have to be
     included as well. These dependencies are defined in the
-    <filename>META-INF/tobago-theme.xml</filename> files inside the theme jars.</para>
+    <filename>META-INF/tobago-config.xml</filename> files inside the theme jars.</para>
 
     <para>Tobago depends on several Jakarta Commons libraries:</para>
 
@@ -126,7 +126,7 @@
       </listitem>
 
       <listitem>
-        <para>commons-digester</para>
+        <para>commons-digester (only Tobago 1.x)</para>
       </listitem>
 
       <listitem>

Modified: myfaces/tobago/trunk/tobago-core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/pom.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-core/pom.xml Fri Aug 23 13:27:56 2013
@@ -225,16 +225,6 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>commons-digester</groupId>
-      <artifactId>commons-digester</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>xml-apis</groupId>
-          <artifactId>xml-apis</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
       <groupId>commons-fileupload</groupId>
       <artifactId>commons-fileupload</artifactId>
     </dependency>

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RendererConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RendererConfig.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RendererConfig.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RendererConfig.java Fri Aug 23 13:27:56 2013
@@ -19,10 +19,10 @@
 
 package org.apache.myfaces.tobago.internal.config;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.tobago.context.Markup;
 
 import java.io.Serializable;
-import java.util.Locale;
 
 public class RendererConfig implements Serializable {
 
@@ -36,7 +36,7 @@ public class RendererConfig implements S
   }
 
   public void setName(String name) {
-    this.name = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1);
+    this.name = StringUtils.uncapitalize(name);
   }
 
   public boolean equals(Object o) {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfig.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfig.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfig.java Fri Aug 23 13:27:56 2013
@@ -19,12 +19,12 @@
 
 package org.apache.myfaces.tobago.internal.config;
 
-import java.util.Collection;
+import java.util.List;
 
 public interface RenderersConfig {
 
   boolean isMarkupSupported(String rendererName, String markup);
 
-  Collection<RendererConfig> getRendererConfigs();
+  List<RendererConfig> getRendererConfigs();
 
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfigImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfigImpl.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfigImpl.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/RenderersConfigImpl.java Fri Aug 23 13:27:56 2013
@@ -23,8 +23,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 public class RenderersConfigImpl implements RenderersConfig, Serializable {
@@ -45,8 +47,10 @@ public class RenderersConfigImpl impleme
     this.merged = merged;
   }
 
-  public Collection<RendererConfig> getRendererConfigs() {
-    return rendererMap.values();
+  public List<RendererConfig> getRendererConfigs() {
+    final ArrayList<RendererConfig> result = new ArrayList<RendererConfig>();
+    result.addAll(rendererMap.values());
+    return result;
   }
 
   public void addRenderer(RendererConfig rendererConfig) {
@@ -60,7 +64,7 @@ public class RenderersConfigImpl impleme
 
   public boolean isMarkupSupported(String rendererName, String markup) {
     if (LOG.isDebugEnabled()) {
-      LOG.debug("calling isMarkupSupported('{}', '{}')", rendererName, markup);
+      LOG.debug("Calling isMarkupSupported('{}', '{}')", rendererName, markup);
     }
     RendererConfig rendererConfig = rendererMap.get(rendererName);
     if (rendererConfig != null) {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigBuilder.java Fri Aug 23 13:27:56 2013
@@ -21,7 +21,6 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.myfaces.tobago.config.TobagoConfig;
-import org.apache.myfaces.tobago.context.ThemeImpl;
 import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,7 +28,9 @@ import org.xml.sax.SAXException;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
+import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -40,14 +41,11 @@ public class TobagoConfigBuilder {
 
   private static final String WEB_INF_TOBAGO_CONFIG_XML = "WEB-INF/tobago-config.xml";
   private static final String META_INF_TOBAGO_CONFIG_XML = "META-INF/tobago-config.xml";
-  /**
-   * @deprecated Since 1.5.0
-   */
-  private static final String META_INF_TOBAGO_THEME_XML = "META-INF/tobago-theme.xml";
 
   private List<TobagoConfigFragment> list;
 
-  private TobagoConfigBuilder(ServletContext servletContext) throws ServletException, IOException, SAXException {
+  private TobagoConfigBuilder(ServletContext servletContext)
+      throws ServletException, IOException, SAXException, ParserConfigurationException, URISyntaxException {
     list = new ArrayList<TobagoConfigFragment>();
     configFromClasspath();
     configFromWebInf(servletContext);
@@ -79,9 +77,10 @@ public class TobagoConfigBuilder {
     }
   }
 
-  private void configFromWebInf(ServletContext servletContext) throws IOException, SAXException {
+  private void configFromWebInf(ServletContext servletContext)
+      throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
 
-    final URL url = servletContext.getResource("/WEB-INF/tobago-config.xml");
+    final URL url = servletContext.getResource("/" + WEB_INF_TOBAGO_CONFIG_XML);
     if (url != null) {
       list.add(new TobagoConfigParser().parse(url));
     }
@@ -89,43 +88,31 @@ public class TobagoConfigBuilder {
 
   private void configFromClasspath() throws ServletException {
 
-    ThemeParser parser = new ThemeParser();
     try {
       if (LOG.isInfoEnabled()) {
-        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML + "'");
+        LOG.info("Searching for '" + META_INF_TOBAGO_CONFIG_XML + "'");
       }
-      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-      List<URL> urls = new ArrayList<URL>();
+      final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+      final List<URL> urls = new ArrayList<URL>();
       CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
-      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));
 
-      for (URL themeUrl : urls) {
-        TobagoConfigFragment tobagoConfig;
-        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
-          tobagoConfig = new TobagoConfigParser().parse(themeUrl);
-        } else {
-          // the old way
-          tobagoConfig = new TobagoConfigFragment();
-          final ThemeImpl theme = parser.parse(themeUrl);
-          tobagoConfig.addThemeDefinition(theme);
-        }
-        tobagoConfig.setUrl(themeUrl);
-        String protocol = themeUrl.getProtocol();
+      for (final URL themeUrl : urls) {
+        final TobagoConfigFragment fragment = new TobagoConfigParser().parse(themeUrl);
+        fragment.setUrl(themeUrl);
+        list.add(fragment);
+
         // tomcat uses jar
         // weblogic uses zip
         // IBM WebSphere uses wsjar
+        final String protocol = themeUrl.getProtocol();
         if (!"jar".equals(protocol) && !"zip".equals(protocol) && !"wsjar".equals(protocol)) {
           LOG.warn("Unknown protocol '" + themeUrl + "'");
         }
-
-        list.add(tobagoConfig);
       }
     } catch (Exception e) {
-      String msg = "while loading ";
+      final String msg = "while loading ";
       LOG.error(msg, e);
       throw new ServletException(msg, e);
     }
   }
-
-
 }

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java Fri Aug 23 13:27:56 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.tobago.internal.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class TobagoConfigEntityResolver extends DefaultHandler {
+
+  private static final String TOBAGO_CONFIG_DTD_1_0 = "/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd";
+  private static final String TOBAGO_CONFIG_DTD_1_0_29 = "/org/apache/myfaces/tobago/config/tobago-config-1.0.29.dtd";
+  private static final String TOBAGO_CONFIG_DTD_1_0_30 = "/org/apache/myfaces/tobago/config/tobago-config-1.0.30.dtd";
+  private static final String TOBAGO_CONFIG_DTD_1_0_34 = "/org/apache/myfaces/tobago/config/tobago-config-1.0.34.dtd";
+  protected static final String TOBAGO_CONFIG_XSD_1_5 = "/org/apache/myfaces/tobago/config/tobago-config-1.5.xsd";
+  @Deprecated
+  protected static final String TOBAGO_CONFIG_XSD_1_6 = "/org/apache/myfaces/tobago/config/tobago-config-1.6.xsd";
+  protected static final String TOBAGO_CONFIG_XSD_2_0 = "/org/apache/myfaces/tobago/config/tobago-config-2.0.xsd";
+
+  private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigEntityResolver.class);
+
+  @Override
+  public InputSource resolveEntity(final String publicId, final String systemId) throws IOException, SAXException {
+    if (LOG.isInfoEnabled()) {
+      LOG.info("Resolving publicId='" + publicId + "' and systemId='" + systemId + "'.");
+    }
+    final InputStream localStream;
+    if (systemId.equals("http://myfaces.apache.org/tobago/tobago-config_1_0.dtd")) {
+      localStream = getClass().getResourceAsStream(TOBAGO_CONFIG_DTD_1_0);
+    } else if (systemId.equals("http://myfaces.apache.org/tobago/tobago-config-1.0.29.dtd")) {
+      localStream = getClass().getResourceAsStream(TOBAGO_CONFIG_DTD_1_0_29);
+    } else if (systemId.equals("http://myfaces.apache.org/tobago/tobago-config-1.0.30.dtd")) {
+      localStream = getClass().getResourceAsStream(TOBAGO_CONFIG_DTD_1_0_30);
+    } else if (systemId.equals("http://myfaces.apache.org/tobago/tobago-config-1.0.34.dtd")) {
+      localStream = getClass().getResourceAsStream(TOBAGO_CONFIG_DTD_1_0_34);
+    } else {
+      localStream = null;
+    }
+    if (localStream != null) {
+      return new InputSource(localStream);
+    } else {
+      LOG.warn("Didn't find local resource for publicId='" + publicId + "' and systemId='" + systemId + "'. "
+          + "Trying to load with parent resolver (might be loaded over the internet).");
+      return super.resolveEntity(publicId, systemId);
+    }
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java Fri Aug 23 13:27:56 2013
@@ -96,8 +96,8 @@ public class TobagoConfigImpl extends To
       }
       if (defaultTheme == null) {
         String error = "Did not found any theme! "
-            + "Please ensure you have a tobago-theme.xml file in your "
-            + "theme jar. Please add a theme jar to your WEB-INF/lib";
+            + "Please ensure you have a tobago-config.xml with a theme-definition in your "
+            + "theme JAR. Please add a theme JAR to your WEB-INF/lib";
         LOG.error(error);
         throw new RuntimeException(error);
       } else {
@@ -122,8 +122,8 @@ public class TobagoConfigImpl extends To
   private void checkThemeIsAvailable(String name, Theme theme) {
     if (theme == null) {
       String error = "Theme not found! name: '" + name + "'. "
-          + "Please ensure you have a tobago-theme.xml file in your "
-          + "theme jar. Found the following themes: " + availableThemes.keySet();
+          + "Please ensure you have a tobago-config.xml with a theme-definition in your "
+          + "theme JAR. Found the following themes: " + availableThemes.keySet();
       LOG.error(error);
       throw new RuntimeException(error);
     }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java Fri Aug 23 13:27:56 2013
@@ -19,185 +19,356 @@
 
 package org.apache.myfaces.tobago.internal.config;
 
-import org.apache.commons.digester.Digester;
 import org.apache.commons.io.IOUtils;
 import org.apache.myfaces.tobago.context.ThemeImpl;
-import org.apache.myfaces.tobago.context.ThemeResources;
 import org.apache.myfaces.tobago.context.ThemeScript;
 import org.apache.myfaces.tobago.context.ThemeStyle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
 import javax.faces.FacesException;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.Stack;
 
-public class TobagoConfigParser {
+public class TobagoConfigParser extends TobagoConfigEntityResolver {
 
   private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigParser.class);
 
-  private static final String TOBAGO_CONFIG_DTD_1_0 = "/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd";
-  private static final String TOBAGO_CONFIG_DTD_1_0_29 = "/org/apache/myfaces/tobago/config/tobago-config-1.0.29.dtd";
-  private static final String TOBAGO_CONFIG_DTD_1_0_30 = "/org/apache/myfaces/tobago/config/tobago-config-1.0.30.dtd";
-  private static final String TOBAGO_CONFIG_DTD_1_0_34 = "/org/apache/myfaces/tobago/config/tobago-config-1.0.34.dtd";
-  private static final String TOBAGO_CONFIG_XSD_1_5 = "/org/apache/myfaces/tobago/config/tobago-config-1.5.xsd";
-  @Deprecated
-  private static final String TOBAGO_CONFIG_XSD_1_6 = "/org/apache/myfaces/tobago/config/tobago-config-1.6.xsd";
-  private static final String TOBAGO_CONFIG_XSD_2_0 = "/org/apache/myfaces/tobago/config/tobago-config-2.0.xsd";
+  private static final int TOBAGO_CONFIG = -1498874611;
+  private static final int NAME = 3373707;
+  private static final int ORDERING = 1234314708;
+  private static final int BEFORE = -1392885889;
+  private static final int AFTER = 92734940;
+  private static final int THEME_CONFIG = 1930630086;
+  private static final int DEFAULT_THEME = -114431171;
+  private static final int SUPPORTED_THEME = -822303766;
+  private static final int RESOURCE_DIR = -385546674;
+  private static final int CREATE_SESSION_SECRET = 413906616;
+  private static final int CHECK_SESSION_SECRET = 275994924;
+  private static final int PREVENT_FRAME_ATTACKS = 270456726;
+  private static final int CONTENT_SECURITY_POLICY = 1207440139;
+  private static final int DIRECTIVE = -962590641;
+  private static final int RENDERERS = 1839650832;
+  private static final int RENDERER = -494845757;
+  private static final int SUPPORTED_MARKUP = 71904295;
+  private static final int MARKUP = -1081305560;
+  private static final int THEME_DEFINITIONS = -255617156;
+  private static final int THEME_DEFINITION = 1515774935;
+  private static final int DISPLAY_NAME = 1568910518;
+  private static final int RESOURCE_PATH = 933304964;
+  private static final int FALLBACK = 761243362;
+  private static final int VERSIONED = -1407102089;
+  private static final int RESOURCES = -1983070683;
+  private static final int SCRIPT = -907685685;
+  private static final int STYLE = 109780401;
+
+  private TobagoConfigFragment tobagoConfig;
+  private RendererConfig currentRenderer;
+  private ThemeImpl currentTheme;
+  private Boolean production;
+  private String text;
 
-  private Digester digester;
+  private Stack<String> stack;
 
   public TobagoConfigParser() {
-    digester = new Digester();
-    digester.setUseContextClassLoader(true);
-    configure();
-    registerDtds();
   }
 
-  public TobagoConfigFragment parse(URL url) throws IOException, SAXException, FacesException {
+  public TobagoConfigFragment parse(URL url)
+      throws IOException, SAXException, FacesException, ParserConfigurationException, URISyntaxException {
 
     if (LOG.isInfoEnabled()) {
       LOG.info("Parsing configuration file: '{}'", url);
     }
 
-    TobagoConfigFragment tobagoConfig = new TobagoConfigFragment();
-    digester.push(tobagoConfig);
+    final TobagoConfigVersion version = new TobagoConfigVersion(url);
+
+    // todo: Is there a solution that validate with both, DTD and XSD?
+
+    if (version.isSchema()) {
+      validate(url, version);
+    }
+
     InputStream inputStream = null;
     try {
-      configureValidation(url);
       inputStream = url.openStream();
-      digester.parse(inputStream);
+      final SAXParserFactory factory = SAXParserFactory.newInstance();
+      if (!version.isSchema()) {
+        factory.setValidating(true);
+      }
+      final SAXParser saxParser = factory.newSAXParser();
+      saxParser.parse(inputStream, this);
     } finally {
       IOUtils.closeQuietly(inputStream);
     }
     return tobagoConfig;
   }
 
-  private void configureValidation(URL url) {
-    // TODO: validating is turned of in case of a schema
-    try {
-      final String xml = IOUtils.toString(url.openStream());
-      if (xml.indexOf("tobago-config-1.5.xsd") > 0
-          || xml.indexOf("tobago-config-1.6.xsd") > 0
-          || xml.indexOf("tobago-config-2.0.xsd") > 0) {
-        digester.setValidating(false);
-        return;
-      }
-    } catch (Exception e) {
-      LOG.warn("Error while checking: '" + url + "'", e);
-    }
-    digester.setValidating(true);
+  @Override
+  public void startDocument() throws SAXException {
+    stack = new Stack<String>();
   }
 
-  private Digester configure() {
+  @Override
+  public void endDocument() throws SAXException {
+    assert stack.empty();
+    stack = null;
+  }
 
-    // ordering
-    digester.addCallMethod("tobago-config/name", "setName", 0);
-    digester.addCallMethod("tobago-config/ordering/before/name", "addBefore", 0);
-    digester.addCallMethod("tobago-config/ordering/after/name", "addAfter", 0);
-
-    // theme-config
-    digester.addCallMethod("tobago-config/theme-config/default-theme", "setDefaultThemeName", 0);
-    digester.addCallMethod("tobago-config/theme-config/supported-theme", "addSupportedThemeName", 0);
-
-    // resource dirs
-    digester.addCallMethod("tobago-config/resource-dir", "addResourceDir", 0);
-
-    // enable ajax
-    digester.addCallMethod("tobago-config/ajax-enabled", "setAjaxEnabled", 0);
-
-    // see bug TOBAGO-912
-    digester.addCallMethod("tobago-config/fix-resource-order", "setFixResourceOrder", 0);
-
-    // see bug TOBAGO-916
-    digester.addCallMethod("tobago-config/fix-layout-transparency", "setFixLayoutTransparency", 0);
-
-    // session secret
-    digester.addCallMethod("tobago-config/create-session-secret", "setCreateSessionSecret", 0);
-    digester.addCallMethod("tobago-config/check-session-secret", "setCheckSessionSecret", 0);
-
-    // frame attacks
-    digester.addBeanPropertySetter("tobago-config/prevent-frame-attacks", "preventFrameAttacks");
-
-    // content-security-policy
-    digester.addCallMethod("tobago-config/content-security-policy/directive", "addContentSecurityPolicy", 0);
-
-    // renderer config
-    digester.addObjectCreate("tobago-config/renderers", RenderersConfigImpl.class);
-    digester.addSetNext("tobago-config/renderers", "setRenderersConfig");
-    digester.addObjectCreate("tobago-config/renderers/renderer", RendererConfig.class);
-    digester.addSetNext("tobago-config/renderers/renderer", "addRenderer");
-    digester.addCallMethod("tobago-config/renderers/renderer/name", "setName", 0);
-    digester.addCallMethod("tobago-config/renderers/renderer/supported-markup/markup", "addSupportedMarkup", 0);
-
-    // theme definition
-    digester.addObjectCreate("tobago-config/theme-definitions/theme-definition", ThemeImpl.class);
-    digester.addSetNext("tobago-config/theme-definitions/theme-definition", "addThemeDefinition");
-    digester.addCallMethod("tobago-config/theme-definitions/theme-definition/name", "setName", 0);
-    digester.addCallMethod("tobago-config/theme-definitions/theme-definition/display-name", "setDisplayName", 0);
-    digester.addCallMethod("tobago-config/theme-definitions/theme-definition/resource-path", "setResourcePath", 0);
-    digester.addCallMethod("tobago-config/theme-definitions/theme-definition/fallback", "setFallbackName", 0);
-    digester.addBeanPropertySetter("tobago-config/theme-definitions/theme-definition/versioned",
-        "versioned");
-    digester.addObjectCreate("tobago-config/theme-definitions/theme-definition/renderers", RenderersConfigImpl.class);
-    digester.addSetNext("tobago-config/theme-definitions/theme-definition/renderers", "setRenderersConfig");
-    digester.addObjectCreate(
-        "tobago-config/theme-definitions/theme-definition/renderers/renderer", RendererConfig.class);
-    digester.addSetNext("tobago-config/theme-definitions/theme-definition/renderers/renderer", "addRenderer");
-    digester.addCallMethod("tobago-config/theme-definitions/theme-definition/renderers/renderer/name", "setName", 0);
-    digester.addCallMethod(
-        "tobago-config/theme-definitions/theme-definition/renderers/renderer/supported-markup/markup",
-        "addSupportedMarkup", 0);
-    digester.addObjectCreate("tobago-config/theme-definitions/theme-definition/resources", ThemeResources.class);
-    digester.addSetProperties("tobago-config/theme-definitions/theme-definition/resources");
-    digester.addSetNext("tobago-config/theme-definitions/theme-definition/resources", "addResources");
-    digester.addObjectCreate("tobago-config/theme-definitions/theme-definition/resources/script", ThemeScript.class);
-    digester.addSetProperties("tobago-config/theme-definitions/theme-definition/resources/script");
-    digester.addSetNext("tobago-config/theme-definitions/theme-definition/resources/script", "addScript");
-    digester.addObjectCreate("tobago-config/theme-definitions/theme-definition/resources/style", ThemeStyle.class);
-    digester.addSetProperties("tobago-config/theme-definitions/theme-definition/resources/style");
-    digester.addSetNext("tobago-config/theme-definitions/theme-definition/resources/style", "addStyle");
-
-    return digester;
-  }
-
-  private void registerDtds() {
-    registerDtd("-//Atanion GmbH//DTD Tobago Config 1.0//EN", TOBAGO_CONFIG_DTD_1_0);
-    registerDtd("-//The Apache Software Foundation//DTD Tobago Config 1.0//EN", TOBAGO_CONFIG_DTD_1_0);
-    registerDtd("-//The Apache Software Foundation//DTD Tobago Config 1.0.29//EN", TOBAGO_CONFIG_DTD_1_0_29);
-    registerDtd("-//The Apache Software Foundation//DTD Tobago Config 1.0.30//EN", TOBAGO_CONFIG_DTD_1_0_30);
-    registerDtd("-//The Apache Software Foundation//DTD Tobago Config 1.0.34//EN", TOBAGO_CONFIG_DTD_1_0_34);
-    // todo: find a way to register the schema
-    //    registerDtd("http://myfaces.apache.org/tobago/tobago-config", TOBAGO_CONFIG_XSD_1_5);
-    //    registerXsd("http://myfaces.apache.org/tobago/tobago-config", TOBAGO_CONFIG_XSD_1_5);
-  }
-
-  private void registerDtd(String publicId, String entityUrl) {
-    URL url = TobagoConfigParser.class.getResource(entityUrl);
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Registering dtd: url='{}'", url);
-    }
-    if (null != url) {
-      digester.register(publicId, url.toString());
-    } else {
-      LOG.warn("Unable to retrieve local DTD '" + entityUrl + "'; trying external URL");
+  @Override
+  public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+
+    stack.add(qName);
+
+    switch (qName.hashCode()) {
+
+      case TOBAGO_CONFIG:
+        tobagoConfig = new TobagoConfigFragment();
+        break;
+
+      case CONTENT_SECURITY_POLICY:
+        LOG.warn("todo: not implemented yet!"); // todo
+        attributes.getValue("disabled");
+        attributes.getValue("replace");
+        break;
+
+      case RENDERERS:
+        if (currentTheme != null) {
+          currentTheme.setRenderersConfig(new RenderersConfigImpl());
+        } else {
+          tobagoConfig.setRenderersConfig(new RenderersConfigImpl());
+        }
+        break;
+
+      case RENDERER:
+        currentRenderer = new RendererConfig();
+        break;
+
+      case THEME_DEFINITION:
+        currentTheme = new ThemeImpl();
+        tobagoConfig.addThemeDefinition(currentTheme);
+        break;
+
+      case RESOURCES:
+        production = Boolean.parseBoolean(attributes.getValue("production"));
+        break;
+
+      case SCRIPT:
+        final ThemeScript script = new ThemeScript();
+        script.setName(attributes.getValue("name"));
+        if (production) {
+          currentTheme.getProductionResources().addScript(script);
+        } else {
+          currentTheme.getResources().addScript(script);
+        }
+        break;
+
+      case STYLE:
+        final ThemeStyle style = new ThemeStyle();
+        style.setName(attributes.getValue("name"));
+        if (production) {
+          currentTheme.getProductionResources().addStyle(style);
+        } else {
+          currentTheme.getResources().addStyle(style);
+        }
+        break;
+
+      case NAME:
+      case ORDERING:
+      case BEFORE:
+      case AFTER:
+      case RESOURCE_DIR:
+      case THEME_CONFIG:
+      case DEFAULT_THEME:
+      case SUPPORTED_THEME:
+      case SUPPORTED_MARKUP:
+      case MARKUP:
+      case CREATE_SESSION_SECRET:
+      case CHECK_SESSION_SECRET:
+      case PREVENT_FRAME_ATTACKS:
+      case DIRECTIVE:
+      case THEME_DEFINITIONS:
+      case DISPLAY_NAME:
+      case RESOURCE_PATH:
+      case VERSIONED:
+      case FALLBACK:
+        break;
+
+      default:
+        LOG.warn("Ignoring unknown start tag <" + qName + ">");
     }
   }
 
-/*
-  private void registerXsd(String publicId, String entityUrl) {
-    URL url = TobagoConfigParser.class.getResource(entityUrl);
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Registering dtd: url='{}'", url);
+  @Override
+  public void characters(char[] ch, int start, int length) throws SAXException {
+    text = new String(ch, start, length);
+  }
+
+  @Override
+  public void endElement(String uri, String localName, String qName) throws SAXException {
+    assert qName.equals(stack.peek());
+
+    switch (qName.hashCode()) {
+
+      case NAME:
+        final String parent = stack.get(stack.size() - 2);
+        switch (parent.hashCode()) {
+
+          case TOBAGO_CONFIG:
+            tobagoConfig.setName(text);
+            break;
+
+          case BEFORE:
+            tobagoConfig.addBefore(text);
+            break;
+
+          case AFTER:
+            tobagoConfig.addAfter(text);
+            break;
+
+          case RENDERER:
+            currentRenderer.setName(text);
+            if (currentTheme != null) {
+              ((RenderersConfigImpl) currentTheme.getRenderersConfig()).addRenderer(currentRenderer);
+            } else {
+              ((RenderersConfigImpl) tobagoConfig.getRenderersConfig()).addRenderer(currentRenderer);
+            }
+            break;
+
+          case THEME_DEFINITION:
+            currentTheme.setName(text);
+            break;
+
+          default:
+            LOG.warn("Ignoring unknown parent <" + qName + "> of tag <name>");
+        }
+        break;
+
+      case DEFAULT_THEME:
+        tobagoConfig.setDefaultThemeName(text);
+        break;
+
+      case SUPPORTED_THEME:
+        tobagoConfig.addSupportedThemeName(text);
+        break;
+
+      case RESOURCE_DIR:
+        tobagoConfig.addResourceDir(text);
+        break;
+
+      case CREATE_SESSION_SECRET:
+        tobagoConfig.setCreateSessionSecret(text);
+        break;
+
+      case CHECK_SESSION_SECRET:
+        tobagoConfig.setCheckSessionSecret(text);
+        break;
+
+      case PREVENT_FRAME_ATTACKS:
+        tobagoConfig.setPreventFrameAttacks(Boolean.parseBoolean(text));
+        break;
+
+      case DIRECTIVE:
+        tobagoConfig.addContentSecurityPolicy(text);
+        break;
+
+      case MARKUP:
+        currentRenderer.addSupportedMarkup(text);
+        break;
+
+      case DISPLAY_NAME:
+        currentTheme.setDisplayName(text);
+        break;
+
+      case RESOURCE_PATH:
+        currentTheme.setResourcePath(text);
+        break;
+
+      case FALLBACK:
+        currentTheme.setFallbackName(text);
+        break;
+
+      case THEME_DEFINITION:
+        currentTheme = null;
+        break;
+
+      case VERSIONED:
+        currentTheme.setVersioned(Boolean.parseBoolean(text));
+        break;
+
+      case RESOURCES:
+        production = null;
+        break;
+
+      case TOBAGO_CONFIG:
+      case THEME_CONFIG:
+      case ORDERING:
+      case BEFORE:
+      case AFTER:
+      case SUPPORTED_MARKUP:
+      case CONTENT_SECURITY_POLICY:
+      case THEME_DEFINITIONS:
+      case RENDERERS:
+      case RENDERER:
+      case SCRIPT:
+      case STYLE:
+        break;
+
+      default:
+        LOG.warn("Ignoring unknown end tag <" + qName + ">");
     }
-    if (null != url) {
-      digester.setSchema(publicId);
-    //  digester.setSchemaLanguage();
+
+    stack.pop();
+  }
+
+  @Override
+  public void warning(SAXParseException e) throws SAXException {
+    throw e;
+  }
+
+  @Override
+  public void error(SAXParseException e) throws SAXException {
+    throw e;
+  }
+
+  @Override
+  public void fatalError(SAXParseException e) throws SAXException {
+    throw e;
+  }
+
+  private void validate(final URL url, final TobagoConfigVersion version)
+      throws URISyntaxException, SAXException, IOException {
+
+    final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+    final Schema schema;
+    if ("2.0".equals(version.getVersion())) {
+      schema = schemaFactory.newSchema(getClass().getResource(TOBAGO_CONFIG_XSD_2_0));
+    } else if ("1.6".equals(version.getVersion())) {
+      LOG.warn("Using deprecated schema with version attribute 1.6 in file: '" + url + "'");
+      schema = schemaFactory.newSchema(getClass().getResource(TOBAGO_CONFIG_XSD_1_6));
+    } else if ("1.5".equals(version.getVersion())) {
+      schema = schemaFactory.newSchema(getClass().getResource(TOBAGO_CONFIG_XSD_1_5));
     } else {
-      LOG.warn("Unable to retrieve local DTD '" + entityUrl + "'; trying external URL");
+      throw new SAXException("Using unknown version attribute '" + version.getVersion() + "' in file: '" + url + "'");
     }
+    final Validator validator = schema.newValidator();
+    final Source source = new StreamSource(url.openStream());
+
+    validator.validate(source);
   }
-*/
+
 }

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigVersion.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigVersion.java?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigVersion.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigVersion.java Fri Aug 23 13:27:56 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.tobago.internal.config;
+
+import org.apache.commons.io.IOUtils;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+public class TobagoConfigVersion extends TobagoConfigEntityResolver {
+
+  /** Schema or DTD? */
+  private boolean schema;
+
+  private String version;
+
+  public TobagoConfigVersion(URL url) throws ParserConfigurationException, SAXException, IOException {
+
+    // simple reading with no validation, at this time
+    InputStream inputStream = null;
+    try {
+      inputStream = url.openStream();
+      SAXParserFactory factory = SAXParserFactory.newInstance();
+      SAXParser saxParser = factory.newSAXParser();
+      saxParser.parse(inputStream, this);
+    } finally {
+      IOUtils.closeQuietly(inputStream);
+    }
+  }
+
+  @Override
+  public void startElement(String uri, String localName, String qName, Attributes attributes) {
+    if ("tobago-config".equals(qName)) {
+      version = attributes.getValue("version");
+      schema = version != null;
+    }
+  }
+
+  public boolean isSchema() {
+    return schema;
+  }
+
+  public String getVersion() {
+    return version;
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java Fri Aug 23 13:27:56 2013
@@ -19,16 +19,12 @@
 
 package org.apache.myfaces.tobago.internal.context;
 
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.myfaces.tobago.context.ThemeImpl;
-import org.apache.myfaces.tobago.internal.config.ThemeParser;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigFragment;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigParser;
-import org.apache.myfaces.tobago.internal.util.Deprecation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.xml.sax.SAXException;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -40,9 +36,7 @@ import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 import java.util.zip.ZipEntry;
@@ -59,7 +53,6 @@ class ResourceLocator {
   private static final Logger LOG = LoggerFactory.getLogger(ResourceLocator.class);
 
   private static final String META_INF_TOBAGO_CONFIG_XML = "META-INF/tobago-config.xml";
-  private static final String META_INF_TOBAGO_THEME_XML = "META-INF/tobago-theme.xml";
   private static final String META_INF_RESOURCES = "META-INF/resources";
 
   private ServletContext servletContext;
@@ -75,7 +68,7 @@ class ResourceLocator {
 
   public void locate()
       throws ServletException {
-    // TODO should the resourcedir used from tobago-config.xml?
+    // TBD should the resource dir used from tobago-config.xml?
     locateResourcesInWar(servletContext, resourceManager, "/");
     locateResourcesFromClasspath(resourceManager);
     locateResourcesServlet30Alike(resourceManager);
@@ -137,61 +130,52 @@ class ResourceLocator {
   private void locateResourcesFromClasspath(ResourceManagerImpl resources)
       throws ServletException {
 
-    ThemeParser parser = new ThemeParser();
     try {
       if (LOG.isInfoEnabled()) {
-        LOG.info("Searching for '" + META_INF_TOBAGO_THEME_XML + "' and '" + META_INF_TOBAGO_CONFIG_XML +"'");
+        LOG.info("Searching for and '" + META_INF_TOBAGO_CONFIG_XML +"'");
       }
-      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-      List<URL> urls = new ArrayList<URL>();
-      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_CONFIG_XML));
-      CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));
-
-      for (URL themeUrl : urls) {
-        if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
-          TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
-          for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
-            if (theme.isVersioned()) {
-              String themeUrlStr = themeUrl.toString();
-              int index = themeUrlStr.indexOf(META_INF_TOBAGO_CONFIG_XML);
-              String metaInf = themeUrlStr.substring(0, index) + "META-INF/MANIFEST.MF";
-              Properties properties = new Properties();
-              final URL url = new URL(metaInf);
-              InputStream inputStream = null;
-              String version = null;
-              try {
-                inputStream = url.openStream();
-                properties.load(inputStream);
-                version = properties.getProperty("Implementation-Version");
-              } catch (FileNotFoundException e) {
-                // may happen (e. g. in tests)
-                LOG.error("No Manifest-File found.");
-              } finally {
-                IOUtils.closeQuietly(inputStream);
-              }
-              if (version != null) {
-                theme.setVersion(version);
-              } else {
-                theme.setVersioned(false);
-                LOG.error("No Implementation-Version found in Manifest-File for theme: '" + theme.getName()
-                    + "'. Resetting the theme to unversioned. Please correct the Manifest-File.");
-              }
+      final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+      final Enumeration<URL> urls = classLoader.getResources(META_INF_TOBAGO_CONFIG_XML);
+
+      while (urls.hasMoreElements()) {
+        URL themeUrl = urls.nextElement();
+        TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
+        for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
+          if (theme.isVersioned()) {
+            String themeUrlStr = themeUrl.toString();
+            int index = themeUrlStr.indexOf(META_INF_TOBAGO_CONFIG_XML);
+            String metaInf = themeUrlStr.substring(0, index) + "META-INF/MANIFEST.MF";
+            Properties properties = new Properties();
+            final URL url = new URL(metaInf);
+            InputStream inputStream = null;
+            String version = null;
+            try {
+              inputStream = url.openStream();
+              properties.load(inputStream);
+              version = properties.getProperty("Implementation-Version");
+            } catch (FileNotFoundException e) {
+              // may happen (e. g. in tests)
+              LOG.error("No Manifest-File found.");
+            } finally {
+              IOUtils.closeQuietly(inputStream);
+            }
+            if (version != null) {
+              theme.setVersion(version);
+            } else {
+              theme.setVersioned(false);
+              LOG.error("No Implementation-Version found in Manifest-File for theme: '" + theme.getName()
+                  + "'. Resetting the theme to unversioned. Please correct the Manifest-File.");
             }
-            addThemeResources(resources, themeUrl, theme);
           }
-        } else {
-          // the old way
-          addThemeResources(resources, themeUrl, parser.parse(themeUrl));
+          addThemeResources(resources, themeUrl, theme);
         }
       }
-    } catch (IOException e) {
-      String msg = "while loading ";
-      LOG.error(msg, e);
-      throw new ServletException(msg, e);
-    } catch (SAXException e) {
-      String msg = "while loading ";
-      LOG.error(msg, e);
-      throw new ServletException(msg, e);
+    } catch (Exception e) {
+      if (e instanceof ServletException) {
+        throw (ServletException) e;
+      } else {
+        throw new ServletException(e);
+      }
     }
   }
 
@@ -256,10 +240,6 @@ class ResourceLocator {
   private void addResources(ResourceManagerImpl resources, URL themeUrl, String prefix, int skipPrefix)
       throws IOException, ServletException {
     String fileName = themeUrl.toString();
-    if (fileName.endsWith(META_INF_TOBAGO_THEME_XML)) {
-      Deprecation.LOG.warn(
-          "The use of 'tobago-theme.xml' is deprecated, please use 'tobago-config.xml' to define a theme!");
-    }
     int index = fileName.indexOf("!");
     String protocol = themeUrl.getProtocol();
     if (index != -1) {
@@ -270,8 +250,7 @@ class ResourceLocator {
     }
 
     // JBoss 5.0.0 introduced vfszip protocol
-    if (!protocol.equals("vfszip")
-        && (fileName.endsWith(META_INF_TOBAGO_THEME_XML) || fileName.endsWith(META_INF_TOBAGO_CONFIG_XML))) {
+    if (!protocol.equals("vfszip") && fileName.endsWith(META_INF_TOBAGO_CONFIG_XML)) {
       try {
         URI uri = themeUrl.toURI();
         File tobagoThemeXml = new File(uri);
@@ -324,19 +303,21 @@ class ResourceLocator {
   private void resolveTheme(ResourceManagerImpl resources, File directoryFile,
       String resourcePath, String prefix, boolean inResourcePath) throws ServletException {
     File[] files = directoryFile.listFiles();
-    for (File file : files) {
-      if (file.isDirectory()) {
-        String currentResourcePath = resourcePath + File.separator + file.getName();
-        if (!inResourcePath && currentResourcePath.startsWith(prefix)) {
-          inResourcePath = true;
-        }
-        resolveTheme(resources, file, currentResourcePath, prefix, inResourcePath);
-      } else {
-        if (LOG.isInfoEnabled()) {
-          LOG.info(resourcePath + File.separator + file.getName());
-        }
-        if (inResourcePath) {
-          addResource(resources, resourcePath + File.separator + file.getName(), 0);
+    if (files != null) {
+      for (File file : files) {
+        if (file.isDirectory()) {
+          String currentResourcePath = resourcePath + File.separator + file.getName();
+          if (!inResourcePath && currentResourcePath.startsWith(prefix)) {
+            inResourcePath = true;
+          }
+          resolveTheme(resources, file, currentResourcePath, prefix, inResourcePath);
+        } else {
+          if (LOG.isInfoEnabled()) {
+            LOG.info(resourcePath + File.separator + file.getName());
+          }
+          if (inResourcePath) {
+            addResource(resources, resourcePath + File.separator + file.getName(), 0);
+          }
         }
       }
     }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeBuilder.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeBuilder.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ThemeBuilder.java Fri Aug 23 13:27:56 2013
@@ -45,7 +45,9 @@ class ThemeBuilder {
   public void resolveThemes() {
     Map<String, ThemeImpl> map = new HashMap<String, ThemeImpl>();
     for (ThemeImpl theme : availableThemes) {
-      LOG.debug("theme from tobago-theme.xml files: {} ", theme.getName());
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Theme from XML files: {} ", theme.getName());
+      }
       map.put(theme.getName(), theme);
     }
     for (ThemeImpl theme : availableThemes) {

Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigMergingUnitTest.java Fri Aug 23 13:27:56 2013
@@ -23,7 +23,9 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.xml.sax.SAXException;
 
+import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -31,7 +33,8 @@ import java.util.List;
 public class TobagoConfigMergingUnitTest {
 
   @Test
-  public void testPreventFrameAttacksCascadingDefault() throws IOException, SAXException {
+  public void testPreventFrameAttacksCascadingDefault()
+      throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
 
     final TobagoConfigImpl config = loadAndMerge(
         "tobago-config-0.xml",
@@ -41,24 +44,25 @@ public class TobagoConfigMergingUnitTest
   }
 
   @Test
-  public void testPreventFrameAttacks() throws IOException, SAXException {
+  public void testPreventFrameAttacks()
+      throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
 
-    final TobagoConfigImpl config = loadAndMerge(
-        "tobago-config-0.xml");
+    final TobagoConfigImpl config = loadAndMerge("tobago-config-0.xml");
 
     Assert.assertFalse(config.isPreventFrameAttacks());
   }
 
   @Test
-  public void testPreventFrameAttacksDefault() throws IOException, SAXException {
+  public void testPreventFrameAttacksDefault()
+      throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
 
-    final TobagoConfigImpl config = loadAndMerge(
-        "tobago-config-1.xml");
+    final TobagoConfigImpl config = loadAndMerge("tobago-config-1.xml");
 
     Assert.assertTrue(config.isPreventFrameAttacks());
   }
 
-  private TobagoConfigImpl loadAndMerge(String... names) throws IOException, SAXException {
+  private TobagoConfigImpl loadAndMerge(String... names)
+      throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
 
     final List<TobagoConfigFragment> list = new ArrayList<TobagoConfigFragment>();
 

Added: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParserUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParserUnitTest.java?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParserUnitTest.java (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParserUnitTest.java Fri Aug 23 13:27:56 2013
@@ -0,0 +1,184 @@
+/*
+ * 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.tobago.internal.config;
+
+import junit.framework.Assert;
+import org.apache.myfaces.tobago.context.ThemeImpl;
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class TobagoConfigParserUnitTest {
+
+  @Test
+  public void testParser() throws Exception {
+
+    final URL url = getClass().getClassLoader().getResource("tobago-config-2.0.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+
+    final TobagoConfigFragment fragment = parser.parse(url);
+
+    Assert.assertEquals("my-name", fragment.getName());
+
+    Assert.assertEquals(1, fragment.getAfter().size());
+    Assert.assertEquals("my-after", fragment.getAfter().get(0));
+
+    Assert.assertEquals(2, fragment.getBefore().size());
+    Assert.assertEquals("my-before-1", fragment.getBefore().get(0));
+    Assert.assertEquals("my-before-2", fragment.getBefore().get(1));
+
+    Assert.assertEquals(2, fragment.getResourceDirs().size());
+    Assert.assertEquals("my-resource-1", fragment.getResourceDirs().get(0));
+    Assert.assertEquals("my-resource-2", fragment.getResourceDirs().get(1));
+
+    Assert.assertEquals(false, fragment.getCreateSessionSecret().booleanValue());
+    Assert.assertEquals(false, fragment.getCheckSessionSecret().booleanValue());
+    Assert.assertEquals(false, fragment.getPreventFrameAttacks().booleanValue());
+
+    Assert.assertEquals(2, fragment.getContentSecurityPolicy().size());
+    Assert.assertEquals("default-src 'self'", fragment.getContentSecurityPolicy().get(0));
+    Assert.assertEquals("frame-src http://apache.org", fragment.getContentSecurityPolicy().get(1));
+    // todo: disabled
+    // todo: replace
+
+    Assert.assertEquals(2, fragment.getRenderersConfig().getRendererConfigs().size());
+    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-1", "my-markup-1"));
+    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-2", "my-markup-2-1"));
+    Assert.assertTrue(fragment.getRenderersConfig().isMarkupSupported("myRenderer-2", "my-markup-2-2"));
+
+    Assert.assertEquals(2, fragment.getThemeDefinitions().size());
+    final ThemeImpl theme1 = fragment.getThemeDefinitions().get(0);
+    Assert.assertEquals("my-theme-1", theme1.getName());
+    Assert.assertEquals("My Theme 1", theme1.getDisplayName());
+    Assert.assertEquals("/my/path-1", theme1.getResourcePath());
+    Assert.assertTrue(theme1.isVersioned());
+    Assert.assertTrue(theme1.getRenderersConfig().isMarkupSupported("themeRenderer", "theme-markup"));
+    Assert.assertTrue(theme1.getProductionResources().isProduction());
+    Assert.assertEquals("script.js", theme1.getProductionResources().getScriptList().get(0).getName());
+    Assert.assertEquals("style.css", theme1.getProductionResources().getStyleList().get(0).getName());
+
+    final ThemeImpl theme2 = fragment.getThemeDefinitions().get(1);
+    Assert.assertEquals("my-theme-2", theme2.getName());
+    Assert.assertEquals("my-theme-1", theme2.getFallbackName());
+    Assert.assertEquals("/my/path-2", theme2.getResourcePath());
+    Assert.assertFalse(theme2.isVersioned());
+    Assert.assertFalse(theme2.getResources().isProduction());
+    Assert.assertEquals(0, theme2.getResources().getScriptList().size());
+    Assert.assertEquals(0, theme2.getResources().getStyleList().size());
+    Assert.assertEquals(0, theme2.getProductionResources().getScriptList().size());
+    Assert.assertEquals(0, theme2.getProductionResources().getStyleList().size());
+  }
+
+  @Test
+  public void testParserFor10() throws Exception {
+    final URL url = getClass().getClassLoader().getResource("tobago-config-1.0.30.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+    final TobagoConfigFragment fragment = parser.parse(url);
+    Assert.assertEquals("speyside", fragment.getDefaultThemeName());
+  }
+
+  @Test
+  public void testFailParserFor10() throws Exception {
+    final URL url = getClass().getClassLoader().getResource("tobago-config-fail-1.0.30.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+    try {
+      parser.parse(url);
+      Assert.fail("No SAXParseException thrown!");
+    } catch (SAXException e) {
+      // okay
+    }
+  }
+
+  @Test
+  public void testParserFor15() throws Exception {
+    final URL url = getClass().getClassLoader().getResource("tobago-config-1.5.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+    final TobagoConfigFragment fragment = parser.parse(url);
+    Assert.assertEquals("speyside", fragment.getDefaultThemeName());
+  }
+
+  @Test
+  public void testFailParserFor15() throws Exception {
+    final URL url = getClass().getClassLoader().getResource("tobago-config-fail-1.5.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+    try {
+      parser.parse(url);
+      Assert.fail("No SAXParseException thrown!");
+    } catch (SAXException e) {
+      // okay
+    }
+  }
+
+  @Test
+  public void testFailParserFor20() throws Exception {
+    final URL url = getClass().getClassLoader().getResource("tobago-config-fail-2.0.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+    try {
+      parser.parse(url);
+      Assert.fail("No SAXParseException thrown!");
+    } catch (SAXException e) {
+      // okay
+    }
+  }
+
+  @Test
+  public void testFailParserForUnknownVersion() throws Exception {
+    final URL url = getClass().getClassLoader().getResource("tobago-config-fail-unknown-version.xml");
+    final TobagoConfigParser parser = new TobagoConfigParser();
+    try {
+      parser.parse(url);
+      Assert.fail("No SAXParseException thrown!");
+    } catch (SAXException e) {
+      // okay
+    }
+  }
+
+  @Test
+  public void testUniqueness() throws IllegalAccessException {
+    final Field[] all = TobagoConfigParser.class.getFields();
+    final List<Field> fields = new ArrayList<Field>();
+    for (Field field : all) {
+      if (field.getType().equals(Integer.TYPE)) {
+        fields.add(field);
+      }
+    }
+    // uniqueness
+    TobagoConfigParser dummy = new TobagoConfigParser();
+    Set<Integer> hashCodes = new HashSet<Integer>();
+    for (Field field : fields) {
+      hashCodes.add(field.getInt(dummy));
+    }
+    Assert.assertEquals("All used hash codes must be unique", fields.size(), hashCodes.size());
+
+    // check hash code values
+    for (Field field : fields) {
+      int hash = field.getInt(dummy);
+      String name = field.getName().toLowerCase().replace('_', '-');
+      Assert.assertEquals("Are the constants correct?", name.hashCode(), hash);
+    }
+  }
+
+}

Copied: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java (from r1515387, myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserTest.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java?p2=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java&p1=myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserTest.java&r1=1515387&r2=1516844&rev=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserTest.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java Fri Aug 23 13:27:56 2013
@@ -21,30 +21,32 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.myfaces.tobago.context.ThemeImpl;
 import org.apache.myfaces.tobago.context.ThemeResources;
-import org.apache.myfaces.tobago.internal.config.ThemeParser;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigImpl;
+import org.apache.myfaces.tobago.internal.config.TobagoConfigParser;
 import org.junit.Assert;
 import org.junit.Test;
 import org.xml.sax.SAXException;
 
+import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Enumeration;
 
-public class ThemeParserTest {
+public class ThemeParserUnitTest {
 
   @Test
-  public void test() throws IOException, SAXException {
+  public void test() throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
     TobagoConfigImpl config = new TobagoConfigImpl();
     ThemeBuilder themeBuilder = new ThemeBuilder(config);
     ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     Enumeration<URL> urls = classLoader.getResources("theme-config.xml");
 
-    ThemeParser parser = new ThemeParser();
+    TobagoConfigParser parser = new TobagoConfigParser();
     ThemeImpl theme = null;
     if  (urls.hasMoreElements()) {
       URL themeUrl = urls.nextElement();
-      theme = parser.parse(themeUrl);
+      theme = parser.parse(themeUrl).getThemeDefinitions().get(0);
       Assert.assertEquals("test", theme.getName());
       Assert.assertNotNull(theme.getResources());
       Assert.assertNotNull(theme.getProductionResources());
@@ -66,7 +68,7 @@ public class ThemeParserTest {
     ThemeImpl theme2 = null;
     if (urls.hasMoreElements()) {
       URL themeUrl = urls.nextElement();
-      theme2 = parser.parse(themeUrl);
+      theme2 = parser.parse(themeUrl).getThemeDefinitions().get(0);
       Assert.assertEquals("test2", theme2.getName());
       Assert.assertNotNull(theme2.getResources());
       Assert.assertEquals(1, theme2.getResources().getScriptList().size());
@@ -81,7 +83,7 @@ public class ThemeParserTest {
     ThemeImpl theme3 = null;
     if (urls.hasMoreElements()) {
       URL themeUrl = urls.nextElement();
-      theme3 = parser.parse(themeUrl);
+      theme3 = parser.parse(themeUrl).getThemeDefinitions().get(0);
       Assert.assertEquals("test3", theme3.getName());
       Assert.assertEquals(0, theme3.getResources().getScriptList().size());
       Assert.assertEquals(0, theme3.getResources().getStyleList().size());
@@ -95,7 +97,7 @@ public class ThemeParserTest {
     ThemeImpl theme4 = null;
     if (urls.hasMoreElements()) {
       URL themeUrl = urls.nextElement();
-      theme4 = parser.parse(themeUrl);
+      theme4 = parser.parse(themeUrl).getThemeDefinitions().get(0);
       Assert.assertEquals("test4", theme4.getName());
       Assert.assertEquals(0, theme4.getResources().getScriptList().size());
       Assert.assertEquals(0, theme4.getResources().getStyleList().size());

Modified: myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockRenderersConfig.java Fri Aug 23 13:27:56 2013
@@ -22,7 +22,7 @@ package org.apache.myfaces.tobago.intern
 import org.apache.myfaces.tobago.internal.config.RendererConfig;
 import org.apache.myfaces.tobago.internal.config.RenderersConfig;
 
-import java.util.Collection;
+import java.util.List;
 
 public class MockRenderersConfig implements RenderersConfig {
 
@@ -33,7 +33,7 @@ public class MockRenderersConfig impleme
     return markup.length() < 10;
   }
 
-  public Collection<RendererConfig> getRendererConfigs() {
+  public List<RendererConfig> getRendererConfigs() {
     return null;
   }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config.xml Fri Aug 23 13:27:56 2013
@@ -17,17 +17,25 @@
  * limitations under the License.
 -->
 
-<tobago-theme>
-  <name>test</name>
-  <display-name>Test</display-name>
-  <resource-path>Test</resource-path>
-  <resources production="true">
-    <script name="script/tobago.min.js"/>
-    <style name="tobago.css"/>
-  </resources>
-  <resources production="false">
-    <script name="script/tobago.js"/>
-    <script name="script/tobago-logging.js"/>
-    <style name="tobago.css"/>
-  </resources>
-</tobago-theme>
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-2.0.xsd"
+    version="2.0">
+  <theme-definitions>
+    <theme-definition>
+      <name>test</name>
+      <display-name>Test</display-name>
+      <resource-path>Test</resource-path>
+      <resources production="true">
+        <script name="script/tobago.min.js"/>
+        <style name="tobago.css"/>
+      </resources>
+      <resources production="false">
+        <script name="script/tobago.js"/>
+        <script name="script/tobago-logging.js"/>
+        <style name="tobago.css"/>
+      </resources>
+    </theme-definition>
+  </theme-definitions>
+</tobago-config>

Modified: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config2.xml Fri Aug 23 13:27:56 2013
@@ -17,13 +17,21 @@
  * limitations under the License.
 -->
 
-<tobago-theme>
-  <name>test2</name>
-  <display-name>Test2</display-name>
-  <resource-path>Test2</resource-path>
-  <fallback>test</fallback>
-  <resources production="false">
-    <script name="script/test.js"/>
-    <style name="tobago.css"/>
-  </resources>
-</tobago-theme>
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-2.0.xsd"
+    version="2.0">
+  <theme-definitions>
+    <theme-definition>
+      <name>test2</name>
+      <display-name>Test2</display-name>
+      <resource-path>Test2</resource-path>
+      <fallback>test</fallback>
+      <resources production="false">
+        <script name="script/test.js"/>
+        <style name="tobago.css"/>
+      </resources>
+    </theme-definition>
+  </theme-definitions>
+</tobago-config>

Modified: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config3.xml Fri Aug 23 13:27:56 2013
@@ -17,9 +17,17 @@
  * limitations under the License.
 -->
 
-<tobago-theme>
-  <name>test3</name>
-  <display-name>Test3</display-name>
-  <resource-path>Test3</resource-path>
-  <fallback>test2</fallback>
-</tobago-theme>
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-2.0.xsd"
+    version="2.0">
+  <theme-definitions>
+    <theme-definition>
+      <name>test3</name>
+      <display-name>Test3</display-name>
+      <resource-path>Test3</resource-path>
+      <fallback>test2</fallback>
+    </theme-definition>
+  </theme-definitions>
+</tobago-config>

Modified: myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml?rev=1516844&r1=1516843&r2=1516844&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml (original)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/theme-config4.xml Fri Aug 23 13:27:56 2013
@@ -17,9 +17,17 @@
  * limitations under the License.
 -->
 
-<tobago-theme>
-  <name>test4</name>
-  <display-name>Test4</display-name>
-  <resource-path>Test4</resource-path>
-  <fallback>test3</fallback>
-</tobago-theme>
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-2.0.xsd"
+    version="2.0">
+  <theme-definitions>
+    <theme-definition>
+      <name>test4</name>
+      <display-name>Test4</display-name>
+      <resource-path>Test4</resource-path>
+      <fallback>test3</fallback>
+    </theme-definition>
+  </theme-definitions>
+</tobago-config>

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.0.30.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.0.30.xml?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.0.30.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.0.30.xml Fri Aug 23 13:27:56 2013
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<!DOCTYPE tobago-config PUBLIC
+    "-//The Apache Software Foundation//DTD Tobago Config 1.0.30//EN"
+    "http://myfaces.apache.org/tobago/tobago-config-1.0.30.dtd">
+
+<tobago-config>
+  <theme-config>
+    <default-theme>speyside</default-theme>
+  </theme-config>
+  <fix-resource-order>true</fix-resource-order>
+  <fix-layout-transparency>true</fix-layout-transparency>
+</tobago-config>

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.5.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.5.xml?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.5.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-1.5.xml Fri Aug 23 13:27:56 2013
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-1.5.xsd"
+    version="1.5">
+
+  <name>my-name</name>
+
+  <ordering>
+    <after>
+      <name>my-after</name>
+    </after>
+    <before>
+      <name>my-before-1</name>
+      <name>my-before-2</name>
+    </before>
+  </ordering>
+
+  <theme-config>
+    <default-theme>speyside</default-theme>
+    <supported-theme>scarborough</supported-theme>
+    <supported-theme>standard</supported-theme>
+  </theme-config>
+
+</tobago-config>

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-2.0.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-2.0.xml?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-2.0.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-2.0.xml Fri Aug 23 13:27:56 2013
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-2.0.xsd"
+    version="2.0">
+
+  <name>my-name</name>
+
+  <ordering>
+    <after>
+      <name>my-after</name>
+    </after>
+    <before>
+      <name>my-before-1</name>
+      <name>my-before-2</name>
+    </before>
+  </ordering>
+
+  <theme-config>
+    <default-theme>speyside</default-theme>
+    <supported-theme>scarborough</supported-theme>
+    <supported-theme>standard</supported-theme>
+  </theme-config>
+
+  <resource-dir>my-resource-1</resource-dir>
+  <resource-dir>my-resource-2</resource-dir>
+
+  <create-session-secret>false</create-session-secret>
+  <check-session-secret>false</check-session-secret>
+  <prevent-frame-attacks>false</prevent-frame-attacks>
+
+  <content-security-policy disabled="true" replace="true">
+    <directive>default-src 'self'</directive>
+    <directive>frame-src http://apache.org</directive>
+  </content-security-policy>
+
+  <renderers>
+    <renderer>
+      <name>MyRenderer-1</name>
+      <supported-markup>
+        <markup>my-markup-1</markup>
+      </supported-markup>
+    </renderer>
+    <renderer>
+      <name>MyRenderer-2</name>
+      <supported-markup>
+        <markup>my-markup-2-1</markup>
+        <markup>my-markup-2-2</markup>
+      </supported-markup>
+    </renderer>
+  </renderers>
+
+  <theme-definitions>
+    <theme-definition>
+      <name>my-theme-1</name>
+      <display-name>My Theme 1</display-name>
+      <resource-path>/my/path-1</resource-path>
+      <versioned>true</versioned>
+      <renderers>
+        <renderer>
+          <name>ThemeRenderer</name>
+          <supported-markup>
+            <markup>theme-markup</markup>
+          </supported-markup>
+        </renderer>
+      </renderers>
+      <resources production="true">
+        <script name="script.js"/>
+        <style name="style.css"/>
+      </resources>
+    </theme-definition>
+
+    <theme-definition>
+      <name>my-theme-2</name>
+      <resource-path>/my/path-2</resource-path>
+      <fallback>my-theme-1</fallback>
+      <resources production="false"/>
+    </theme-definition>
+
+  </theme-definitions>
+
+</tobago-config>

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.0.30.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.0.30.xml?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.0.30.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.0.30.xml Fri Aug 23 13:27:56 2013
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<!DOCTYPE tobago-config PUBLIC
+    "-//The Apache Software Foundation//DTD Tobago Config 1.0.30//EN"
+    "http://myfaces.apache.org/tobago/tobago-config-1.0.30.dtd">
+
+<tobago-config>
+  <theme-config>
+  </theme-config>
+</tobago-config>

Added: myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.5.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.5.xml?rev=1516844&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.5.xml (added)
+++ myfaces/tobago/trunk/tobago-core/src/test/resources/tobago-config-fail-1.5.xml Fri Aug 23 13:27:56 2013
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<tobago-config
+    xmlns="http://myfaces.apache.org/tobago/tobago-config"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-1.5.xsd"
+    version="1.5">
+
+  <content-security-policy>
+    <directive>default-src 'self'</directive>
+  </content-security-policy>
+
+</tobago-config>



Mime
View raw message