Skip to content

Commit ef106d6

Browse files
Mini filter now work in a caching mode too
1 parent f6c4605 commit ef106d6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fj-core/src/main/java/org/fugerit/java/core/util/filterchain/MiniFilterConfig.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.io.InputStream;
44
import java.util.Collection;
5+
import java.util.HashMap;
56
import java.util.Iterator;
7+
import java.util.Map;
68

79
import org.fugerit.java.core.cfg.xml.GenericListCatalogConfig;
810
import org.fugerit.java.core.lang.helpers.ClassHelper;
@@ -17,6 +19,13 @@ public class MiniFilterConfig extends GenericListCatalogConfig<MiniFilterConfigE
1719
*/
1820
private static final long serialVersionUID = 286844409632297876L;
1921

22+
private Map<String, MiniFilterChain> mapChain;
23+
24+
public MiniFilterConfig() {
25+
super();
26+
this.mapChain = new HashMap<String, MiniFilterChain>();
27+
}
28+
2029
public static MiniFilterConfig loadConfig( InputStream is, MiniFilterConfig config ) throws Exception {
2130
Document doc = DOMIO.loadDOMDoc( is );
2231
Element root = doc.getDocumentElement();
@@ -39,4 +48,13 @@ public MiniFilterChain getChain( String id ) throws Exception {
3948
return chain;
4049
}
4150

51+
public MiniFilterChain getChainCache( String id ) throws Exception {
52+
MiniFilterChain chain = this.mapChain.get( id );
53+
if ( chain == null ) {
54+
chain = this.getChain( id );
55+
this.mapChain.put( id , chain );
56+
}
57+
return chain;
58+
}
59+
4260
}

0 commit comments

Comments
 (0)