openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r962953 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-imp...
Date Sun, 11 Jul 2010 00:24:21 GMT
Author: gerdogdu
Date: Sun Jul 11 00:24:20 2010
New Revision: 962953

URL: http://svn.apache.org/viewvc?rev=962953&view=rev
Log:
OWB-405 refactored JavassistProxyFactory from static maps to singletons

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbDefinitionUtility.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
Sun Jul 11 00:24:20 2010
@@ -503,12 +503,12 @@ public class OpenWebBeansEjbInterceptor
 
             if (injectionTarget.getDecoratorStack().size() > 0)
             {
-                Class<?> proxyClass = JavassistProxyFactory.getInterceptorProxyClasses().get(injectionTarget);
+                Class<?> proxyClass = JavassistProxyFactory.getInstance().getInterceptorProxyClasses().get(injectionTarget);
                 if (proxyClass == null)
                 {
-                    ProxyFactory delegateFactory = JavassistProxyFactory.createProxyFactory(injectionTarget);
-                    proxyClass = JavassistProxyFactory.getProxyClass(delegateFactory);
-                    JavassistProxyFactory.getInterceptorProxyClasses().put(injectionTarget,
proxyClass);
+                    ProxyFactory delegateFactory = JavassistProxyFactory.getInstance().createProxyFactory(injectionTarget);
+                    proxyClass = JavassistProxyFactory.getInstance().getProxyClass(delegateFactory);
+                    JavassistProxyFactory.getInstance().getInterceptorProxyClasses().put(injectionTarget,
proxyClass);
                 }
                 Object delegate = proxyClass.newInstance();
                 delegateHandler = new DelegateHandler(threadLocal.get(),ejbContext);

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbDefinitionUtility.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbDefinitionUtility.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbDefinitionUtility.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbDefinitionUtility.java
Sun Jul 11 00:24:20 2010
@@ -52,7 +52,7 @@ public final class EjbDefinitionUtility
         {
             bean.setIface(iface);
             
-            Class<?> clazz = JavassistProxyFactory.getEjbBeanProxyClass(bean);
+            Class<?> clazz = JavassistProxyFactory.getInstance().getEjbBeanProxyClass(bean);
             if(clazz != null)
             {
                 return (T)clazz.newInstance();
@@ -65,7 +65,7 @@ public final class EjbDefinitionUtility
             factory.setHandler(handler);
             factory.setInterfaces(new Class[]{iface});
          
-            return (T)(JavassistProxyFactory.defineEjbBeanProxyClass(bean, factory).newInstance());
+            return (T)(JavassistProxyFactory.getInstance().defineEjbBeanProxyClass(bean,
factory).newInstance());
             
         }
         catch(Exception e)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
Sun Jul 11 00:24:20 2010
@@ -140,7 +140,7 @@ public abstract class AbstractInjectionT
         boolean isDependentProxy = false;
         if(getScope() == Dependent.class && !(this instanceof EnterpriseBeanMarker))
         {
-            T result = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this, instance,
creationalContext);
+            T result = (T)JavassistProxyFactory.getInstance().createDependentScopedBeanProxy(this,
instance, creationalContext);
             //Means that Dependent Bean has interceptor/decorator
             if(JavassistProxyFactory.isProxyInstance(result))
             {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
Sun Jul 11 00:24:20 2010
@@ -54,13 +54,13 @@ public class ResourceBean<X, T extends A
         try
         {
             //X TODO cache proxy class!
-            ProxyFactory proxyFactory = JavassistProxyFactory.createProxyFactory(this);
+            ProxyFactory proxyFactory = JavassistProxyFactory.getInstance().createProxyFactory(this);
             
             ResourceInjectionService resourceService = ServiceLoader.getService(ResourceInjectionService.class);
             this.actualResourceReference = resourceService.getResourceReference(this.resourceReference);
             proxyFactory.setHandler(new ResourceProxyHandler(this.actualResourceReference));
             
-            instance = (X)(JavassistProxyFactory.getProxyClass(proxyFactory).newInstance());
+            instance = (X)(JavassistProxyFactory.getInstance().getProxyClass(proxyFactory).newInstance());
         }
         catch (Exception e)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Sun Jul 11 00:24:20 2010
@@ -809,7 +809,7 @@ public class BeanManagerImpl implements 
             }
             
             //Create Managed Bean Proxy
-            instance = JavassistProxyFactory.createNormalScopedBeanProxy((AbstractOwbBean<?>)bean,creationalContext);
+            instance = JavassistProxyFactory.getInstance().createNormalScopedBeanProxy((AbstractOwbBean<?>)bean,creationalContext);
             
         }
         //Create Pseudo-Scope Bean Instance

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
Sun Jul 11 00:24:20 2010
@@ -348,7 +348,7 @@ public class WebBeansDecorator<T> extend
         
         Context context = BeanManagerImpl.getManager().getContext(getScope());
         Object actualInstance = context.get((Bean<Object>)this.wrappedBean, (CreationalContext<Object>)creationalContext);
-        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.wrappedBean,
actualInstance, creationalContext);
+        T proxy = (T)JavassistProxyFactory.getInstance().createDependentScopedBeanProxy(this.wrappedBean,
actualInstance, creationalContext);
         
         return proxy;        
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Sun Jul 11 00:24:20 2010
@@ -203,12 +203,12 @@ public abstract class InterceptorHandler
                     List<Object> decorators = null;
                     if (injectionTarget.getDecoratorStack().size() > 0)
                     {
-                        Class<?> proxyClass = JavassistProxyFactory.getInterceptorProxyClasses().get(bean);
+                        Class<?> proxyClass = JavassistProxyFactory.getInstance().getInterceptorProxyClasses().get(bean);
                         if (proxyClass == null)
                         {
-                            ProxyFactory delegateFactory = JavassistProxyFactory.createProxyFactory(bean);
-                            proxyClass = JavassistProxyFactory.getProxyClass(delegateFactory);
-                            JavassistProxyFactory.getInterceptorProxyClasses().put(bean,
proxyClass);
+                            ProxyFactory delegateFactory = JavassistProxyFactory.getInstance().createProxyFactory(bean);
+                            proxyClass = JavassistProxyFactory.getInstance().getProxyClass(delegateFactory);
+                            JavassistProxyFactory.getInstance().getInterceptorProxyClasses().put(bean,
proxyClass);
                         }
                         Object delegate = proxyClass.newInstance();
                         delegateHandler = new DelegateHandler(this.bean);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Sun Jul 11 00:24:20 2010
@@ -295,7 +295,7 @@ public class WebBeansInterceptor<T> exte
     {
         Context context = BeanManagerImpl.getManager().getContext(getScope());
         Object actualInstance = context.get((Bean<Object>)this.delegateBean, (CreationalContext<Object>)creationalContext);
-        T proxy = (T)JavassistProxyFactory.createDependentScopedBeanProxy(this.delegateBean,
actualInstance, creationalContext);
+        T proxy = (T)JavassistProxyFactory.getInstance().createDependentScopedBeanProxy(this.delegateBean,
actualInstance, creationalContext);
         
         return proxy;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
Sun Jul 11 00:24:20 2010
@@ -157,7 +157,7 @@ public abstract class AbstractLifeCycle 
             InjectionResolver.getInstance().clearCaches();
             
             //Delte proxies
-            JavassistProxyFactory.clear();
+            JavassistProxyFactory.getInstance().clear();
             
             //Delete AnnotateTypeCache
             AnnotatedElementFactory.getInstance().clear();

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=962953&r1=962952&r2=962953&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
Sun Jul 11 00:24:20 2010
@@ -39,6 +39,7 @@ import javax.enterprise.inject.spi.Decor
 import org.apache.webbeans.annotation.WebBeansAnnotation;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.OwbBean;
+import org.apache.webbeans.config.WebBeansFinder;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.AbstractDecoratorMethodHandler;
 import org.apache.webbeans.decorator.WebBeansDecorator;
@@ -58,20 +59,27 @@ public final class JavassistProxyFactory
 
     }
     
-    private static Map<OwbBean<?>, Class<?>> normalScopedBeanProxyClasses
= new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private  Map<OwbBean<?>, Class<?>> normalScopedBeanProxyClasses = new
ConcurrentHashMap<OwbBean<?>, Class<?>>();
     
-    private static Map<OwbBean<?>, Class<?>> dependentScopedBeanProxyClasses
= new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private  Map<OwbBean<?>, Class<?>> dependentScopedBeanProxyClasses
= new ConcurrentHashMap<OwbBean<?>, Class<?>>();
     
-    private static Map<OwbBean<?>, Class<?>> interceptorProxyClasses =
new ConcurrentHashMap<OwbBean<?>, Class<?>>();
+    private  Map<OwbBean<?>, Class<?>> interceptorProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();
     
-    private static Map<OwbBean<?>, Class<?>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();
+    private  Map<OwbBean<?>, Class<?>> ejbProxyClasses = new ConcurrentHashMap<OwbBean<?>,
Class<?>>();
     
-    public static  Map<OwbBean<?>, Class<?>> getInterceptorProxyClasses()
+    public   Map<OwbBean<?>, Class<?>> getInterceptorProxyClasses()
     {
         return interceptorProxyClasses;
     }
     
-    public static void clear()
+    public static JavassistProxyFactory getInstance()
+    {
+        JavassistProxyFactory aef = (JavassistProxyFactory) WebBeansFinder.getSingletonInstance(JavassistProxyFactory.class.getName());
+        return aef;
+    }
+    
+    
+    public void clear()
     {
         normalScopedBeanProxyClasses.clear();
         dependentScopedBeanProxyClasses.clear();
@@ -79,12 +87,12 @@ public final class JavassistProxyFactory
         ejbProxyClasses.clear();
     }
     
-    public static Class<?> getEjbBeanProxyClass(OwbBean<?> bean)
+    public  Class<?> getEjbBeanProxyClass(OwbBean<?> bean)
     {
         return ejbProxyClasses.get(bean);
     }
     
-    public static Class<?> defineEjbBeanProxyClass(OwbBean<?> bean, ProxyFactory
factory)
+    public  Class<?> defineEjbBeanProxyClass(OwbBean<?> bean, ProxyFactory factory)
     {
         Class<?> clazz = ejbProxyClasses.get(bean);
         if(clazz != null)
@@ -100,7 +108,7 @@ public final class JavassistProxyFactory
         return clazz;
     }
     
-    public static Class<?> createAbstractDecoratorProxyClass(OwbBean<?> bean)
+    public  Class<?> createAbstractDecoratorProxyClass(OwbBean<?> bean)
     {
         //Will only get called once while defining the bean, so no need to cache
         Class<?> clazz = null;
@@ -119,7 +127,7 @@ public final class JavassistProxyFactory
         
     }
     
-    public static Object createNormalScopedBeanProxy(OwbBean<?> bean, CreationalContext<?>
creationalContext)
+    public  Object createNormalScopedBeanProxy(OwbBean<?> bean, CreationalContext<?>
creationalContext)
     {
         Object result = null;
         try
@@ -155,7 +163,7 @@ public final class JavassistProxyFactory
         return result;
     }
     
-    public static Object createDependentScopedBeanProxy(OwbBean<?> bean, Object actualInstance,
CreationalContext<?> creastionalContext)
+    public  Object createDependentScopedBeanProxy(OwbBean<?> bean, Object actualInstance,
CreationalContext<?> creastionalContext)
     {
         Object result = null;
         
@@ -242,7 +250,7 @@ public final class JavassistProxyFactory
     }
 
 
-    public static Class<?> getProxyClass(ProxyFactory factory)
+    public  Class<?> getProxyClass(ProxyFactory factory)
     {
         Class<?> proxyClass = null;
         try
@@ -268,7 +276,7 @@ public final class JavassistProxyFactory
         return proxyClass;
     }
     
-    public static ProxyFactory createProxyFactory(Bean<?> bean) throws Exception
+    public  ProxyFactory createProxyFactory(Bean<?> bean) throws Exception
     {
         Set<Type> types = bean.getTypes();
         Set<Class<?>> interfaceList = new HashSet<Class<?>>();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
Sun Jul 11 00:24:20 2010
@@ -772,7 +772,7 @@ public final class WebBeansAnnotatedType
     {
         
         ManagedBean<T> bean = defineManagedBean(type);
-        Class clazz = JavassistProxyFactory.createAbstractDecoratorProxyClass(bean);
+        Class clazz = JavassistProxyFactory.getInstance().createAbstractDecoratorProxyClass(bean);
         bean.setConstructor(WebBeansUtil.defineConstructor(clazz));
         return bean;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=962953&r1=962952&r2=962953&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sun Jul 11 00:24:20 2010
@@ -2949,7 +2949,7 @@ public final class WebBeansUtil
     {
 
         ManagedBean<T> bean = defineManagedBean(managedBeanCreator, processInjectionTargetEvent);
-        Class clazz = JavassistProxyFactory.createAbstractDecoratorProxyClass(bean);
+        Class clazz = JavassistProxyFactory.getInstance().createAbstractDecoratorProxyClass(bean);
         bean.setConstructor(WebBeansUtil.defineConstructor(clazz));
         return bean;
     }



Mime
View raw message