openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r903457 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/util/ test/java/org/apache/webbeans/test/component/ test/java/org/apache/webbeans/test/component/decorator/clean/ tes...
Date Tue, 26 Jan 2010 22:21:45 GMT
Author: gerdogdu
Date: Tue Jan 26 22:21:44 2010
New Revision: 903457

URL: http://svn.apache.org/viewvc?rev=903457&view=rev
Log:
[OWB-253] Caching of Bean Proxies

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/CheckWithCheckPayment.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/LargeTransactionDecorator.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/service/Typed2.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorTest1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/CurrentInjectedComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/TypedInjectedComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java

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=903457&r1=903456&r2=903457&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
Tue Jan 26 22:21:44 2010
@@ -705,15 +705,21 @@
             }            
             //Create Managed Bean Proxy
             else
-            {                
-                if (this.proxyMap.containsKey(bean))
+            {   
+                boolean proxyCacheable = WebBeansUtil.isProxyForScopeCachable(bean.getScope());
+                
+                if (proxyCacheable && this.proxyMap.containsKey(bean))
                 {
                     instance = this.proxyMap.get(bean);
                 }
                 else
                 {
                     instance = JavassistProxyFactory.createNormalScopedBeanProxy(bean,creationalContext);
-                    this.proxyMap.put(bean, instance);     
+                    
+                    if(proxyCacheable)
+                    {
+                        this.proxyMap.put(bean, instance);   
+                    }     
                     
                     //push this proxy instance into creational context
                     if(creationalContext instanceof CreationalContextImpl)

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=903457&r1=903456&r2=903457&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
Tue Jan 26 22:21:44 2010
@@ -2274,4 +2274,15 @@
         return false;
 
     }    
+    
+    public static boolean isProxyForScopeCachable(Class<? extends Annotation> scopeType)
+    {
+        Asserts.assertNotNull(scopeType, "Scope type is null");
+        if(scopeType.equals(ApplicationScoped.class))
+        {
+            return true;
+        }
+        
+        return false;
+    }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/CheckWithCheckPayment.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/CheckWithCheckPayment.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/CheckWithCheckPayment.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/CheckWithCheckPayment.java
Tue Jan 26 22:21:44 2010
@@ -23,10 +23,20 @@
 @Named
 public class CheckWithCheckPayment implements IPayment
 {
+    private boolean value = false;
 
     public String pay()
     {
         return "CHECK";
     }
 
+    public boolean getValue()
+    {
+        return this.value;
+    }
+    
+    public void setValue(boolean value)
+    {
+        this.value = value;
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/LargeTransactionDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/LargeTransactionDecorator.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/LargeTransactionDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/LargeTransactionDecorator.java
Tue Jan 26 22:21:44 2010
@@ -20,8 +20,7 @@
 import javax.enterprise.context.RequestScoped;
 
 @Decorator
-@RequestScoped
-public abstract class LargeTransactionDecorator implements Account
+public class LargeTransactionDecorator implements Account
 {
     @Delegate Account account;
 
@@ -55,4 +54,11 @@
         return withDrawAmount;
     }
 
+    @Override
+    public BigDecimal getBalance()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
Tue Jan 26 22:21:44 2010
@@ -23,8 +23,7 @@
 
 @Decorator
 @Named
-@RequestScoped
-public abstract class ServiceDecorator implements IService
+public  class ServiceDecorator implements IService
 {
     @Delegate @Binding1 IService delegate;
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/service/Typed2.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/service/Typed2.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/service/Typed2.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/service/Typed2.java
Tue Jan 26 22:21:44 2010
@@ -25,5 +25,23 @@
 @Binding2
 public class Typed2 implements ITyped2<String, Object>, Serializable
 {
+    private boolean value = false;
 
+    /**
+     * @return the value
+     */
+    public boolean isValue()
+    {
+        return value;
+    }
+
+    /**
+     * @param value the value to set
+     */
+    public void setValue(boolean value)
+    {
+        this.value = value;
+    }
+    
+    
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorTest1.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorTest1.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorTest1.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/DecoratorTest1.java
Tue Jan 26 22:21:44 2010
@@ -83,7 +83,7 @@
         ServiceImpl1 serviceImpl = getManager().getInstance(component);
         String s = serviceImpl.service();
 
-        Assert.assertEquals("ServiceImpl1", s);
+        Assert.assertEquals("ServiceDecorator", s);
 
         Set<Type> apiTyeps = new HashSet<Type>();
         apiTyeps.add(IService.class);
@@ -91,7 +91,7 @@
         List<Decorator<?>> decs = getManager().resolveDecorators(apiTyeps, new
Annotation[] { new Binding1Literal() });
 
         ServiceDecorator dec = (ServiceDecorator) getManager().getInstance(decs.get(0));
-        Assert.assertEquals("ServiceImpl1", dec.getDelegateAttr());
+        Assert.assertEquals(null, dec.getDelegateAttr());
 
     }
 
@@ -117,8 +117,8 @@
         List<Decorator<?>> decs = getManager().resolveDecorators(apiTyeps, new
Annotation[] { new DefaultLiteral() });
 
         LargeTransactionDecorator dec = (LargeTransactionDecorator) getManager().getInstance(decs.get(0));
-        Assert.assertEquals(new BigDecimal(1500), dec.getDepositeAmount());
-        Assert.assertEquals(new BigDecimal(3000), dec.getWithDrawAmount());
+        Assert.assertEquals(null, dec.getDepositeAmount());
+        Assert.assertEquals(null, dec.getWithDrawAmount());
 
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/CurrentInjectedComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/CurrentInjectedComponentTest.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/CurrentInjectedComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/CurrentInjectedComponentTest.java
Tue Jan 26 22:21:44 2010
@@ -72,7 +72,7 @@
 
         Object obj2 = getManager().getInstance(comps.get(1));
 
-        Assert.assertSame(i.getInstance(), obj2);
+        Assert.assertSame(i.getInstance().getTyped2(), ((CurrentBindingComponent) obj2).getTyped2());
 
         CurrentBindingComponent bc = (CurrentBindingComponent) obj2;
         ITyped2 typed2 = bc.getTyped2();

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/TypedInjectedComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/TypedInjectedComponentTest.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/TypedInjectedComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/TypedInjectedComponentTest.java
Tue Jan 26 22:21:44 2010
@@ -69,12 +69,15 @@
         Assert.assertTrue(object instanceof TypedInjection);
 
         TypedInjection i = (TypedInjection) object;
+        Typed2 typed2 = (Typed2)i.getV();
+        typed2.setValue(true);
+
 
         Assert.assertTrue(i.getV() instanceof ITyped2);
 
-        Object obj2 = getManager().getInstance(comps.get(0));
+        Typed2 obj2 = (Typed2)getManager().getInstance(comps.get(0));
 
-        Assert.assertSame(i.getV(), obj2);
+        Assert.assertSame(typed2.isValue(), obj2.isValue());
 
         ContextFactory.destroySessionContext(session);
     }
@@ -100,12 +103,14 @@
         Assert.assertTrue(object instanceof TypedInjectionWithoutArguments);
 
         TypedInjectionWithoutArguments i = (TypedInjectionWithoutArguments) object;
+        Typed2 typed2 = (Typed2)i.getV();
+        typed2.setValue(true);
 
         Assert.assertTrue(i.getV() instanceof ITyped2);
 
-        Object obj2 = getManager().getInstance(comps.get(0));
+        Typed2 obj2 = (Typed2)getManager().getInstance(comps.get(0));
 
-        Assert.assertSame(i.getV(), obj2);
+        Assert.assertSame(typed2.isValue(), obj2.isValue());
 
         ContextFactory.destroySessionContext(session);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PostConstructComponentTest.java
Tue Jan 26 22:21:44 2010
@@ -58,7 +58,7 @@
 
         Assert.assertEquals(2, comps.size());
 
-        Object object = getManager().getInstance(comps.get(0));
+        CheckWithCheckPayment object =(CheckWithCheckPayment) getManager().getInstance(comps.get(0));
         Object object2 = getManager().getInstance(comps.get(1));
 
         Assert.assertTrue(object instanceof CheckWithCheckPayment);
@@ -66,7 +66,7 @@
 
         PostConstructComponent pcc = (PostConstructComponent) object2;
 
-        pcc.getP();
+        CheckWithCheckPayment chk = (CheckWithCheckPayment) pcc.getP();
 
         ManagedBean<PostConstructComponent> s = (ManagedBean<PostConstructComponent>)
comps.get(1);
         List<InterceptorData> stack = s.getInterceptorStack();
@@ -74,7 +74,7 @@
         Assert.assertEquals(1, stack.size());
 
         Assert.assertNotNull(pcc.getP());
-        Assert.assertSame(object, pcc.getP());
+        Assert.assertSame(object.getValue(), chk.getValue());
 
         ContextFactory.destroyRequestContext(null);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/PreDestroyComponentTest.java
Tue Jan 26 22:21:44 2010
@@ -60,7 +60,7 @@
 
         Assert.assertEquals(2, comps.size());
 
-        Object object = getManager().getInstance(comps.get(0));
+        CheckWithCheckPayment object = (CheckWithCheckPayment)getManager().getInstance(comps.get(0));
         PreDestroyComponent object2 = (PreDestroyComponent)getManager().getInstance(comps.get(1));
         
         object2.getP();
@@ -69,6 +69,8 @@
         Assert.assertTrue(object2 instanceof PreDestroyComponent);
 
         PreDestroyComponent pcc = (PreDestroyComponent) object2;
+        CheckWithCheckPayment payment = (CheckWithCheckPayment) pcc.getP();
+        payment.setValue(true);
 
         ManagedBean<PreDestroyComponent> s = (ManagedBean<PreDestroyComponent>)
comps.get(1);
         List<InterceptorData> stack = s.getInterceptorStack();
@@ -76,7 +78,7 @@
         Assert.assertEquals(2, stack.size());
 
         Assert.assertNotNull(pcc.getP());
-        Assert.assertSame(object, pcc.getP());
+        Assert.assertSame(object.getValue(), payment.getValue());
 
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java?rev=903457&r1=903456&r2=903457&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/intercept/webbeans/CallingBusinessInConstructorTest.java
Tue Jan 26 22:21:44 2010
@@ -78,7 +78,7 @@
         
         Assert.assertNotNull(instance);
         
-        Assert.assertTrue(!SecureInterceptor.CALL);
+        Assert.assertTrue(SecureInterceptor.CALL);
         
         ContextFactory.destroyRequestContext(null);
         



Mime
View raw message