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 2012/05/23 13:22:11 UTC
svn commit: r1341831 - in
/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal:
config/TobagoConfigFragment.java context/ResourceLocator.java
Author: lofwyr
Date: Wed May 23 11:22:11 2012
New Revision: 1341831
URL: http://svn.apache.org/viewvc?rev=1341831&view=rev
Log:
TOBAGO-1142: Endless loop when having the file /WEB-INF/classes/META-INF/tobago-config.xml
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigFragment.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ResourceLocator.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigFragment.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigFragment.java?rev=1341831&r1=1341830&r2=1341831&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigFragment.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigFragment.java Wed May 23 11:22:11 2012
@@ -17,7 +17,7 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
-import org.apache.myfaces.tobago.context.Theme;
+import org.apache.myfaces.tobago.context.ThemeImpl;
import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +41,7 @@ public class TobagoConfigFragment {
private Boolean createSessionSecret;
private Boolean checkSessionSecret;
// todo
- private List<Theme> themeDefinitions;
+ private List<ThemeImpl> themeDefinitions;
private URL url;
public TobagoConfigFragment() {
@@ -49,7 +49,7 @@ public class TobagoConfigFragment {
after = new ArrayList<String>();
supportedThemeNames = new ArrayList<String>();
resourceDirs = new ArrayList<String>();
- themeDefinitions = new ArrayList<Theme>();
+ themeDefinitions = new ArrayList<ThemeImpl>();
}
public void addSupportedThemeName(String name) {
@@ -119,11 +119,11 @@ public class TobagoConfigFragment {
after.add(name);
}
- public void addThemeDefinition(Theme theme) {
+ public void addThemeDefinition(ThemeImpl theme) {
themeDefinitions.add(theme);
}
- public List<Theme> getThemeDefinitions() {
+ public List<ThemeImpl> getThemeDefinitions() {
return themeDefinitions;
}
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=1341831&r1=1341830&r2=1341831&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 Wed May 23 11:22:11 2012
@@ -145,25 +145,15 @@ class ResourceLocator {
CollectionUtils.addAll(urls, classLoader.getResources(META_INF_TOBAGO_THEME_XML));
for (URL themeUrl : urls) {
- ThemeImpl theme;
if (themeUrl.toString().endsWith(META_INF_TOBAGO_CONFIG_XML)) {
TobagoConfigFragment tobagoConfig = new TobagoConfigParser().parse(themeUrl);
- theme = (ThemeImpl) tobagoConfig.getThemeDefinitions().get(0);
+ for (ThemeImpl theme : tobagoConfig.getThemeDefinitions()) {
+ addThemeResources( resources, themeUrl, theme);
+ }
} else {
// the old way
- theme = parser.parse(themeUrl);
- }
- themeBuilder.addTheme(theme);
- String prefix = ensureSlash(theme.getResourcePath());
-
- String protocol = themeUrl.getProtocol();
- // tomcat uses jar
- // weblogic uses zip
- // IBM WebSphere uses wsjar
- if (!"jar".equals(protocol) && !"zip".equals(protocol) && !"wsjar".equals(protocol)) {
- LOG.warn("Unknown protocol '" + themeUrl + "'");
+ addThemeResources(resources, themeUrl, parser.parse(themeUrl));
}
- addResources(resources, themeUrl, prefix, 0);
}
} catch (IOException e) {
String msg = "while loading ";
@@ -176,6 +166,21 @@ class ResourceLocator {
}
}
+ private void addThemeResources(ResourceManagerImpl resources, URL themeUrl, ThemeImpl theme)
+ throws IOException, ServletException {
+ themeBuilder.addTheme(theme);
+ String prefix = ensureSlash(theme.getResourcePath());
+
+ String protocol = themeUrl.getProtocol();
+ // tomcat uses jar
+ // weblogic uses zip
+ // IBM WebSphere uses wsjar
+ if (!"jar".equals(protocol) && !"zip".equals(protocol) && !"wsjar".equals(protocol)) {
+ LOG.warn("Unknown protocol '" + themeUrl + "'");
+ }
+ addResources(resources, themeUrl, prefix, 0);
+ }
+
/**
* Searches the /WEB-INF/lib directory for *.jar files which contains /META-INF/resources directory
* to hold resources and add them to the ResourceManager.
@@ -228,11 +233,12 @@ class ResourceLocator {
fileName = fileName.substring(protocol.length() + 1, index);
}
if (LOG.isInfoEnabled()) {
- LOG.info("Adding resources from fileName='"+fileName + "' prefix='" + prefix + "' skip=" + skipPrefix + "");
+ LOG.info("Adding resources from fileName='" + fileName + "' prefix='" + prefix + "' skip=" + skipPrefix + "");
}
// JBoss 5.0.0 introduced vfszip protocol
- if (!protocol.equals("vfszip") && fileName.endsWith(META_INF_TOBAGO_THEME_XML)) {
+ if (!protocol.equals("vfszip")
+ && (fileName.endsWith(META_INF_TOBAGO_THEME_XML) || fileName.endsWith(META_INF_TOBAGO_CONFIG_XML))) {
try {
URI uri = themeUrl.toURI();
File tobagoThemeXml = new File(uri);
@@ -240,7 +246,7 @@ class ResourceLocator {
String resourcePath = "";
resolveTheme(resources, directoryFile, resourcePath, prefix, false);
} catch (URISyntaxException e) {
- LOG.error("", e);
+ LOG.error("themeUrl='" + themeUrl + "'", e);
}
} else {
URL jarFile;
@@ -250,7 +256,9 @@ class ResourceLocator {
fileName = new File(fileName).getParentFile().getParentFile().getPath();
if (File.separatorChar == '\\' && fileName.contains("\\")) {
fileName = fileName.replace('\\', '/');
- LOG.info("Fixed slashes for virtual filesystem protocol on windows system: " + fileName);
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Fixed slashes for virtual filesystem protocol on windows system: " + fileName);
+ }
}
}
jarFile = new URL(fileName);