1 13 package info.magnolia.cms.core.ie; 14 15 import info.magnolia.cms.util.ClassUtil; 16 17 import java.util.Hashtable ; 18 import java.util.Map ; 19 20 import org.slf4j.Logger; 21 import org.slf4j.LoggerFactory; 22 23 24 28 public final class ContentExporter { 29 30 33 private static Logger log = LoggerFactory.getLogger(ContentExporter.class); 34 35 38 public static final String DEFAULT_HANDLER_CLASS = "info.magnolia.cms.core.ie.XmlExport"; 40 public static final String DEFAULT_HANDLER = "defaultHandler"; 42 45 private Map handlers = new Hashtable (); 46 47 private static ContentExporter contentExporter = new ContentExporter(); 48 49 52 private ContentExporter() { 53 try { 54 ExportHandler defaultExporter = (ExportHandler) ClassUtil.newInstance(DEFAULT_HANDLER_CLASS); 55 this.addExportHandler(DEFAULT_HANDLER, defaultExporter); 56 } 57 catch (Exception e) { 58 log.error(e.getMessage(), e); 59 } 60 } 61 62 public static ContentExporter getInstance() { 63 return ContentExporter.contentExporter; 64 } 65 66 public void addExportHandler(String name, ExportHandler export) { 67 if (log.isDebugEnabled()) { 68 log.debug("Adding export handler " + export.getClass()); } 70 this.handlers.put(name, export); 71 } 72 73 public ExportHandler getExportHandler(String name) { 74 if (this.handlers.get(name) == null) { 75 log.error("No export handler found with name - " + name); log.error("Returning default export handler - " + DEFAULT_HANDLER); return (ExportHandler) this.handlers.get(DEFAULT_HANDLER); 78 } 79 return (ExportHandler) this.handlers.get(name); 80 } 81 82 } 83 | Popular Tags |