You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/01/12 12:27:19 UTC
svn commit: r611401 - in
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config:
TobagoConfig.java TobagoConfigParser.java
Author: bommel
Date: Sat Jan 12 03:27:18 2008
New Revision: 611401
URL: http://svn.apache.org/viewvc?rev=611401&view=rev
Log:
(TOBAGO-584) Minimize configuration overhead for tobago
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java?rev=611401&r1=611400&r2=611401&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java Sat Jan 12 03:27:18 2008
@@ -69,21 +69,41 @@
}
public void resolveThemes() {
-
- defaultTheme = availableTheme.get(defaultThemeName);
- checkThemeIsAvailable(defaultThemeName, defaultTheme);
- if (LOG.isDebugEnabled()) {
- LOG.debug("name = '" + defaultThemeName + "'");
- LOG.debug("defaultTheme = '" + defaultTheme + "'");
- }
-
- for (String name : supportedThemeNames) {
- Theme theme = availableTheme.get(name);
- checkThemeIsAvailable(name, theme);
- supportedThemes.add(theme);
+ if (defaultThemeName != null) {
+ defaultTheme = availableTheme.get(defaultThemeName);
+ checkThemeIsAvailable(defaultThemeName, defaultTheme);
if (LOG.isDebugEnabled()) {
- LOG.debug("name = '" + name + "'");
- LOG.debug("supportedThemes.last() = '" + supportedThemes.get(supportedThemes.size() - 1) + "'");
+ LOG.debug("name = '" + defaultThemeName + "'");
+ LOG.debug("defaultTheme = '" + defaultTheme + "'");
+ }
+ } else {
+ int deep = 1;
+ for (Map.Entry<String, Theme> entry: availableTheme.entrySet()) {
+ Theme theme = entry.getValue();
+ if (theme.getFallbackList().size() > deep) {
+ defaultTheme = theme;
+ deep = theme.getFallbackList().size();
+ }
+ }
+ 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";
+ LOG.error(error);
+ throw new RuntimeException(error);
+ } else {
+ LOG.info("Using default Theme " + defaultTheme.getName());
+ }
+ }
+ if (!supportedThemeNames.isEmpty()) {
+ for (String name : supportedThemeNames) {
+ Theme theme = availableTheme.get(name);
+ checkThemeIsAvailable(name, theme);
+ supportedThemes.add(theme);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("name = '" + name + "'");
+ LOG.debug("supportedThemes.last() = '" + supportedThemes.get(supportedThemes.size() - 1) + "'");
+ }
}
}
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java?rev=611401&r1=611400&r2=611401&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java Sat Jan 12 03:27:18 2008
@@ -109,8 +109,7 @@
if (input != null) {
digester.parse(input);
} else {
- throw new FacesException(
- "No config file found: '" + configPath + "'. Tobago can't run without configuration.");
+ LOG.warn("No config file found: '" + configPath + "'. Tobago runs with a default configuration.");
}
} finally {
IOUtils.closeQuietly(input);