Revision: 620
http://stripes.svn.sourceforge.net/stripes/?rev=620&view=rev
Author: bengunter
Date: 2007-11-12 04:27:50 -0800 (Mon, 12 Nov 2007)
Log Message:
-----------
More for STS-428. Replaced calls to Map.putAll(...) with new
mergeInterceptorMaps(...) which adds to any collections already present in the
destination map or creates new ones if necessary.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java
2007-11-12 04:42:24 UTC (rev 619)
+++ trunk/stripes/src/net/sourceforge/stripes/config/DefaultConfiguration.java
2007-11-12 12:27:50 UTC (rev 620)
@@ -169,11 +169,11 @@
this.interceptors = new HashMap<LifecycleStage,
Collection<Interceptor>>();
Map<LifecycleStage, Collection<Interceptor>> map =
initCoreInterceptors();
if (map != null) {
- this.interceptors.putAll(map);
+ mergeInterceptorMaps(this.interceptors, map);
}
map = initInterceptors();
if (map != null) {
- this.interceptors.putAll(map);
+ mergeInterceptorMaps(this.interceptors, map);
}
}
catch (Exception e) {
@@ -335,6 +335,23 @@
}
/**
+ * Merges the two [EMAIL PROTECTED] Map}s of [EMAIL PROTECTED]
LifecycleStage} to [EMAIL PROTECTED] Collection} of
+ * [EMAIL PROTECTED] Interceptor}. A simple [EMAIL PROTECTED]
Map#putAll(Map)} does not work because it overwrites
+ * the collections in the map instead of adding to them.
+ */
+ protected void mergeInterceptorMaps(Map<LifecycleStage,
Collection<Interceptor>> dst,
+ Map<LifecycleStage, Collection<Interceptor>> src) {
+ for (Map.Entry<LifecycleStage, Collection<Interceptor>> entry :
src.entrySet()) {
+ Collection<Interceptor> collection = dst.get(entry.getKey());
+ if (collection == null) {
+ collection = new LinkedList<Interceptor>();
+ dst.put(entry.getKey(), collection);
+ }
+ collection.addAll(entry.getValue());
+ }
+ }
+
+ /**
* Adds the interceptor to the map, associating it with the [EMAIL
PROTECTED] LifecycleStage}s indicated
* by the [EMAIL PROTECTED] Intercepts} annotation. If the interceptor
implements
* [EMAIL PROTECTED] ConfigurableComponent}, then its init() method will
be called.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development