fugerit-org/fj-doc

[fj-doc-base] Managing of unsafe DocTypeHandler for DocHandlerFactory

Closed this issue · 0 comments

The class DocHandlerFactory offers a conveniente system to load and register type handler, but if even just one type handler is not found, the load process will fail.

It would be better if it was possible to tag handlers entry as "unsafe" (in which case the factory creations should not safe if the handler is not found).

	<factory id="unsafe-test">
		<data id="html-fm" info="html" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8" />	
		<data id="html-fragment-fm" info="fhtml" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerUTF8" />
		<data id="pdf-unsafe" info="pdf" type="org.fugerit.java.doc.pdf.UnsafeDocHandler" />
	</factory>

Imagine the last handler is not available in class loader. Thi can be handled with the new properties :

unsafe="true" unsafeMode="log-trace"

	<factory id="unsafe-test">
		<data id="html-fm" info="html" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8" />	
		<data id="html-fragment-fm" info="fhtml" type="org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerUTF8" />
		<data id="pdf-unsafe" info="pdf" type="org.fugerit.java.doc.pdf.UnsafeDocHandler" unsafe="true" unsafeMode="log-trace"/>
	</factory>

The stack trace will be logged only if you set unsafeMod to log-trace. If you want to suppress the stack trace use :

unsafe="true" unsafeMode="log-message"