1 /* 2 * $Id: RenderKitFactory.java,v 1.24 2007/04/27 22:00:10 ofung Exp $ 3 */ 4 5 /* 6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 7 * 8 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. 9 * 10 * The contents of this file are subject to the terms of either the GNU 11 * General Public License Version 2 only ("GPL") or the Common Development 12 * and Distribution License("CDDL") (collectively, the "License"). You 13 * may not use this file except in compliance with the License. You can obtain 14 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html 15 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific 16 * language governing permissions and limitations under the License. 17 * 18 * When distributing the software, include this License Header Notice in each 19 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. 20 * Sun designates this particular file as subject to the "Classpath" exception 21 * as provided by Sun in the GPL Version 2 section of the License file that 22 * accompanied this code. If applicable, add the following below the License 23 * Header, with the fields enclosed by brackets [] replaced by your own 24 * identifying information: "Portions Copyrighted [year] 25 * [name of copyright owner]" 26 * 27 * Contributor(s): 28 * 29 * If you wish your version of this file to be governed by only the CDDL or 30 * only the GPL Version 2, indicate your decision by adding "[Contributor] 31 * elects to include this software in this distribution under the [CDDL or GPL 32 * Version 2] license." If you don't indicate a single choice of license, a 33 * recipient has the option to distribute your version of this file under 34 * either the CDDL, the GPL Version 2 or to extend the choice of license to 35 * its licensees as provided above. However, if you add GPL Version 2 code 36 * and therefore, elected the GPL Version 2 license, then the option applies 37 * only if the new code is made subject to such option by the copyright 38 * holder. 39 */ 40 41 package javax.faces.render; 42 43 44 import java.util.Iterator; 45 import javax.faces.FacesWrapper; 46 import javax.faces.context.FacesContext; 47 48 49 /** 50 * <p><strong class="changed_modified_2_0">RenderKitFactory</strong> is a 51 * factory object that registers 52 * and returns {@link RenderKit} instances. Implementations of 53 * JavaServer Faces must provide at least a default implementation of 54 * {@link RenderKit}. Advanced implementations (or external third party 55 * libraries) may provide additional {@link RenderKit} implementations 56 * (keyed by render kit identifiers) for performing different types of 57 * rendering for the same components.</p> 58 * 59 * <p>There must be one {@link RenderKitFactory} instance per web 60 * application that is utilizing JavaServer Faces. This instance can be 61 * acquired, in a portable manner, by calling:</p> 62 * <pre> 63 * RenderKitFactory factory = (RenderKitFactory) 64 * FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY); 65 * </pre> 66 */ 67 68 public abstract class RenderKitFactory implements FacesWrapper<RenderKitFactory> { 69 70 /** 71 * <p class="changed_added_2_0">If this factory has been decorated, the 72 * implementation doing the decorating may override this method to provide 73 * access to the implementation being wrapped. A default implementation 74 * is provided that returns <code>null</code>.</p> 75 * 76 * @since 2.0 77 */ 78 79 public RenderKitFactory getWrapped() { 80 return null; 81 } 82 83 /** 84 * <p>The render kit identifier of the default {@link RenderKit} instance 85 * for this JavaServer Faces implementation.</p> 86 */ 87 public static final String HTML_BASIC_RENDER_KIT = "HTML_BASIC"; 88 89 90 /** 91 * <p>Register the specified {@link RenderKit} instance, associated with 92 * the specified <code>renderKitId</code>, to be supported by this 93 * {@link RenderKitFactory}, replacing any previously registered 94 * {@link RenderKit} for this identifier.</p> 95 * 96 * @param renderKitId Identifier of the {@link RenderKit} to register 97 * @param renderKit {@link RenderKit} instance that we are registering 98 * 99 * @throws NullPointerException if <code>renderKitId</code> or 100 * <code>renderKit</code> is <code>null</code> 101 */ 102 public abstract void addRenderKit(String renderKitId, 103 RenderKit renderKit); 104 105 106 /** 107 * <p>Return a {@link RenderKit} instance for the specified render 108 * kit identifier, possibly customized based on dynamic 109 * characteristics of the specified {@link FacesContext}, if 110 * non-<code>null</code>. If there is no registered {@link 111 * RenderKit} for the specified identifier, return 112 * <code>null</code>. The set of available render kit identifiers 113 * is available via the <code>getRenderKitIds()</code> method.</p> 114 * 115 * @param context FacesContext for the request currently being 116 * processed, or <code>null</code> if none is available. 117 * @param renderKitId Render kit identifier of the requested 118 * {@link RenderKit} instance 119 * 120 * @throws IllegalArgumentException if no {@link RenderKit} instance 121 * can be returned for the specified identifier 122 * @throws NullPointerException if <code>renderKitId</code> is 123 * <code>null</code> 124 */ 125 public abstract RenderKit getRenderKit(FacesContext context, 126 String renderKitId); 127 128 129 /** 130 * <p>Return an <code>Iterator</code> over the set of render kit 131 * identifiers registered with this factory. This set must include 132 * the value specified by <code>RenderKitFactory.HTML_BASIC_RENDER_KIT</code>. 133 * </p> 134 */ 135 public abstract Iterator<String> getRenderKitIds(); 136 137 138 }