dev@javaserverfaces.java.net

Seeking Retroactive Review [265-DecorateRenderKit]

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Wed, 15 Oct 2008 16:50:31 -0400

Issue: 265


SECTION: Modified Files
----------------------------
M jsf-ri/src/com/sun/faces/config/processor/RenderKitConfigProcessor.java

- Modify to state that RenderKits can be decorated.

A jsf-api/src/javax/faces/render/RenderKitWrapper.java

- Simple wrapper for RenderKit

SECTION: Spec Prose document Mods:

Add this to 11.4.5 Delegating Implementation Support

The implementation must also support decoration of a RenderKit
instance. At the point in time of when the <render-kit> element is
processed in an application configuration resources, if the current
RenderKitFactory already has a RenderKit instance for the
<render-kit-id> within the <render-kit> element, and the Class whose
fully qualified java class name is given as the value of the
<render-kit-class> element within the <render-kit> element has a
constructor that takes an RenderKit instance, the existing RenderKit for
that <render-kit-id> must be passed to that constructor, and the
RenderKit resulting from the executing of that constructor must be
passed to RenderKitFactory.addRenderKit().

SECTION: Diffs
----------------------------
Index: jsf-api/src/javax/faces/render/RenderKitWrapper.java
===================================================================
--- jsf-api/src/javax/faces/render/RenderKitWrapper.java (revision 0)
+++ jsf-api/src/javax/faces/render/RenderKitWrapper.java (revision 0)
@@ -0,0 +1,101 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+package javax.faces.render;
+
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Iterator;
+import javax.faces.FacesWrapper;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+
+/**
+ * <p class="changed_modified_2_0">Provides a simple implementation of
+ * {_at_link RenderKit} that
+ * can be subclassed by developers wishing to provide specialized
+ * behavior to an existing {_at_link RenderKit} instance. The default
+ * implementation of all methods is to call through to the wrapped
+ * {_at_link RenderKit}.</p>
+ *
+ * <p class="changed_added_2_0">Usage: extend this class and override {_at_link #getWrapped} to
+ * return the instance we are wrapping.</p>
+ *
+ * @since 2.0
+ */
+public abstract class RenderKitWrapper extends RenderKit implements FacesWrapper<RenderKit> {
+
+ @Override
+ public void addRenderer(String family, String rendererType, Renderer renderer) {
+ getWrapped().addRenderer(family, rendererType, renderer);
+ }
+
+ @Override
+ public ResponseStream createResponseStream(OutputStream out) {
+ return getWrapped().createResponseStream(out);
+ }
+
+ @Override
+ public ResponseWriter createResponseWriter(Writer writer, String contentTypeList, String characterEncoding) {
+ return getWrapped().createResponseWriter(writer, contentTypeList, characterEncoding);
+ }
+
+ @Override
+ public Renderer getRenderer(String family, String rendererType) {
+ return getWrapped().getRenderer(family, rendererType);
+ }
+
+ @Override
+ public ResponseStateManager getResponseStateManager() {
+ return getWrapped().getResponseStateManager();
+ }
+
+ public abstract RenderKit getWrapped();
+
+ @Override
+ public Iterator<String> getComponentFamilies() {
+ return getWrapped().getComponentFamilies();
+ }
+
+ @Override
+ public Iterator<String> getRendererTypes(String componentFamily) {
+ return getWrapped().getRendererTypes(componentFamily);
+ }
+
+
+
+
+}
Index: jsf-ri/src/com/sun/faces/config/processor/RenderKitConfigProcessor.java
===================================================================
--- jsf-ri/src/com/sun/faces/config/processor/RenderKitConfigProcessor.java (revision 5548)
+++ jsf-ri/src/com/sun/faces/config/processor/RenderKitConfigProcessor.java (working copy)
@@ -59,6 +59,7 @@
 import java.util.Map;
 import java.util.LinkedHashMap;
 import java.text.MessageFormat;
+import javax.faces.context.FacesContext;
 
 /**
  * <p>
@@ -191,7 +192,9 @@
 
             RenderKit rk = rkf.getRenderKit(null, rkId);
             if (rk == null && rkClass != null) {
- rk = (RenderKit) createInstance(rkClass, RenderKit.class, null, renderKit);
+ RenderKit previous = rkf.getRenderKit(FacesContext.getCurrentInstance(),
+ rkId);
+ rk = (RenderKit) createInstance(rkClass, RenderKit.class, previous, renderKit);
                 if (LOGGER.isLoggable(Level.FINE)) {
                     LOGGER.log(Level.FINE,
                                MessageFormat.format(


SECTION: New Files
----------------------------
SEE ATTACHMENTS


--