Skip to content

Commit 49fbbf9

Browse files
committed
Version 2.2.3.1 (2019-12-01)
---------------------------- - Changed type handler registration in [DocHandlerFacade](src/main/java/org/fugerit/java/doc/base/facade/DocHandlerFacade.java)
1 parent 2abde77 commit 49fbbf9

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

fj-doc-base/src/main/java/org/fugerit/java/doc/base/facade/DocHandlerFacade.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package org.fugerit.java.doc.base.facade;
22

33
import java.io.Serializable;
4+
import java.util.Collection;
45
import java.util.HashMap;
56
import java.util.Map;
67

78
import org.fugerit.java.core.cfg.ConfigException;
8-
import org.fugerit.java.core.cfg.xml.FactoryCatalog;
9+
import org.fugerit.java.core.util.collection.ListMapStringKey;
910
import org.fugerit.java.doc.base.config.DocInput;
1011
import org.fugerit.java.doc.base.config.DocOutput;
1112
import org.fugerit.java.doc.base.config.DocTypeHandler;
@@ -34,15 +35,24 @@ public class DocHandlerFacade implements Serializable {
3435

3536
public static final boolean DEFAULT_ERROR_ON_DUPLICATE = false;
3637

37-
private Map<String, DocTypeHandler> mapHandlers;
38+
private Map<String, DocTypeHandler> mapHandlers; // map handlers registered by id
39+
40+
private Map<String, ListMapStringKey<DocTypeHandler>> mapTypeHandlers; // map handlers registered by type
3841

3942
public DocHandlerFacade() {
4043
this.mapHandlers = new HashMap<>();
44+
this.mapTypeHandlers = new HashMap<>();
4145
}
4246

4347
private void doRegister( DocTypeHandler handler, String id ) {
4448
logger.info( "Registering handler with id {} : {}", id, handler.getClass().getName() );
45-
this.mapHandlers.put( id, handler );
49+
this.mapHandlers.put( id, handler );
50+
ListMapStringKey<DocTypeHandler> list = this.mapTypeHandlers.get( handler.getType() );
51+
if ( list == null ) {
52+
list = new ListMapStringKey<DocTypeHandler>();
53+
this.mapTypeHandlers.put( handler.getType() , list );
54+
}
55+
list.add( handler );
4656
}
4757

4858
public void registerHandler( DocTypeHandler handler, boolean registerForType, boolean errorOnDuplicate ) throws Exception {
@@ -60,7 +70,7 @@ public void registerHandler( DocTypeHandler handler, boolean registerForType, bo
6070
doRegister(handler, type);
6171
}
6272
}
63-
73+
6474
public void registerHandler( DocTypeHandler handler ) throws Exception {
6575
this.registerHandler( handler, DEFAULT_REGISTER_FOR_TYPE, DEFAULT_ERROR_ON_DUPLICATE );
6676
}
@@ -79,12 +89,12 @@ public DocTypeHandler findHandler( String id ) {
7989
return this.mapHandlers.get( id );
8090
}
8191

82-
public void register( String factoryCatalogPath ) {
83-
92+
public ListMapStringKey<DocTypeHandler> listHandlersForType( String type ) {
93+
return this.mapTypeHandlers.get( type );
8494
}
8595

86-
public void register( FactoryCatalog catalog ) {
87-
96+
public Collection<DocTypeHandler> handlers() {
97+
return this.mapHandlers.values();
8898
}
8999

90100
}

0 commit comments

Comments
 (0)