1 20 package org.enhydra.barracuda.core.util.dom; 21 22 import java.io.IOException ; 23 import org.w3c.dom.Document ; 24 import org.apache.log4j.Logger; 25 import org.enhydra.xml.xmlc.XMLObject; 26 import org.enhydra.xml.xmlc.XMLCStdFactory; 27 28 29 33 public class XMLCStdDOMFactory implements DOMFactory { 34 35 38 protected static final Logger logger = Logger.getLogger(XMLCStdDOMFactory.class.getName()); 39 40 43 protected final Object sync = new Object (); 44 45 49 protected boolean initialized = false; 50 51 55 protected XMLCStdFactory xmlcFactory; 56 57 67 public Document getInstance(Class clazz) throws IOException { 68 if (!((XMLObject.class).isAssignableFrom(clazz))) throw new IOException ("Class "+clazz.getName()+" can not be loaded by this DOMFactory because it does not implement XMLOBject"); 69 initFactory(); 70 return xmlcFactory.create(clazz); 71 } 72 73 77 public Document getInstance(String docPath) throws IOException { 78 throw new IOException ("Error: Unimplemented - XMLCStdFactory does not support creation of documents directly from file"); 79 } 80 81 private void initFactory() { 82 if (initialized == false) { 83 synchronized (sync) { 84 logger.info("initializing an XMLC Std factory for returning XMLC-generated documents"); 85 xmlcFactory = new XMLCStdFactory(Thread.currentThread().getContextClassLoader(), null); 86 initialized = true; 87 } 88 } 89 } 90 91 } 92 | Popular Tags |