11package org .fugerit .java .doc .freemarker .process ;
22
33import java .io .Serializable ;
4- import java .util .HashMap ;
5- import java .util .Map ;
4+ import java .util .Set ;
65
76import org .fugerit .java .core .cfg .xml .ListMapConfig ;
87import org .fugerit .java .core .util .filterchain .MiniFilterChain ;
8+ import org .fugerit .java .core .util .filterchain .MiniFilterMap ;
99import org .fugerit .java .doc .base .facade .DocHandlerFacade ;
1010import org .fugerit .java .doc .base .process .DocProcessConfig ;
1111import org .fugerit .java .doc .base .process .DocProcessContext ;
1515import lombok .extern .slf4j .Slf4j ;
1616
1717@ Slf4j
18- public class FreemarkerDocProcessConfig extends DocProcessConfig implements Serializable {
18+ public class FreemarkerDocProcessConfig implements Serializable , MiniFilterMap {
1919
2020 private static final long serialVersionUID = -6761081877582850120L ;
2121
2222 @ Getter
2323 private ListMapConfig <DocChainModel > docChainList ;
2424
25- private Map <String , MiniFilterChain > additionalChans ;
26-
2725 @ Getter
2826 private DocHandlerFacade facade ;
2927
28+ private DocProcessConfig docProcessConfig ;
29+
3030 protected FreemarkerDocProcessConfig () {
3131 super ();
3232 this .docChainList = new ListMapConfig <>();
33- this .additionalChans = new HashMap <>();
3433 this .facade = new DocHandlerFacade ();
34+ this .docProcessConfig = new DocProcessConfig ();
3535 }
3636
3737 private DefaultChainProvider defaultChain ;
@@ -46,26 +46,35 @@ protected DefaultChainProvider getDefaultChain() {
4646
4747 public void process ( String chainId , DocProcessContext context , DocProcessData data ) throws Exception {
4848 MiniFilterChain chain = this .getChainCache ( chainId );
49- log .info ( "chain list {}" , this .getIdSet () );
49+ log .info ( "chain list {}" , this .docProcessConfig . getIdSet () );
5050 chain .apply ( context , data );
5151 }
5252
5353 @ Override
5454 public MiniFilterChain getChain (String id ) throws Exception {
55+ return this .docProcessConfig .getChain ( id );
56+ }
57+
58+ @ Override
59+ public MiniFilterChain getChainCache (String id ) throws Exception {
5560 MiniFilterChain chain = null ;
56- if ( this .getDataList ( id ) != null ) {
57- chain = this .getChain ( id );
58- } else if ( this .additionalChans .containsKey ( id ) ) {
59- chain = this .additionalChans .get ( id );
60- } else if ( this .getDefaultChain () != null ) {
61- chain = this .getDefaultChain ().newDefaultChain (id );
62- this .addAdditionalChain (chain );
61+ if ( this .docProcessConfig .getKeys ().contains ( id ) ) {
62+ chain = this .docProcessConfig .getChain (id );
63+ } else if ( this .defaultChain != null ) {
64+ chain = this .defaultChain .newDefaultChain (id );
65+ this .setChain (id , chain );
6366 }
6467 return chain ;
6568 }
66-
67- protected void addAdditionalChain ( MiniFilterChain chain ) {
68- this .additionalChans .put (chain .getChainId (), chain );
69+
70+ @ Override
71+ public Set <String > getKeys () {
72+ return this .docProcessConfig .getKeys ();
73+ }
74+
75+ @ Override
76+ public void setChain (String id , MiniFilterChain chain ) {
77+ this .docProcessConfig .setChain (id , chain );
6978 }
7079
7180}
0 commit comments