1 16 package org.apache.cocoon.components.renderer; 17 18 import org.apache.fop.render.Renderer; 19 import org.apache.fop.render.pcl.PCLRenderer; 20 import org.apache.fop.render.pdf.PDFRenderer; 21 import org.apache.fop.render.ps.PSRenderer; 22 23 import java.util.HashMap ; 24 import java.util.Map ; 25 26 34 public class ExtendableRendererFactory implements RendererFactory { 35 36 protected final static Map renderers = new HashMap (); 37 38 protected final static RendererFactory singleton = new ExtendableRendererFactory(); 39 40 private ExtendableRendererFactory() { 41 addRenderer("application/pdf", PDFRenderer.class); 43 addRenderer("application/postscript", PSRenderer.class); 44 addRenderer("application/vnd.hp-PCL", PCLRenderer.class); 45 } 46 47 50 public final static RendererFactory getRendererFactoryImplementation() { 51 return singleton; 52 } 53 54 59 public Renderer createRenderer(String mimeType) { 60 Class rendererClass = (Class )renderers.get(mimeType); 61 if (rendererClass == null) { 62 return null; 63 } else { 64 try { 65 return (Renderer)rendererClass.newInstance(); 66 } catch (Exception ex) { 67 return null; 68 } 69 } 70 } 71 72 78 public void addRenderer(String mimeType, Class rendererClass) { 79 renderers.put(mimeType, rendererClass); 80 } 81 82 86 public void removeRenderer(String mimeType) { 87 renderers.remove(mimeType); 88 } 89 } 90 | Popular Tags |