openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1477205 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ResourceBean.java component/ResourceProvider.java portable/ProviderBasedProxyProducer.java portable/ProviderBasedProxyProducerFactory.java
Date Mon, 29 Apr 2013 17:13:56 GMT
Author: rmannibucau
Date: Mon Apr 29 17:13:20 2013
New Revision: 1477205

URL: http://svn.apache.org/r1477205
Log:
OWB-850 @Dependent on a produce -> no proxy should be created

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceProvider.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducerFactory.java

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=1477205&r1=1477204&r2=1477205&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
Mon Apr 29 17:13:20 2013
@@ -24,6 +24,8 @@ import org.apache.webbeans.portable.Prov
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.spi.api.ResourceReference;
 
+import javax.enterprise.context.Dependent;
+
 public class ResourceBean<X, T extends Annotation> extends ProducerFieldBean<X>
 {
     
@@ -37,7 +39,8 @@ public class ResourceBean<X, T extends A
         super(ownerComponent,
               beanAttributes,
               beanClass,
-              new ProviderBasedProxyProducerFactory<X>(new ResourceProvider<X>(resourceReference,
ownerComponent.getWebBeansContext()),
+              new ProviderBasedProxyProducerFactory<X>(Dependent.class.equals(beanAttributes.getScope()),
+                      new ResourceProvider<X>(resourceReference, ownerComponent.getWebBeansContext()),
                                                        beanClass,
                                                        ownerComponent.getWebBeansContext()));
         this.resourceReference = resourceReference;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceProvider.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceProvider.java?rev=1477205&r1=1477204&r2=1477205&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceProvider.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceProvider.java
Mon Apr 29 17:13:20 2013
@@ -18,13 +18,12 @@
  */
 package org.apache.webbeans.component;
 
-import javax.inject.Provider;
-
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.spi.api.ResourceReference;
 
+import javax.inject.Provider;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducer.java?rev=1477205&r1=1477204&r2=1477205&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducer.java
Mon Apr 29 17:13:20 2013
@@ -32,12 +32,14 @@ public class ProviderBasedProxyProducer<
     private Class<T> returnType;
     private Provider<T> provider;
     private T proxyInstance;
+    private boolean proxy;
 
-    public ProviderBasedProxyProducer(WebBeansContext webBeansContext, Class<T> returnType,
Provider<T> provider)
+    public ProviderBasedProxyProducer(WebBeansContext webBeansContext, Class<T> returnType,
Provider<T> provider, boolean proxy)
     {
         this.webBeansContext = webBeansContext;
         this.returnType = returnType;
         this.provider = provider;
+        this.proxy = proxy;
     }
 
     @Override
@@ -45,14 +47,21 @@ public class ProviderBasedProxyProducer<
     {
         if (proxyInstance == null)
         {
-            NormalScopeProxyFactory proxyFactory = webBeansContext.getNormalScopeProxyFactory();
-            ClassLoader loader = returnType.getClassLoader();
-            if (loader == null)
+            if (proxy)
             {
-                loader = WebBeansUtil.getCurrentClassLoader();
+                NormalScopeProxyFactory proxyFactory = webBeansContext.getNormalScopeProxyFactory();
+                ClassLoader loader = returnType.getClassLoader();
+                if (loader == null)
+                {
+                    loader = WebBeansUtil.getCurrentClassLoader();
+                }
+                Class<T> proxyClass = proxyFactory.createProxyClass(loader, returnType);
+                proxyInstance = proxyFactory.createProxyInstance(proxyClass, provider);
+            }
+            else
+            {
+                proxyInstance = provider.get();
             }
-            Class<T> proxyClass = proxyFactory.createProxyClass(loader, returnType);
-            proxyInstance = proxyFactory.createProxyInstance(proxyClass, provider);
         }
         return proxyInstance;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducerFactory.java?rev=1477205&r1=1477204&r2=1477205&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducerFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducerFactory.java
Mon Apr 29 17:13:20 2013
@@ -32,8 +32,9 @@ public class ProviderBasedProxyProducerF
     private Provider<?> provider;
     private Class<?> providerType;
     private WebBeansContext webBeansContext;
+    private boolean proxy;
     
-    public ProviderBasedProxyProducerFactory(Provider<?> provider, Class<?> providerType,
WebBeansContext context)
+    public ProviderBasedProxyProducerFactory(boolean proxy, Provider<?> provider, Class<?>
providerType, WebBeansContext context)
     {
         Asserts.assertNotNull(provider);
         Asserts.assertNotNull(providerType);
@@ -41,11 +42,12 @@ public class ProviderBasedProxyProducerF
         this.provider = provider;
         this.providerType = providerType;
         this.webBeansContext = context;
+        this.proxy = proxy;
     }
 
     @Override
     public <T> Producer<T> createProducer(Bean<T> bean)
     {
-        return new ProviderBasedProxyProducer<T>(webBeansContext, (Class<T>)providerType,
(Provider<T>)provider);
+        return new ProviderBasedProxyProducer<T>(webBeansContext, (Class<T>)providerType,
(Provider<T>)provider, proxy);
     }
 }



Mime
View raw message