From 49fbbf9aa4a85864b9cc4a3c9ee9998093424e27 Mon Sep 17 00:00:00 2001 From: Fugerit Date: Mon, 2 Dec 2019 01:12:11 +0100 Subject: [PATCH] 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) --- .../doc/base/facade/DocHandlerFacade.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/facade/DocHandlerFacade.java b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/facade/DocHandlerFacade.java index da30314f9..66cb22ad5 100644 --- a/fj-doc-base/src/main/java/org/fugerit/java/doc/base/facade/DocHandlerFacade.java +++ b/fj-doc-base/src/main/java/org/fugerit/java/doc/base/facade/DocHandlerFacade.java @@ -1,11 +1,12 @@ package org.fugerit.java.doc.base.facade; import java.io.Serializable; +import java.util.Collection; import java.util.HashMap; import java.util.Map; import org.fugerit.java.core.cfg.ConfigException; -import org.fugerit.java.core.cfg.xml.FactoryCatalog; +import org.fugerit.java.core.util.collection.ListMapStringKey; import org.fugerit.java.doc.base.config.DocInput; import org.fugerit.java.doc.base.config.DocOutput; import org.fugerit.java.doc.base.config.DocTypeHandler; @@ -34,15 +35,24 @@ public class DocHandlerFacade implements Serializable { public static final boolean DEFAULT_ERROR_ON_DUPLICATE = false; - private Map mapHandlers; + private Map mapHandlers; // map handlers registered by id + + private Map> mapTypeHandlers; // map handlers registered by type public DocHandlerFacade() { this.mapHandlers = new HashMap<>(); + this.mapTypeHandlers = new HashMap<>(); } private void doRegister( DocTypeHandler handler, String id ) { logger.info( "Registering handler with id {} : {}", id, handler.getClass().getName() ); - this.mapHandlers.put( id, handler ); + this.mapHandlers.put( id, handler ); + ListMapStringKey list = this.mapTypeHandlers.get( handler.getType() ); + if ( list == null ) { + list = new ListMapStringKey(); + this.mapTypeHandlers.put( handler.getType() , list ); + } + list.add( handler ); } public void registerHandler( DocTypeHandler handler, boolean registerForType, boolean errorOnDuplicate ) throws Exception { @@ -60,7 +70,7 @@ public void registerHandler( DocTypeHandler handler, boolean registerForType, bo doRegister(handler, type); } } - + public void registerHandler( DocTypeHandler handler ) throws Exception { this.registerHandler( handler, DEFAULT_REGISTER_FOR_TYPE, DEFAULT_ERROR_ON_DUPLICATE ); } @@ -79,12 +89,12 @@ public DocTypeHandler findHandler( String id ) { return this.mapHandlers.get( id ); } - public void register( String factoryCatalogPath ) { - + public ListMapStringKey listHandlersForType( String type ) { + return this.mapTypeHandlers.get( type ); } - public void register( FactoryCatalog catalog ) { - + public Collection handlers() { + return this.mapHandlers.values(); } }