1 16 package org.apache.myfaces.renderkit; 17 18 import org.apache.commons.logging.Log; 19 import org.apache.commons.logging.LogFactory; 20 21 import javax.faces.FacesException; 22 import javax.faces.context.FacesContext; 23 import javax.faces.render.RenderKit; 24 import javax.faces.render.RenderKitFactory; 25 import java.util.HashMap ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 47 public class RenderKitFactoryImpl 48 extends RenderKitFactory 49 { 50 private static final Log log = LogFactory.getLog(RenderKitFactoryImpl.class); 51 52 private Map _renderkits = new HashMap (); 53 54 public RenderKitFactoryImpl() 55 { 56 } 57 58 59 public void addRenderKit(String renderKitId, RenderKit renderKit) 60 { 61 if (renderKitId == null) throw new NullPointerException ("renderKitId"); 62 if (renderKit == null) throw new NullPointerException ("renderKit"); 63 if (log.isInfoEnabled()) 64 { 65 if (_renderkits.containsKey(renderKitId)) 66 { 67 log.info("RenderKit with renderKitId '" + renderKitId + "' was replaced."); 68 } 69 } 70 _renderkits.put(renderKitId, renderKit); 71 } 72 73 74 public RenderKit getRenderKit(FacesContext context, String renderKitId) 75 throws FacesException 76 { 77 if (renderKitId == null) throw new NullPointerException ("renderKitId"); 78 RenderKit renderkit = (RenderKit)_renderkits.get(renderKitId); 79 if (renderkit == null) 80 { 81 log.warn("Unknown RenderKit '" + renderKitId + "'."); 87 } 88 return renderkit; 89 } 90 91 92 public Iterator getRenderKitIds() 93 { 94 return _renderkits.keySet().iterator(); 95 } 96 } 97 | Popular Tags |