openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r1055806 - in /openwebbeans/trunk/webbeans-impl/src/main: java/org/apache/webbeans/config/OpenWebBeansConfiguration.java java/org/apache/webbeans/proxy/JavassistProxyFactory.java resources/META-INF/openwebbeans/openwebbeans.properties
Date Thu, 06 Jan 2011 09:42:14 GMT
Author: gerdogdu
Date: Thu Jan  6 09:42:14 2011
New Revision: 1055806

URL: http://svn.apache.org/viewvc?rev=1055806&view=rev
Log:
[OWB-496], adding flag for updating javassist classloader provider. Default to false therefore
current sitation has not chaged

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1055806&r1=1055805&r2=1055806&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
Thu Jan  6 09:42:14 2011
@@ -110,6 +110,8 @@ public class OpenWebBeansConfiguration
     public static final String EL_ADAPTOR_CLASS = "org.apache.webbeans.spi.adaptor.ELAdaptor";
     
     public static final String PROPERTY_OWB_APPLICATION = "org.apache.webbeans.application.isOwbApplication";
+    
+    public static final String USE_JAVASSIST_CLASSLOADERPROVIDER = "org.apache.webbeans.javassist.useClassLoaderProvider";
 
     /**
      * Use BDABeansXmlScanner to determine if interceptors, decorators, and
@@ -323,4 +325,17 @@ public class OpenWebBeansConfiguration
         
         return Boolean.valueOf(value);
     }
+    
+    /**
+     * Gets flag for updating Javasisst ProxyFactory.classLoaderProvider
+     * @return true if use javassist ProxyFactory.classLoaderProvider
+     * update if exception occurn on ProxyFactory.createClass
+     */
+    public boolean isUpdateJavassistClassLoaderProvider()
+    {
+        String value = getProperty(USE_JAVASSIST_CLASSLOADERPROVIDER);
+        
+        return Boolean.valueOf(value);
+    }
+    
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=1055806&r1=1055805&r2=1055806&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
Thu Jan  6 09:42:14 2011
@@ -35,6 +35,7 @@ import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.Decorator;
 
 import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyFactory.ClassLoaderProvider;
 import javassist.util.proxy.ProxyObject;
 import org.apache.webbeans.annotation.WebBeansAnnotation;
 import org.apache.webbeans.component.InjectionTargetBean;
@@ -309,7 +310,43 @@ public final class JavassistProxyFactory
 
     public  Class<?> getProxyClass(ProxyFactory factory)
     {
-        return SecurityUtil.doPrivilegedCreateClass(factory);
+        ClassLoaderProvider oldProvider = ProxyFactory.classLoaderProvider;
+        Class<?> clazz = null;
+        try
+        {
+            clazz = SecurityUtil.doPrivilegedCreateClass(factory);            
+        }
+        catch(RuntimeException e)
+        {
+            //Default is false
+            if(WebBeansContext.getInstance().getOpenWebBeansConfiguration().isUpdateJavassistClassLoaderProvider())
+            {                   
+                //Try thread class loader
+                ProxyFactory.classLoaderProvider = new ProxyFactory.ClassLoaderProvider()
+                {                            
+                    @Override
+                    public ClassLoader get(ProxyFactory pf)
+                    {
+                        return WebBeansUtil.getCurrentClassLoader();
+                    }
+                };
+                
+                //try again with updated class loader
+                clazz = SecurityUtil.doPrivilegedCreateClass(factory);  
+            }
+            else
+            {
+                //Default, throw exception
+                throw e;
+            }
+        }
+        finally
+        {
+            //Switch to old
+            ProxyFactory.classLoaderProvider = oldProvider;            
+        }
+        
+        return clazz; 
     }
     
     public  ProxyFactory createProxyFactory(Bean<?> bean) throws Exception

Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1055806&r1=1055805&r2=1055806&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Thu Jan  6 09:42:14 2011
@@ -104,3 +104,10 @@ org.apache.webbeans.application.supports
 # of the appropriate archive.
 org.apache.webbeans.useBDABeansXMLScanner=false
 ################################################################################################
+
+####################### Proxy Factory Class Loader Update ######################################
+# If true, ProxyFactory.classLoaderProvider will be updates on ClassNotFoundException, 
+# default to false
+org.apache.webbeans.javassist.useClassLoaderProvider=false
+################################################################################################
+



Mime
View raw message