geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1135403 - in /geronimo/server/trunk/plugins/myfaces: ./ geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/ geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ geronimo-myfaces/src/main/java/org/apache/ge...
Date Tue, 14 Jun 2011 08:18:38 GMT
Author: xuhaihong
Date: Tue Jun 14 08:18:38 2011
New Revision: 1135403

URL: http://svn.apache.org/viewvc?rev=1135403&view=rev
Log:
GERONIMO-6006 Upgrade MyFaces to 2.0.7
The most change is to use one LifecycleProviderFactory for each web application, as MyFaces
will not use a static variable to host it in the LifeccyleProviderFactory

Added:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoLifecycleProviderFactory.java
      - copied, changed from r1135037, geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ApplicationIndexedLifecycleProviderFactory.java
Removed:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ApplicationIndexedLifecycleProviderFactory.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderFactoryGBean.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderFactorySource.java
Modified:
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderGBean.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoStartupServletContextListener.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
    geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/test/java/org/apache/geronimo/myfaces/BasicTest.java
    geronimo/server/trunk/plugins/myfaces/myfaces-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/myfaces/pom.xml

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
Tue Jun 14 08:18:38 2011
@@ -48,7 +48,6 @@ import org.apache.geronimo.common.Deploy
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
@@ -108,8 +107,6 @@ public class MyFacesModuleBuilderExtensi
 
     private final Environment defaultEnvironment;
 
-    private final AbstractNameQuery providerFactoryNameQuery;
-
     private final NamingBuilder namingBuilders;
 
     private static final String CONTEXT_LISTENER_NAME = GeronimoStartupServletContextListener.class.getName();
@@ -137,10 +134,8 @@ public class MyFacesModuleBuilderExtensi
     };
 
     public MyFacesModuleBuilderExtension(@ParamAttribute(name = "defaultEnvironment") Environment
defaultEnvironment,
-            @ParamAttribute(name = "providerFactoryNameQuery") AbstractNameQuery providerFactoryNameQuery,
             @ParamReference(name = "NamingBuilders", namingType = NameFactory.MODULE_BUILDER)
NamingBuilder namingBuilders) {
         this.defaultEnvironment = defaultEnvironment;
-        this.providerFactoryNameQuery = providerFactoryNameQuery;
         this.namingBuilders = namingBuilders;
         this.standardFacesConfig = getStandardFacesConfig();
     }
@@ -304,7 +299,6 @@ public class MyFacesModuleBuilderExtensi
         GBeanData providerData = new GBeanData(providerName, LifecycleProviderGBean.class);
         providerData.setAttribute("holder", holder);
         providerData.setReferencePatterns("ContextSource", webAppData.getReferencePatterns("ContextSource"));
-        providerData.setReferencePattern("LifecycleProviderFactory", providerFactoryNameQuery);
         try {
             moduleContext.addGBean(providerData);
             moduleContext.addGBean(myFacesWebAppContextData);
@@ -312,9 +306,10 @@ public class MyFacesModuleBuilderExtensi
             throw new DeploymentException("Duplicate jsf config gbean in web module", e);
         }
 
+        myFacesWebAppContextData.setReferencePattern("LifecycleProvider", providerName);
         //make the web app start second after the injection machinery
         webAppData.addDependency(providerName);
-
+        webAppData.addDependency(myFacesWebAppContextName);
     }
 
     protected FacesConfig getJSFAnnotationFacesConfig(EARContext earContext, Module module,
Bundle bundle, Set<ConfigurationResource> metaInfConfigurationResources) throws DeploymentException
{

Copied: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoLifecycleProviderFactory.java
(from r1135037, geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ApplicationIndexedLifecycleProviderFactory.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoLifecycleProviderFactory.java?p2=geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoLifecycleProviderFactory.java&p1=geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ApplicationIndexedLifecycleProviderFactory.java&r1=1135037&r2=1135403&rev=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/ApplicationIndexedLifecycleProviderFactory.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/GeronimoLifecycleProviderFactory.java
Tue Jun 14 08:18:38 2011
@@ -19,30 +19,32 @@
 
 package org.apache.geronimo.myfaces;
 
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
 import javax.faces.context.ExternalContext;
 
-import org.apache.xbean.osgi.bundle.util.BundleUtils;
+import org.apache.geronimo.myfaces.webapp.MyFacesWebAppContext;
+import org.apache.geronimo.web.WebApplicationConstants;
 import org.apache.myfaces.config.annotation.LifecycleProvider;
 import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
+import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ApplicationIndexedLifecycleProviderFactory extends LifecycleProviderFactory
{
+public class GeronimoLifecycleProviderFactory extends LifecycleProviderFactory {
 
-    private final Map<Bundle, LifecycleProvider> providers = new ConcurrentHashMap<Bundle,
LifecycleProvider>();
+    private LifecycleProvider lifecycleProvider;
 
     public LifecycleProvider getLifecycleProvider(ExternalContext externalContext) {
-        Bundle bundle = getBundle();
-        LifecycleProvider provider = providers.get(bundle);
-        if (provider == null) {
-            throw new IllegalStateException("No LifecycleProvider registered for application
bundle: " + bundle);
+        if (lifecycleProvider == null) {
+            String webModuleName = (String) externalContext.getApplicationMap().get(WebApplicationConstants.WEB_APP_NAME);
+            MyFacesWebAppContext myFacesWebAppContext = MyFacesWebAppContext.getMyFacesWebAppContext(webModuleName);
+            lifecycleProvider = myFacesWebAppContext.getLifecycleProvider();
+            if (lifecycleProvider == null) {
+                throw new IllegalStateException("No LifecycleProvider registered for application
" + webModuleName + " in the bundle: " + getBundle());
+            }
         }
-        return provider;
+        return lifecycleProvider;
     }
 
     private Bundle getBundle() {
@@ -52,25 +54,9 @@ public class ApplicationIndexedLifecycle
         }
         return bundle;
     }
-    
-    /**
-     * Register a lifecycle provider for an application classloader.  This method is intended
to be called
-     * by the container in which MyFaces is running, once for each application, during application
startup before
-     * any other myfaces initialization has taken place.
-     *
-     * @param cl       application classloader, used to index LifecycleProviders
-     * @param provider LifecycleProvider for the application.
-     */
-    public void registerLifecycleProvider(Bundle bundle, LifecycleProvider provider) {
-        providers.put(bundle, provider);
-    }
-
-    public void unregisterLifecycleProvider(Bundle bundle) {
-        providers.remove(bundle);
-    }
 
+    @Override
     public void release() {
-        providers.clear();
+        lifecycleProvider = null;
     }
-
 }

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderGBean.java?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderGBean.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderGBean.java
Tue Jun 14 08:18:38 2011
@@ -21,11 +21,9 @@ package org.apache.geronimo.myfaces;
 
 import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
-
 import javax.naming.Context;
 import javax.naming.NamingException;
 
-import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
@@ -42,23 +40,20 @@ import org.osgi.framework.Bundle;
  * @version $Rev$ $Date$
  */
 @GBean
-public class LifecycleProviderGBean implements LifecycleProvider, GBeanLifecycle {
+public class LifecycleProviderGBean implements LifecycleProvider {
 
     private final Holder holder;
     private final Context context;
-    private final ApplicationIndexedLifecycleProviderFactory factory;
     private final ClassLoader classLoader;
     private final Bundle bundle;
 
     public LifecycleProviderGBean(@ParamAttribute(name="holder") Holder holder,
                                   @ParamReference(name="ContextSource", namingType = "Context")
ContextSource contextSource,
-                                  @ParamReference(name="LifecycleProviderFactory") LifecycleProviderFactorySource
factory,
                                   @ParamSpecial(type = SpecialAttributeType.kernel)Kernel
kernel,
                                   @ParamSpecial(type = SpecialAttributeType.bundle)Bundle
bundle,
                                   @ParamSpecial(type=SpecialAttributeType.classLoader)ClassLoader
classLoader) throws NamingException {
         this.holder = holder;
         context = contextSource.getContext();
-        this.factory = factory.getLifecycleProviderFactory();
         this.bundle = bundle;
         this.classLoader = classLoader;
     }
@@ -79,17 +74,4 @@ public class LifecycleProviderGBean impl
             }
         }
     }
-
-    public void doStart() {
-        factory.registerLifecycleProvider(bundle, this);
-    }
-
-    public void doStop() {
-        factory.unregisterLifecycleProvider(bundle);
-    }
-
-    public void doFail() {
-        doStop();
-    }
-
 }

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoStartupServletContextListener.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoStartupServletContextListener.java?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoStartupServletContextListener.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoStartupServletContextListener.java
Tue Jun 14 08:18:38 2011
@@ -20,11 +20,13 @@ package org.apache.geronimo.myfaces.weba
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 
+import org.apache.geronimo.myfaces.GeronimoLifecycleProviderFactory;
 import org.apache.geronimo.myfaces.facelet.GeronimoFaceletConfigResourceProviderFactory;
 import org.apache.geronimo.myfaces.info.GeronimoFacesConfigurationMergerFactory;
 import org.apache.geronimo.osgi.web.WABApplicationConstants;
 import org.apache.geronimo.web.WebApplicationConstants;
 import org.apache.geronimo.web.info.WebAppInfo;
+import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
 import org.apache.myfaces.shared_impl.webapp.webxml.WebXml;
 import org.apache.myfaces.spi.FaceletConfigResourceProviderFactory;
 import org.apache.myfaces.spi.FacesConfigurationMergerFactory;
@@ -47,6 +49,7 @@ public class GeronimoStartupServletConte
         servletContext.setAttribute(WebXml.class.getName(), webXml);
         servletContext.setAttribute(FacesConfigurationMergerFactory.class.getName(), new
GeronimoFacesConfigurationMergerFactory());
         servletContext.setAttribute(FaceletConfigResourceProviderFactory.class.getName(),
new GeronimoFaceletConfigResourceProviderFactory());
+        servletContext.setAttribute(LifecycleProviderFactory.class.getName(), new GeronimoLifecycleProviderFactory());
         super.contextInitialized(servletContextEvent);
     }
 }

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
Tue Jun 14 08:18:38 2011
@@ -29,11 +29,13 @@ import org.apache.geronimo.gbean.Abstrac
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.myfaces.config.resource.ConfigurationResource;
 import org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
+import org.apache.myfaces.config.annotation.LifecycleProvider;
 import org.apache.myfaces.config.element.FacesConfigData;
 import org.apache.xbean.osgi.bundle.util.BundleUtils;
 import org.osgi.framework.Bundle;
@@ -61,8 +63,11 @@ public class MyFacesWebAppContext implem
 
     private AbstractName abName;
 
+    private LifecycleProvider lifecycleProvider;
+
     public MyFacesWebAppContext(@ParamAttribute(name = "facesConfigData") FacesConfigData
facesConfigData,
             @ParamAttribute(name = "faceletConfigResources") Set<ConfigurationResource>
faceletConfigResources,
+            @ParamReference(name = "LifecycleProvider") LifecycleProvider lifecycleProvider,
             @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
             @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
             @ParamSpecial(type = SpecialAttributeType.abstractName) AbstractName abName)
{
@@ -70,6 +75,8 @@ public class MyFacesWebAppContext implem
         this.facesConfigData = facesConfigData;
         this.classLoader = classLoader;
         this.abName = abName;
+        this.lifecycleProvider = lifecycleProvider;
+
         ServiceReference serviceReference = null;
         this.faceletConfigResources = new ArrayList<URL>(faceletConfigResources.size());
         try {
@@ -108,6 +115,10 @@ public class MyFacesWebAppContext implem
         return faceletConfigResources;
     }
 
+    public LifecycleProvider getLifecycleProvider() {
+        return lifecycleProvider;
+    }
+
     @Override
     public void doFail() {
         try {

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/test/java/org/apache/geronimo/myfaces/BasicTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/test/java/org/apache/geronimo/myfaces/BasicTest.java?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/test/java/org/apache/geronimo/myfaces/BasicTest.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/test/java/org/apache/geronimo/myfaces/BasicTest.java
Tue Jun 14 08:18:38 2011
@@ -28,8 +28,5 @@ import junit.framework.TestCase;
 public class BasicTest extends TestCase {
 
     public void testLifecycleProviderFactory() throws Exception {
-        LifecycleProviderFactoryGBean factory = new LifecycleProviderFactoryGBean();
-        ApplicationIndexedLifecycleProviderFactory providerFactory = factory.getLifecycleProviderFactory();
-        assertNotNull(providerFactory);
     }
 }

Modified: geronimo/server/trunk/plugins/myfaces/myfaces-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/myfaces-deployer/src/main/plan/plan.xml?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/myfaces-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/myfaces-deployer/src/main/plan/plan.xml Tue Jun
14 08:18:38 2011
@@ -21,7 +21,6 @@
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
 
     <gbean name="MyFacesModuleBuilderExtension" class="org.apache.geronimo.myfaces.deployment.MyFacesModuleBuilderExtension">
-        <attribute name="providerFactoryNameQuery">?name=MyFacesLifecycleProviderFactory#org.apache.geronimo.myfaces.LifecycleProviderFactoryGBean</attribute>
         <reference name="NamingBuilders">
             <name>NamingBuilders</name>
         </reference>

Modified: geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml Tue Jun 14 08:18:38
2011
@@ -20,6 +20,4 @@
 
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
 
-    <gbean name="MyFacesLifecycleProviderFactory" class="org.apache.geronimo.myfaces.LifecycleProviderFactoryGBean"/>
-
 </module>

Modified: geronimo/server/trunk/plugins/myfaces/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/pom.xml?rev=1135403&r1=1135402&r2=1135403&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/pom.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/pom.xml Tue Jun 14 08:18:38 2011
@@ -34,7 +34,7 @@
     </description>
 
     <properties>
-        <myfacesVersion>2.0.3</myfacesVersion>
+        <myfacesVersion>2.0.7</myfacesVersion>
     </properties>
     
     <modules>



Mime
View raw message