You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2015/11/25 18:05:51 UTC

svn commit: r1716490 - in /myfaces/tobago/branches/tobago-3.0.x/tobago-core/src: main/java/org/apache/myfaces/tobago/context/ main/java/org/apache/myfaces/tobago/internal/config/ main/java/org/apache/myfaces/tobago/internal/context/ main/resources/org/...

Author: lofwyr
Date: Wed Nov 25 17:05:51 2015
New Revision: 1716490

URL: http://svn.apache.org/viewvc?rev=1716490&view=rev
Log:
TOBAGO-1513: Possibility to exclude resources from parent theme.

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-3.0.xsd
      - copied, changed from r1716433, myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-2.0.xsd
Removed:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ThemeBuilder.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/TobagoConfigTestUtils.java
Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeResources.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceManagerFactory.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeImpl.java Wed Nov 25 17:05:51 2015
@@ -55,9 +55,8 @@ public class ThemeImpl implements Theme,
   private boolean unmodifiable = false;
 
   public ThemeImpl() {
-    resources = new ThemeResources();
-    productionResources = new ThemeResources();
-    productionResources.setProduction(true);
+    resources = new ThemeResources(false);
+    productionResources = new ThemeResources(true);
   }
 
   private void checkLocked() throws IllegalStateException {
@@ -175,20 +174,6 @@ public class ThemeImpl implements Theme,
     }
   }
 
-  public String toString() {
-    final StringBuilder builder = new StringBuilder();
-    builder.append("Theme: ");
-    builder.append(name);
-    if (renderersConfig != null) {
-      builder.append("\n");
-      for (final RendererConfig config : renderersConfig.getRendererConfigs()) {
-        builder.append(config);
-        builder.append("\n");
-      }
-    }
-    return builder.toString();
-  }
-
   public void setRenderersConfig(final RenderersConfigImpl renderersConfig) {
     checkLocked();
     this.renderersConfig = renderersConfig;
@@ -212,6 +197,7 @@ public class ThemeImpl implements Theme,
 
   public void addResources(final ThemeResources themeResources) {
     checkLocked();
+
     if (themeResources.isProduction()) {
       productionResources.merge(themeResources);
     } else {
@@ -244,15 +230,17 @@ public class ThemeImpl implements Theme,
   public String[] getScriptResources(final boolean production) {
     if (production) {
       return productionScripts;
+    } else {
+      return scripts;
     }
-    return scripts;
   }
 
   public String[] getStyleResources(final boolean production) {
     if (production) {
       return productionStyles;
+    } else {
+      return styles;
     }
-    return styles;
   }
 
   public boolean isVersioned() {
@@ -273,4 +261,46 @@ public class ThemeImpl implements Theme,
     checkLocked();
     this.version = version;
   }
+
+  public String toString() {
+    final StringBuilder builder = new StringBuilder();
+    builder.append("Theme:  name='");
+    builder.append(name);
+    builder.append("' fallback=");
+    if (fallback != null) {
+      builder.append("'");
+      builder.append(fallback.getName());
+      builder.append("'");
+    } else {
+      builder.append("null");
+    }
+    builder.append(", \nproductionScripts=[");
+    for (String s : productionScripts != null ? productionScripts : new String[0]) {
+      builder.append("\n");
+      builder.append(s);
+    }
+    builder.append("], \nscripts=[");
+    for (String s : scripts != null ? scripts : new String[0]) {
+      builder.append("\n");
+      builder.append(s);
+    }
+    builder.append("], \nproductionStyles=[");
+    for (String s : productionStyles != null ? productionStyles : new String[0]) {
+      builder.append("\n");
+      builder.append(s);
+    }
+    builder.append("], \nstyles=[");
+    for (String s : styles != null ? styles : new String[0]) {
+      builder.append("\n");
+      builder.append(s);
+    }
+    if (renderersConfig != null) {
+      builder.append("\n");
+      for (final RendererConfig config : renderersConfig.getRendererConfigs()) {
+        builder.append(config);
+        builder.append("\n");
+      }
+    }
+    return builder.toString();
+  }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeResources.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeResources.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeResources.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ThemeResources.java Wed Nov 25 17:05:51 2015
@@ -30,23 +30,33 @@ import java.util.List;
  */
 public final class ThemeResources implements Serializable {
 
-  private boolean production;
-  private List<ThemeScript> scriptList = new ArrayList<ThemeScript>();
-  private List<ThemeStyle> styleList = new ArrayList<ThemeStyle>();
+  private final boolean production;
+  private final List<ThemeScript> scriptList = new ArrayList<ThemeScript>();
+  private final List<ThemeScript> scriptExcludes = new ArrayList<ThemeScript>();
+  private final List<ThemeStyle> styleList = new ArrayList<ThemeStyle>();
+  private final List<ThemeStyle> styleExcludes = new ArrayList<ThemeStyle>();
+
+  public ThemeResources(boolean production) {
+    this.production = production;
+  }
 
   public void merge(final ThemeResources toAddResources) {
     if (this == toAddResources) {
       return;
     }
-    for (int i = toAddResources.getScriptList().size()-1; i >= 0; i--) {
-      final ThemeScript script = toAddResources.getScriptList().get(i);
-      this.getScriptList().remove(script);
-      this.getScriptList().add(0, script);
+    for (int i = toAddResources.scriptList.size() - 1; i >= 0; i--) {
+      final ThemeScript script = toAddResources.scriptList.get(i);
+      scriptList.remove(script);
+      if (!scriptExcludes.contains(script)) {
+        scriptList.add(0, script);
+      }
     }
-    for (int i = toAddResources.getStyleList().size()-1; i >= 0; i--) {
-      final ThemeStyle style = toAddResources.getStyleList().get(i);
-      this.getStyleList().remove(style);
-      this.getStyleList().add(0, style);
+    for (int i = toAddResources.styleList.size() - 1; i >= 0; i--) {
+      final ThemeStyle style = toAddResources.styleList.get(i);
+      styleList.remove(style);
+      if (!styleExcludes.contains(style)) {
+        styleList.add(0, style);
+      }
     }
   }
 
@@ -54,16 +64,12 @@ public final class ThemeResources implem
     return production;
   }
 
-  public void setProduction(final boolean production) {
-    this.production = production;
-  }
-
-  public boolean addScript(final ThemeScript script) {
-    return scriptList.add(script);
+  public boolean addScript(final ThemeScript script, boolean exclude) {
+    return exclude ? scriptExcludes.add(script) : scriptList.add(script);
   }
 
-  public boolean addStyle(final ThemeStyle style) {
-    return styleList.add(style);
+  public boolean addStyle(final ThemeStyle style, boolean exclude) {
+    return exclude ? styleExcludes.add(style) : styleList.add(style);
   }
 
   public List<ThemeScript> getScriptList() {

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigEntityResolver.java Wed Nov 25 17:05:51 2015
@@ -39,6 +39,7 @@ public class TobagoConfigEntityResolver
   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";
   protected static final String TOBAGO_CONFIG_XSD_2_0_6 = "/org/apache/myfaces/tobago/config/tobago-config-2.0.6.xsd";
+  protected static final String TOBAGO_CONFIG_XSD_3_0 = "/org/apache/myfaces/tobago/config/tobago-config-3.0.xsd";
 
   private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigEntityResolver.class);
 

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java Wed Nov 25 17:05:51 2015
@@ -56,7 +56,7 @@ public class TobagoConfigImpl extends To
   private Theme defaultTheme;
   private String defaultThemeName;
   private List<String> resourceDirs;
-  private Map<String, Theme> availableThemes;
+  private Map<String, ThemeImpl> availableThemes;
   private RenderersConfig renderersConfig;
   private ProjectStage projectStage;
   private boolean createSessionSecret;
@@ -74,6 +74,7 @@ public class TobagoConfigImpl extends To
   protected TobagoConfigImpl() {
     supportedThemeNames = new ArrayList<String>();
     supportedThemes = new ArrayList<Theme>();
+    availableThemes = new HashMap<String, ThemeImpl>();
     resourceDirs = new ArrayList<String>();
     createSessionSecret = true;
     checkSessionSecret = true;
@@ -119,6 +120,11 @@ public class TobagoConfigImpl extends To
   // TODO one init method
   protected void resolveThemes() {
     checkLocked();
+
+    for (final Theme theme : availableThemes.values()) {
+      addResourceDir(theme.getResourcePath());
+    }
+
     if (defaultThemeName != null) {
       defaultTheme = availableThemes.get(defaultThemeName);
       checkThemeIsAvailable(defaultThemeName, defaultTheme);
@@ -128,7 +134,7 @@ public class TobagoConfigImpl extends To
       }
     } else {
       int deep = 0;
-      for (final Map.Entry<String, Theme> entry : availableThemes.entrySet()) {
+      for (final Map.Entry<String, ThemeImpl> entry : availableThemes.entrySet()) {
         final Theme theme = entry.getValue();
         if (theme.getFallbackList().size() > deep) {
           defaultTheme = theme;
@@ -214,12 +220,13 @@ public class TobagoConfigImpl extends To
     return defaultTheme;
   }
 
-  protected void setAvailableThemes(final Map<String, Theme> availableThemes) {
+  protected void addAvailableTheme(ThemeImpl availableTheme) {
     checkLocked();
-    this.availableThemes = availableThemes;
-    for (final Theme theme : this.availableThemes.values()) {
-      addResourceDir(theme.getResourcePath());
-    }
+    availableThemes.put(availableTheme.getName(), availableTheme);
+  }
+
+  public Map<String, ThemeImpl> getAvailableThemes() {
+    return availableThemes;
   }
 
   protected RenderersConfig getRenderersConfig() {
@@ -388,7 +395,7 @@ public class TobagoConfigImpl extends To
       builder.append(", ");
     }
     builder.append("], \ndefaultTheme=");
-    builder.append(defaultTheme.getName());
+    builder.append(defaultTheme != null ? defaultTheme.getName() : null);
     builder.append(", \nresourceDirs=");
     builder.append(resourceDirs);
     builder.append(", \navailableThemes=");

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigParser.java Wed Nov 25 17:05:51 2015
@@ -75,6 +75,7 @@ public class TobagoConfigParser extends
   private static final int FALLBACK = 761243362;
   private static final int VERSIONED = -1407102089;
   private static final int RESOURCES = -1983070683;
+  private static final int EXCLUDES = 1994055129;
   private static final int SANITIZER = 1807639849;
   private static final int SANITIZER_CLASS = -974266412;
   private static final int SCRIPT = -907685685;
@@ -91,6 +92,7 @@ public class TobagoConfigParser extends
   private RendererConfig currentRenderer;
   private ThemeImpl currentTheme;
   private Boolean production;
+  private boolean exclude;
   private StringBuilder buffer;
   private Properties properties;
   private String entryKey;
@@ -192,13 +194,17 @@ public class TobagoConfigParser extends
         production = Boolean.parseBoolean(attributes.getValue("production"));
         break;
 
+      case EXCLUDES:
+        exclude = true;
+        break;
+
       case SCRIPT:
         final ThemeScript script = new ThemeScript();
         script.setName(attributes.getValue("name"));
         if (production) {
-          currentTheme.getProductionResources().addScript(script);
+          currentTheme.getProductionResources().addScript(script, exclude);
         } else {
-          currentTheme.getResources().addScript(script);
+          currentTheme.getResources().addScript(script, exclude);
         }
         break;
 
@@ -206,9 +212,9 @@ public class TobagoConfigParser extends
         final ThemeStyle style = new ThemeStyle();
         style.setName(attributes.getValue("name"));
         if (production) {
-          currentTheme.getProductionResources().addStyle(style);
+          currentTheme.getProductionResources().addStyle(style, exclude);
         } else {
-          currentTheme.getResources().addStyle(style);
+          currentTheme.getResources().addStyle(style, exclude);
         }
         break;
 
@@ -250,7 +256,7 @@ public class TobagoConfigParser extends
         break;
 
       default:
-        LOG.warn("Ignoring unknown start tag <" + qName + ">");
+        LOG.warn("Ignoring unknown start tag <" + qName + "> with hashCode=" + qName.hashCode());
     }
   }
 
@@ -362,6 +368,10 @@ public class TobagoConfigParser extends
         production = null;
         break;
 
+      case EXCLUDES:
+        exclude = false;
+        break;
+
       case SANITIZER_CLASS:
         tobagoConfig.setSanitizerClass(text);
         break;
@@ -437,7 +447,9 @@ public class TobagoConfigParser extends
 
     final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
     final Schema schema;
-    if ("2.0.6".equals(version.getVersion())) {
+    if ("3.0".equals(version.getVersion())) {
+      schema = schemaFactory.newSchema(getClass().getResource(TOBAGO_CONFIG_XSD_3_0));
+    } else if ("2.0.6".equals(version.getVersion())) {
       schema = schemaFactory.newSchema(getClass().getResource(TOBAGO_CONFIG_XSD_2_0_6));
     } else if ("2.0".equals(version.getVersion())) {
       schema = schemaFactory.newSchema(getClass().getResource(TOBAGO_CONFIG_XSD_2_0));

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigSorter.java Wed Nov 25 17:05:51 2015
@@ -19,6 +19,7 @@
 
 package org.apache.myfaces.tobago.internal.config;
 
+import org.apache.myfaces.tobago.context.ThemeImpl;
 import org.apache.myfaces.tobago.sanitizer.IgnoringSanitizer;
 import org.apache.myfaces.tobago.sanitizer.JsoupSanitizer;
 import org.apache.myfaces.tobago.sanitizer.Sanitizer;
@@ -134,12 +135,10 @@ public class TobagoConfigSorter implemen
       }
 
       // theme definition
-      // todo
-/*
-      for (Theme theme : fragment.getThemeDefinitions()) {
-        result.addThemeDefinition(theme);
+      result.toString();
+      for (ThemeImpl theme : fragment.getThemeDefinitions()) {
+        result.addAvailableTheme(theme);
       }
-*/
 
       // url
       // todo???
@@ -151,6 +150,8 @@ public class TobagoConfigSorter implemen
 
     }
 
+    resolveThemes(result, result.getAvailableThemes());
+
     if (sanitizerClass != null) {
       try {
         final Class<? extends Sanitizer> aClass = Class.forName(sanitizerClass).asSubclass(Sanitizer.class);
@@ -288,6 +289,26 @@ public class TobagoConfigSorter implemen
     return null;
   }
 
+  private void resolveThemes(TobagoConfigImpl tobagoConfig, Map<String, ThemeImpl> map) {
+    for (final ThemeImpl theme : map.values()) {
+      final String fallbackName = theme.getFallbackName();
+      final ThemeImpl fallback = map.get(fallbackName);
+      theme.setFallback(fallback);
+    }
+    for (final ThemeImpl theme : map.values()) {
+      theme.resolveFallbacks();
+    }
+    for (final ThemeImpl theme : map.values()) {
+      theme.resolveRendererConfig(tobagoConfig.getRenderersConfig());
+    }
+    for (final ThemeImpl theme : map.values()) {
+      theme.resolveResources();
+    }
+    for (final ThemeImpl theme : map.values()) {
+      theme.init();
+    }
+  }
+
   protected List<Pair> getPairs() {
     return pairs;
   }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java Wed Nov 25 17:05:51 2015
@@ -20,7 +20,6 @@
 package org.apache.myfaces.tobago.internal.context;
 
 import org.apache.myfaces.tobago.context.ThemeImpl;
-import org.apache.myfaces.tobago.internal.config.ThemeBuilder;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigFragment;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigParser;
 import org.apache.myfaces.tobago.internal.util.IoUtils;
@@ -69,13 +68,10 @@ class ResourceLocator {
 
   private ServletContext servletContext;
   private ResourceManagerImpl resourceManager;
-  private ThemeBuilder themeBuilder;
 
-  public ResourceLocator(
-      final ServletContext servletContext, final ResourceManagerImpl resourceManager, final ThemeBuilder themeBuilder) {
+  public ResourceLocator(final ServletContext servletContext, final ResourceManagerImpl resourceManager) {
     this.servletContext = servletContext;
     this.resourceManager = resourceManager;
-    this.themeBuilder = themeBuilder;
   }
 
   public void locate()
@@ -154,7 +150,6 @@ class ResourceLocator {
         final TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(tobagoConfigUrl);
         for (final ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
           detectThemeVersion(tobagoConfigUrl, theme);
-          themeBuilder.addTheme(theme);
           final String prefix = ensureSlash(theme.getResourcePath());
           final String protocol = tobagoConfigUrl.getProtocol();
           // tomcat uses jar // weblogic uses zip // IBM WebSphere uses wsjar

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceManagerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceManagerFactory.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceManagerFactory.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceManagerFactory.java Wed Nov 25 17:05:51 2015
@@ -20,7 +20,6 @@
 package org.apache.myfaces.tobago.internal.context;
 
 import org.apache.myfaces.tobago.context.ResourceManager;
-import org.apache.myfaces.tobago.internal.config.ThemeBuilder;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigImpl;
 
 import javax.faces.context.FacesContext;
@@ -54,10 +53,8 @@ public final class ResourceManagerFactor
     assert !initialized;
     final ResourceManagerImpl resourceManager = new ResourceManagerImpl(tobagoConfig);
 
-    final ThemeBuilder themeBuilder = new ThemeBuilder(tobagoConfig);
-    final ResourceLocator resourceLocator = new ResourceLocator(servletContext, resourceManager, themeBuilder);
+    final ResourceLocator resourceLocator = new ResourceLocator(servletContext, resourceManager);
     resourceLocator.locate();
-    themeBuilder.resolveThemes();
 
     servletContext.setAttribute(RESOURCE_MANAGER, resourceManager);
 

Copied: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-3.0.xsd (from r1716433, myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-2.0.xsd)
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-3.0.xsd?p2=myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-3.0.xsd&p1=myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-2.0.xsd&r1=1716433&r2=1716490&rev=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-2.0.xsd (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config-3.0.xsd Wed Nov 25 17:05:51 2015
@@ -6,7 +6,7 @@
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified"
-    version="2.0">
+    version="3.0">
 
   <xs:annotation>
     <xs:documentation>
@@ -36,19 +36,19 @@
       ************************************************************************************
       WARNING
       THIS IS A PRE-RELEASE VERSION OF THIS FILE, PLEASE CHECK IF THERE IS AN UPDATE ON
-      http://myfaces.apache.org/tobago/tobago-config-2.0.xsd
+      http://myfaces.apache.org/tobago/tobago-config-3.0.xsd
       ************************************************************************************
       ************************************************************************************
 
-      This is the XML schema for the Tobago configuration files version 2.0.
+      This is the XML schema for the Tobago configuration files version 3.0.
 
       Use the following definition:
 
       <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">
+          xsi:schemaLocation="http://myfaces.apache.org/tobago/tobago-config http://myfaces.apache.org/tobago/tobago-config-3.0.xsd"
+          version="3.0">
         ...
       </tobago-config>
       ]]>
@@ -81,7 +81,7 @@
 
   <xs:simpleType name="tobago-config-version-type">
     <xs:restriction base="xs:token">
-      <xs:enumeration value="2.0"/>
+      <xs:enumeration value="3.0"/>
     </xs:restriction>
   </xs:simpleType>
 
@@ -166,12 +166,20 @@
 
   <xs:complexType name="resources-type">
     <xs:sequence>
+      <xs:element name="excludes" type="tobago:excludes-type" minOccurs="0" maxOccurs="1"/>
       <xs:element name="script" type="tobago:script-type" minOccurs="0" maxOccurs="unbounded"/>
       <xs:element name="style" type="tobago:style-type" minOccurs="0" maxOccurs="unbounded"/>
     </xs:sequence>
     <xs:attribute name="production" type="xs:boolean" use="required"/>
   </xs:complexType>
 
+  <xs:complexType name="excludes-type">
+    <xs:sequence>
+      <xs:element name="script" type="tobago:script-type" minOccurs="0" maxOccurs="unbounded"/>
+      <xs:element name="style" type="tobago:style-type" minOccurs="0" maxOccurs="unbounded"/>
+    </xs:sequence>
+  </xs:complexType>
+
   <xs:complexType name="script-type">
     <xs:attribute name="name" type="xs:string" use="required"/>
   </xs:complexType>

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/config/AbstractTobagoTestBase.java Wed Nov 25 17:05:51 2015
@@ -33,6 +33,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.Theme;
+import org.apache.myfaces.tobago.context.ThemeImpl;
 import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
 import org.apache.myfaces.tobago.internal.mock.faces.MockTheme;
 import org.apache.myfaces.tobago.internal.util.MimeTypeUtils;
@@ -41,11 +42,8 @@ import org.junit.Before;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Locale;
-import java.util.Map;
 
 /**
  * <p>Abstract JUnit test case base class, which sets up the JavaServer Faces
@@ -72,12 +70,10 @@ public abstract class AbstractTobagoTest
     // Tobago specific extensions
 
     final TobagoConfigImpl tobagoConfig = TobagoConfigMergingUnitTest.loadAndMerge("tobago-config-for-unit-tests.xml");
-    final Theme theme = new MockTheme("default", "Default Mock Theme", Collections.<Theme>emptyList());
-    final Theme one = new MockTheme("one", "Mock Theme One", Arrays.asList(theme));
-    final Map<String, Theme> availableThemes = new HashMap<String, Theme>();
-    availableThemes.put(theme.getName(), theme);
-    availableThemes.put(one.getName(), one);
-    tobagoConfig.setAvailableThemes(availableThemes);
+    final ThemeImpl theme = new MockTheme("default", "Default Mock Theme", Collections.<Theme>emptyList());
+    final ThemeImpl one = new MockTheme("one", "Mock Theme One", Collections.singletonList((Theme) theme));
+    tobagoConfig.addAvailableTheme(theme);
+    tobagoConfig.addAvailableTheme(one);
     tobagoConfig.resolveThemes();
     tobagoConfig.initProjectState(servletContext);
     tobagoConfig.initDefaultValidatorInfo();

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/context/ThemeParserUnitTest.java Wed Nov 25 17:05:51 2015
@@ -21,9 +21,7 @@ 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.ThemeBuilder;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigParser;
-import org.apache.myfaces.tobago.internal.config.TobagoConfigTestUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.xml.sax.SAXException;
@@ -38,13 +36,12 @@ public class ThemeParserUnitTest {
 
   @Test
   public void test() throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
-    final ThemeBuilder themeBuilder = TobagoConfigTestUtils.createThemeBuilder();
     final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     Enumeration<URL> urls = classLoader.getResources("theme-config.xml");
 
     final TobagoConfigParser parser = new TobagoConfigParser();
     ThemeImpl theme = null;
-    if  (urls.hasMoreElements()) {
+    if (urls.hasMoreElements()) {
       final URL themeUrl = urls.nextElement();
       theme = parser.parse(themeUrl).getThemeDefinitions().get(0);
       Assert.assertEquals("test", theme.getName());
@@ -58,7 +55,6 @@ public class ThemeParserUnitTest {
 //      Assert.assertEquals("script/tobago-console.js", resources.getScriptList().get(1).getName());
 
       Assert.assertEquals(1, productionResources.getScriptList().size());
-      themeBuilder.addTheme(theme);
     } else {
       Assert.fail();
     }
@@ -73,7 +69,6 @@ public class ThemeParserUnitTest {
       Assert.assertNotNull(theme2.getResources());
       Assert.assertEquals(1, theme2.getResources().getScriptList().size());
       Assert.assertEquals(1, theme2.getResources().getStyleList().size());
-      themeBuilder.addTheme(theme2);
     } else {
       Assert.fail();
     }
@@ -87,7 +82,6 @@ public class ThemeParserUnitTest {
       Assert.assertEquals("test3", theme3.getName());
       Assert.assertEquals(0, theme3.getResources().getScriptList().size());
       Assert.assertEquals(0, theme3.getResources().getStyleList().size());
-      themeBuilder.addTheme(theme3);
     } else {
       Assert.fail();
     }
@@ -101,33 +95,8 @@ public class ThemeParserUnitTest {
       Assert.assertEquals("test4", theme4.getName());
       Assert.assertEquals(0, theme4.getResources().getScriptList().size());
       Assert.assertEquals(0, theme4.getResources().getStyleList().size());
-      themeBuilder.addTheme(theme4);
     } else {
       Assert.fail();
     }
-
-    themeBuilder.resolveThemes();
-    Assert.assertEquals(1, theme.getResources().getScriptList().size());
-    Assert.assertEquals("script/tobago.js", theme.getResources().getScriptList().get(0).getName());
-//    Assert.assertEquals("script/tobago-console.js", theme.getResources().getScriptList().get(1).getName());
-
-    Assert.assertNotNull(theme2.getResources());
-    Assert.assertEquals(2, theme2.getResources().getScriptList().size());
-    Assert.assertEquals(1, theme2.getResources().getStyleList().size());
-    Assert.assertEquals("script/tobago.js", theme2.getResources().getScriptList().get(0).getName());
-//    Assert.assertEquals("script/tobago-console.js", theme2.getResources().getScriptList().get(1).getName());
-    Assert.assertEquals("script/test.js", theme2.getResources().getScriptList().get(1).getName());
-
-    Assert.assertEquals(2, theme3.getResources().getScriptList().size());
-    Assert.assertEquals("script/tobago.js", theme3.getResources().getScriptList().get(0).getName());
-//    Assert.assertEquals("script/tobago-console.js", theme3.getResources().getScriptList().get(1).getName());
-    Assert.assertEquals("script/test.js", theme3.getResources().getScriptList().get(1).getName());
-
-    Assert.assertEquals(2, theme4.getResources().getScriptList().size());
-    Assert.assertEquals("script/tobago.js", theme4.getResources().getScriptList().get(0).getName());
-//    Assert.assertEquals("script/tobago-console.js", theme4.getResources().getScriptList().get(1).getName());
-    Assert.assertEquals("script/test.js", theme4.getResources().getScriptList().get(1).getName());
-
-
   }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java?rev=1716490&r1=1716489&r2=1716490&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/mock/faces/MockTheme.java Wed Nov 25 17:05:51 2015
@@ -20,11 +20,12 @@
 package org.apache.myfaces.tobago.internal.mock.faces;
 
 import org.apache.myfaces.tobago.context.Theme;
+import org.apache.myfaces.tobago.context.ThemeImpl;
 import org.apache.myfaces.tobago.internal.config.RenderersConfig;
 
 import java.util.List;
 
-public class MockTheme implements Theme {
+public class MockTheme extends ThemeImpl {
 
   private String name;