Updated CssUrlReplacementCompressor - ComponentInitializationListener has to be ThreadSafe - Fixed redundancy
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b8635045 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b8635045 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b8635045 Branch: refs/heads/master Commit: b8635045b1b3cca9799dccae37ece6c8926db65b Parents: 9752eac Author: klopfdreh <klopfdreh@tobiass-mbp> Authored: Wed Feb 4 15:17:23 2015 +0100 Committer: klopfdreh <klopfdreh@tobiass-mbp> Committed: Wed Feb 4 15:17:23 2015 +0100 ---------------------------------------------------------------------- .../resource/CssUrlReplacementCompressor.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/b8635045/wicket-core/src/main/java/org/apache/wicket/resource/CssUrlReplacementCompressor.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/CssUrlReplacementCompressor.java b/wicket-core/src/main/java/org/apache/wicket/resource/CssUrlReplacementCompressor.java index eac8d23..44d67e5 100644 --- a/wicket-core/src/main/java/org/apache/wicket/resource/CssUrlReplacementCompressor.java +++ b/wicket-core/src/main/java/org/apache/wicket/resource/CssUrlReplacementCompressor.java @@ -19,8 +19,10 @@ package org.apache.wicket.resource; import java.io.PrintWriter; import java.io.StringWriter; import java.net.URL; -import java.util.ArrayList; -import java.util.List; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -35,8 +37,8 @@ import org.apache.wicket.request.resource.PackageResourceReference; /** * This compressor is used to replace url within css files with resources that belongs to their - * corresponding page classes. The compress method is not compressing any content, but replacing the URLs - * with Wicket representatives.<br> + * corresponding page classes. The compress method is not compressing any content, but replacing the + * URLs with Wicket representatives.<br> * <br> * Usage: * @@ -52,7 +54,7 @@ public class CssUrlReplacementCompressor implements ICssCompressor { // Holds the names of pages - private List<String> pageNames = new ArrayList<String>(); + private Map<String, String> pageNames = Collections.synchronizedMap(new LinkedHashMap<String, String>()); // The pattern to find URLs in CSS resources private Pattern urlPattern = Pattern.compile("url\\(['|\"](.*)['|\"]\\)"); @@ -70,7 +72,8 @@ public class CssUrlReplacementCompressor implements ICssCompressor { if (Page.class.isAssignableFrom(component.getClass())) { - CssUrlReplacementCompressor.this.pageNames.add(component.getClass().getName()); + CssUrlReplacementCompressor.this.pageNames.put(component.getClass() + .getName(), component.getClass().getSimpleName()); } } }); @@ -87,7 +90,8 @@ public class CssUrlReplacementCompressor implements ICssCompressor // Search for urls while (matcher.find()) { - for (String pageName : this.pageNames) + Collection<String> pageNames = this.pageNames.values(); + for (String pageName : pageNames) { try {