Author: thomas.heute(a)jboss.com
Date: 2007-06-21 04:53:27 -0400 (Thu, 21 Jun 2007)
New Revision: 7499
Added:
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeFacesContextFactoryImpl.java
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeLifecycleFactoryImpl.java
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeViewHandlerImpl.java
trunk/faces/src/resources/portal-faces-lib-jar/META-INF/faces-config.xml
Log:
Trying to have JBoss Portal 2.6 running on JBoss AS 4.0.x and 4.2.x
Added:
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeFacesContextFactoryImpl.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeFacesContextFactoryImpl.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeFacesContextFactoryImpl.java 2007-06-21
08:53:27 UTC (rev 7499)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.portlet;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFMetaBridgeFacesContextFactoryImpl extends FacesContextFactory
+{
+
+ private FacesContextFactory facesContextFactory;
+
+ public JSFMetaBridgeFacesContextFactoryImpl()
+ {
+ JSFMetaBridge metaBridge = JSFMetaBridgeFactory.getMetaBridge();
+ if
(metaBridge.getPortletClassName().equals(JSFMetaBridge.SUN_JSF.getPortletClassName()))
+ {
+ Class clazz;
+ try
+ {
+ clazz =
Thread.currentThread().getContextClassLoader().loadClass("com.sun.faces.portlet.FacesContextFactoryImpl");
+ facesContextFactory = (FacesContextFactory) clazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ else if
(metaBridge.getPortletClassName().equals(JSFMetaBridge.MYFACES_JSF.getPortletClassName()))
+ {
+ Class clazz;
+ try
+ {
+ clazz =
Thread.currentThread().getContextClassLoader().loadClass("org.apache.myfaces.context.FacesContextFactoryImpl");
+ facesContextFactory = (FacesContextFactory) clazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+ }
+
+ public FacesContext getFacesContext(Object context, Object request, Object response,
Lifecycle lifecycle) throws FacesException
+ {
+ return facesContextFactory.getFacesContext(context, request, response, lifecycle);
+ }
+
+}
Added:
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeLifecycleFactoryImpl.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeLifecycleFactoryImpl.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeLifecycleFactoryImpl.java 2007-06-21
08:53:27 UTC (rev 7499)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.portlet;
+
+import java.util.Iterator;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFMetaBridgeLifecycleFactoryImpl extends LifecycleFactory
+{
+
+ private LifecycleFactory lifecycleFactory;
+
+ public JSFMetaBridgeLifecycleFactoryImpl()
+ {
+ JSFMetaBridge metaBridge = JSFMetaBridgeFactory.getMetaBridge();
+ if
(metaBridge.getPortletClassName().equals(JSFMetaBridge.SUN_JSF.getPortletClassName()))
+ {
+ Class clazz;
+ try
+ {
+ clazz =
Thread.currentThread().getContextClassLoader().loadClass("com.sun.faces.portlet.LifecycleFactoryImpl");
+ lifecycleFactory = (LifecycleFactory) clazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ else if
(metaBridge.getPortletClassName().equals(JSFMetaBridge.MYFACES_JSF.getPortletClassName()))
+ {
+ Class clazz;
+ try
+ {
+ clazz =
Thread.currentThread().getContextClassLoader().loadClass("org.apache.myfaces.lifecycle.LifecycleFactoryImpl");
+ lifecycleFactory = (LifecycleFactory) clazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+ }
+
+ public void addLifecycle(String lifecycleId, Lifecycle lifecycle)
+ {
+ lifecycleFactory.addLifecycle(lifecycleId, lifecycle);
+
+ }
+
+ public Lifecycle getLifecycle(String lifecycleId)
+ {
+ return lifecycleFactory.getLifecycle(lifecycleId);
+ }
+
+ public Iterator getLifecycleIds()
+ {
+ return lifecycleFactory.getLifecycleIds();
+ }
+
+}
Added:
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeViewHandlerImpl.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeViewHandlerImpl.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/portlet/JSFMetaBridgeViewHandlerImpl.java 2007-06-21
08:53:27 UTC (rev 7499)
@@ -0,0 +1,153 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.portlet;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Locale;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFMetaBridgeViewHandlerImpl extends ViewHandler
+{
+
+ private ViewHandler viewHandler;
+
+ public JSFMetaBridgeViewHandlerImpl()
+ {
+ JSFMetaBridge metaBridge = JSFMetaBridgeFactory.getMetaBridge();
+ if
(metaBridge.getPortletClassName().equals(JSFMetaBridge.SUN_JSF.getPortletClassName()))
+ {
+ Application application = ((ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ ViewHandler oldViewHandler = application.getViewHandler();
+
+ Class clazz;
+ try
+ {
+ Class[] parameterTypes = new Class[] { ViewHandler.class };
+ clazz =
Thread.currentThread().getContextClassLoader().loadClass("com.sun.faces.portlet.ViewHandlerImpl");
+ Constructor constructor = clazz.getConstructor(parameterTypes);
+ viewHandler = (ViewHandler) constructor.newInstance(new Object[] {
oldViewHandler });
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ else if
(metaBridge.getPortletClassName().equals(JSFMetaBridge.MYFACES_JSF.getPortletClassName()))
+ {
+ Application application = ((ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY)).getApplication();
+ viewHandler = application.getViewHandler();
+/*
+ Class clazz;
+ try
+ {
+ clazz =
Thread.currentThread().getContextClassLoader().loadClass("org.apache.myfaces.application.jsp.JspViewHandlerImpl");
+ viewHandler = (ViewHandler) clazz.newInstance();
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+*/
+ }
+
+
+ }
+
+ public Locale calculateLocale(FacesContext context)
+ {
+ return viewHandler.calculateLocale(context);
+ }
+
+ public String calculateRenderKitId(FacesContext context)
+ {
+ return viewHandler.calculateRenderKitId(context);
+ }
+
+ public UIViewRoot createView(FacesContext context, String viewId)
+ {
+ return viewHandler.createView(context, viewId);
+ }
+
+ public String getActionURL(FacesContext context, String viewId)
+ {
+ return viewHandler.getActionURL(context, viewId);
+ }
+
+ public String getResourceURL(FacesContext context, String path)
+ {
+ return viewHandler.getResourceURL(context, path);
+ }
+
+ public void renderView(FacesContext context, UIViewRoot viewToRender) throws
IOException, FacesException
+ {
+ viewHandler.renderView(context, viewToRender);
+ }
+
+ public UIViewRoot restoreView(FacesContext context, String viewId)
+ {
+ return viewHandler.restoreView(context, viewId);
+ }
+
+ public void writeState(FacesContext context) throws IOException
+ {
+ viewHandler.writeState(context);
+
+ }
+
+}
Added: trunk/faces/src/resources/portal-faces-lib-jar/META-INF/faces-config.xml
===================================================================
--- trunk/faces/src/resources/portal-faces-lib-jar/META-INF/faces-config.xml
(rev 0)
+++ trunk/faces/src/resources/portal-faces-lib-jar/META-INF/faces-config.xml 2007-06-21
08:53:27 UTC (rev 7499)
@@ -0,0 +1,70 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+ The contents of this file are subject to the terms
+ of the Common Development and Distribution License
+ (the License). You may not use this file except in
+ compliance with the License.
+
+ You can obtain a copy of the License at
+
https://javaserverfaces.dev.java.net/CDDL.html or
+ legal/CDDLv1.0.txt.
+ See the License for the specific language governing
+ permission and limitations under the License.
+
+ When distributing Covered Code, include this CDDL
+ Header Notice in each file and include the License file
+ at legal/CDDLv1.0.txt.
+ If applicable, add the following below the CDDL Header,
+ with the fields enclosed by brackets [] replaced by
+ your own identifying information:
+ "Portions Copyrighted [year] [name of copyright owner]"
+
+ [Name of File] [ver.__] [Date]
+
+ Copyright 2006 Sun Microsystems Inc. All Rights Reserved
+-->
+
+<!DOCTYPE faces-config PUBLIC
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+
+<faces-config>
+
+
+ <!-- Install Replacement Factory Objects -->
+ <factory>
+ <faces-context-factory>
+ org.jboss.portal.faces.portlet.JSFMetaBridgeFacesContextFactoryImpl
+ </faces-context-factory>
+ <lifecycle-factory>
+ org.jboss.portal.faces.portlet.JSFMetaBridgeLifecycleFactoryImpl
+ </lifecycle-factory>
+ </factory>
+
+ <!-- Install Replacement Application Objects -->
+ <application>
+ <view-handler>
+ org.jboss.portal.faces.portlet.JSFMetaBridgeViewHandlerImpl
+ </view-handler>
+ </application>
+
+
+ <component>
+ <component-type>PortletComponent</component-type>
+
<component-class>com.sun.faces.portlet.PortletComponent</component-class>
+ <property>
+ <description>
+ ValueBinding Expression which evaluates to a PortletId for the Portlet
+ </description>
+ <property-name>portletId</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <component-extension>
+ <component-family>PortletComponent</component-family>
+ </component-extension>
+
+ </component>
+</faces-config>