geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r906232 - in /geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces: ApplicationIndexedLifecycleProviderFactory.java LifecycleProviderFactoryGBean.java LifecycleProviderGBean.java
Date Wed, 03 Feb 2010 20:41:51 GMT
Author: gawor
Date: Wed Feb  3 20:41:51 2010
New Revision: 906232

URL: http://svn.apache.org/viewvc?rev=906232&view=rev
Log:
GERONIMO-4996: Lookup LifecycleProvider based on Bundle instead of ClassLoader. ClassLoaders
even for the same Bundle might be different objects.

Modified:
    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/LifecycleProviderGBean.java

Modified: 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/ApplicationIndexedLifecycleProviderFactory.java?rev=906232&r1=906231&r2=906232&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/ApplicationIndexedLifecycleProviderFactory.java
Wed Feb  3 20:41:51 2010
@@ -17,7 +17,6 @@
  * under the License.
  */
 
-
 package org.apache.geronimo.myfaces;
 
 import java.util.Map;
@@ -25,25 +24,35 @@
 
 import javax.faces.context.ExternalContext;
 
+import org.apache.geronimo.kernel.osgi.BundleUtils;
 import org.apache.myfaces.config.annotation.LifecycleProvider;
 import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ApplicationIndexedLifecycleProviderFactory extends LifecycleProviderFactory
{
 
-    private final Map<ClassLoader, LifecycleProvider> providers = new ConcurrentHashMap<ClassLoader,
LifecycleProvider>();
+    private final Map<Bundle, LifecycleProvider> providers = new ConcurrentHashMap<Bundle,
LifecycleProvider>();
 
     public LifecycleProvider getLifecycleProvider(ExternalContext externalContext) {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        LifecycleProvider provider = providers.get(cl);
+        Bundle bundle = getBundle();
+        LifecycleProvider provider = providers.get(bundle);
         if (provider == null) {
-            throw new IllegalStateException("No LifecycleProvider registered for application
classloader: " + cl);
+            throw new IllegalStateException("No LifecycleProvider registered for application
bundle: " + bundle);
         }
         return provider;
     }
 
+    private Bundle getBundle() {
+        Bundle bundle = BundleUtils.getContextBundle();
+        if (bundle == null) {
+            throw new IllegalStateException("Unable to get Bundle object associated with
the context classloader");
+        }
+        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
@@ -52,12 +61,12 @@
      * @param cl       application classloader, used to index LifecycleProviders
      * @param provider LifecycleProvider for the application.
      */
-    public void registerLifecycleProvider(ClassLoader cl, LifecycleProvider provider) {
-        providers.put(cl, provider);
+    public void registerLifecycleProvider(Bundle bundle, LifecycleProvider provider) {
+        providers.put(bundle, provider);
     }
 
-    public void unregisterLifecycleProvider(ClassLoader cl) {
-        providers.remove(cl);
+    public void unregisterLifecycleProvider(Bundle bundle) {
+        providers.remove(bundle);
     }
 
     public void release() {

Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderFactoryGBean.java?rev=906232&r1=906231&r2=906232&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderFactoryGBean.java
(original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/LifecycleProviderFactoryGBean.java
Wed Feb  3 20:41:51 2010
@@ -17,13 +17,11 @@
  * under the License.
  */
 
-
 package org.apache.geronimo.myfaces;
 
 import org.apache.myfaces.config.annotation.LifecycleProviderFactory;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 
 /**
  * @version $Rev$ $Date$

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=906232&r1=906231&r2=906232&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
Wed Feb  3 20:41:51 2010
@@ -17,25 +17,26 @@
  * under the License.
  */
 
-
 package org.apache.geronimo.myfaces;
 
 import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 
-import javax.naming.NamingException;
 import javax.naming.Context;
+import javax.naming.NamingException;
 
-import org.apache.geronimo.gbean.annotation.*;
-import org.apache.myfaces.config.annotation.LifecycleProvider;
+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.annotation.Holder;
 import org.apache.geronimo.j2ee.annotation.LifecycleMethod;
 import org.apache.geronimo.j2ee.jndi.ContextSource;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
+import org.apache.myfaces.config.annotation.LifecycleProvider;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev$ $Date$
@@ -47,17 +48,18 @@
     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;
-//        GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
         context = contextSource.getContext();
         this.factory = factory.getLifecycleProviderFactory();
+        this.bundle = bundle;
         this.classLoader = classLoader;
     }
 
@@ -79,11 +81,11 @@
     }
 
     public void doStart() {
-        factory.registerLifecycleProvider(classLoader, this);
+        factory.registerLifecycleProvider(bundle, this);
     }
 
     public void doStop() {
-        factory.unregisterLifecycleProvider(classLoader);
+        factory.unregisterLifecycleProvider(bundle);
     }
 
     public void doFail() {



Mime
View raw message