openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r881046 [1/2] - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/component/third/ main/java/org/apache/webbeans/component/xml/ main/java/org/apache/webbeans/config/ m...
Date Mon, 16 Nov 2009 23:27:46 GMT
Author: gerdogdu
Date: Mon Nov 16 23:27:42 2009
New Revision: 881046

URL: http://svn.apache.org/viewvc?rev=881046&view=rev
Log:
Correction on the CreationalContext and Interceptors/Decorators architecture. Update all codes.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProvidedBeansProxyHandler.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/ConversationDecorator.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.xml   (with props)
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/IBeanHasParent.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLProducerBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbPlugin.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ServiceLoader.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/Singleton.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/StaticProducerTest.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java Mon Nov 16 23:27:42 2009
@@ -106,9 +106,6 @@
     /**Tracks dependent injection point owner, can be null*/
     protected InjectionPoint dependentOwnerInjectionPoint;
     
-    /**Creational context*/
-    protected CreationalContext<T> creationalContext = null;
-
     /**
      * Constructor definiton. Each subclass redefines its own constructor with
      * calling this.
@@ -158,10 +155,8 @@
     {
         T instance = null;
         try
-        {
-            this.creationalContext = creationalContext;
-            instance = createInstance(this.creationalContext);
-
+        {            
+            instance = createInstance(creationalContext);
         }
         catch (Exception re)
         {
@@ -200,10 +195,10 @@
         try
         {
             //Destory dependent instances
-            this.creationalContext.release();
+            creationalContext.release();
             
             //Destroy instance, call @PreDestroy
-            destroyInstance(instance);
+            destroyInstance(instance,creationalContext);
                         
             //Reset it
             this.dependentOwnerInjectionPoint = null;  
@@ -221,7 +216,7 @@
      * 
      * @param instance instance of the bean that is being destroyed
      */
-    protected void destroyInstance(T instance)
+    protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
         
     }
@@ -428,25 +423,30 @@
      * @param dependentComponent dependent web beans bean
      * @return the dependent bean instance
      */
-    public Object getDependent(Bean<?> dependentComponent, InjectionPoint injectionPoint)
+    public Object getDependent(Bean<?> dependentComponent, InjectionPoint injectionPoint, CreationalContext<?> creational)
     {
         Object object = null;
         
         //Setting injection point owner
-        AbstractBean<?> dependent = (AbstractBean<?>)dependentComponent;
+        @SuppressWarnings("unchecked")
+        AbstractBean<Object> dependent = (AbstractBean<Object>)dependentComponent;
         dependent.setDependentOwnerInjectionPoint(injectionPoint);        
         
         @SuppressWarnings("unchecked")
-        CreationalContext<?> dependentCreational = CreationalContextFactory.getInstance().getCreationalContext(dependentComponent);
+        CreationalContext<Object> dependentCreational = CreationalContextFactory.getInstance().getCreationalContext(dependentComponent);
         
         //Get dependent instance
         object = BeanManagerImpl.getManager().getReference(dependentComponent, injectionPoint.getType(), dependentCreational);
         
-        CreationalContextImpl<T> cc = (CreationalContextImpl<T>)this.creationalContext;
+        if(creational instanceof CreationalContextImpl)
+        {
+            CreationalContextImpl<?> cc = (CreationalContextImpl<?>)creational;
+            
+            //Put this into the dependent map
+            cc.addDependent(dependent, object, dependentCreational);
+    
+        }
         
-        //Put this into the dependent map
-        cc.addDependent(dependentComponent, object);
-
         return object;
     }
     
@@ -585,23 +585,7 @@
         return set;
     }
     
-    /**
-     * {@inheritDoc}
-     */    
-    public CreationalContext<T> getCreationalContext()
-    {
-        return this.creationalContext;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public  void setCreationalContext(CreationalContext<T> creationalContext)
-    {
-        this.creationalContext = creationalContext;
-    }
-    
-    /**
+     /**
      * {@inheritDoc}
      */    
     public boolean isAlternative()

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractInjectionTargetBean.java Mon Nov 16 23:27:42 2009
@@ -129,14 +129,14 @@
         //Push instance into the creational context
         if(WebBeansUtil.isScopeTypeNormal(getScope()))
         {
-            this.creationalContext.push(instance);
+            creationalContext.push(instance);
         }
 
         afterConstructor(instance, creationalContext);
         
-        if(this.creationalContext instanceof CreationalContextImpl)
+        if(creationalContext instanceof CreationalContextImpl)
         {
-            CreationalContextImpl<T> impl = (CreationalContextImpl<T>)this.creationalContext;
+            CreationalContextImpl<T> impl = (CreationalContextImpl<T>)creationalContext;
             impl.remove();
         }
 
@@ -146,7 +146,7 @@
     /**
      * {@inheritDoc}
      */
-    protected void destroyInstance(T instance)
+    protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
         destroyComponentInstance(instance);
     }
@@ -167,10 +167,6 @@
     protected void destroyComponentInstance(T instance)
     {
         preDestroy(instance);
-
-        // Remove it from creational context, if any
-        CreationalContextImpl<T> cc = (CreationalContextImpl<T>) this.creationalContext;
-        cc.remove();
     }
 
     /**
@@ -308,7 +304,7 @@
         {
             if (field.getAnnotation(Delegate.class) == null)
             {
-                injectField(field, instance);
+                injectField(field, instance, creationalContext);
             }
         }                
     }
@@ -320,7 +316,7 @@
         {
             if (field.getAnnotation(Delegate.class) == null)
             {
-                injectField(field, instance);
+                injectField(field, instance, creationalContext);
             }
         }                        
     }
@@ -331,12 +327,12 @@
 
         for (Method method : methods)
         {
-            injectMethod(method, instance);
+            injectMethod(method, instance, creationalContext);
         }        
     }
     
     
-    private void injectField(Field field, Object instance)
+    private void injectField(Field field, Object instance, CreationalContext<?> creationalContext)
     {
         InjectableField f = new InjectableField(field, instance, this, creationalContext);
         f.doInjection();        
@@ -354,12 +350,12 @@
 
         for (Method method : methods)
         {
-            injectMethod(method, instance);
+            injectMethod(method, instance, creationalContext);
         }
     }
     
     @SuppressWarnings("unchecked")
-    private void injectMethod(Method method, Object instance)
+    private void injectMethod(Method method, Object instance, CreationalContext<?> creationalContext)
     {
         InjectableMethods m = new InjectableMethods(method, instance, this, creationalContext);
         m.doInjection();        

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java Mon Nov 16 23:27:42 2009
@@ -69,7 +69,7 @@
     /**
      * {@inheritDoc}
      */
-    public void dispose(T instance)
+    public void dispose(T instance, CreationalContext<T> creationalContext)
     {
         // Do nothing
     }
@@ -121,12 +121,12 @@
      * @param instance bean instance
      */
     @SuppressWarnings("unchecked")
-    protected <K> void destroyBean(Bean<?> bean, Object instance)
+    protected <K> void destroyBean(Bean<?> bean, Object instance, CreationalContext<?> creationalContext)
     {
         Bean<K> destroy = (Bean<K>) bean;
         K inst = (K) instance;
 
-        CreationalContext<K> cc = (CreationalContext<K>) this.creationalContext;
+        CreationalContext<K> cc = (CreationalContext<K>) creationalContext;
         destroy.destroy(inst, cc);
     }
 
@@ -136,7 +136,7 @@
      * @return owner bean instance
      */
     @SuppressWarnings("unchecked")
-    protected Object getParentInstance()
+    protected Object getParentInstance(CreationalContext<?> creationalContext)
     {
         // return getManager().getInstance(this.ownerComponent);
 
@@ -150,11 +150,11 @@
 
         if (specialize != null)
         {
-            parentInstance = getManager().getReference(specialize, null, getManager().createCreationalContext(specialize));
+            parentInstance = getManager().getReference(specialize, null, creationalContext);
         }
         else
         {
-            parentInstance = getManager().getReference(this.ownerComponent, null, getManager().createCreationalContext(this.ownerComponent));
+            parentInstance = getManager().getReference(this.ownerComponent, null, creationalContext);
         }
 
         return parentInstance;
@@ -165,7 +165,7 @@
      * {@inheritDoc}
      */
     @Override
-    protected void destroyInstance(T instance)
+    protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
 
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BaseBean.java Mon Nov 16 23:27:42 2009
@@ -179,7 +179,7 @@
      * @param injectionPoint injection point of dependent bean
      * @return dependent bean
      */
-    public abstract Object getDependent(Bean<?> dependentBean,InjectionPoint injectionPoint);
+    public abstract Object getDependent(Bean<?> dependentBean,InjectionPoint injectionPoint, CreationalContext<?> creational);
 
     /**
      * Gets interceptor stack of bean instance.
@@ -229,15 +229,4 @@
      */    
     public abstract boolean isEnabled();
     
-    /**
-     * Returns creational context of bean instance
-     * @return creational context of bean instance.
-     */
-    public abstract CreationalContext<T> getCreationalContext();
-    
-    /**
-     * Set creational context
-     * @param creationalContext creational context
-     */
-    public abstract void setCreationalContext(CreationalContext<T> creationalContext);
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java Mon Nov 16 23:27:42 2009
@@ -39,7 +39,7 @@
     }
 
     @Override
-    protected void destroyInstance(BeanManager instance)
+    protected void destroyInstance(BeanManager instance,CreationalContext<BeanManager> creationalContext)
     {
         this.manager = null;
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java Mon Nov 16 23:27:42 2009
@@ -62,7 +62,7 @@
     }
 
     @Override
-    protected void destroyInstance(Conversation instance)
+    protected void destroyInstance(Conversation instance, CreationalContext<Conversation> creationalContext)
     {
         if (instance.isTransient())
         {

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/IBeanHasParent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/IBeanHasParent.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/IBeanHasParent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/IBeanHasParent.java Mon Nov 16 23:27:42 2009
@@ -16,9 +16,11 @@
  */
 package org.apache.webbeans.component;
 
+import javax.enterprise.context.spi.CreationalContext;
+
 public interface IBeanHasParent<T>
 {
     public AbstractBean<?> getParent();
     
-    public void dispose(T instance);
+    public void dispose(T instance, CreationalContext<T> creationalContext);
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java Mon Nov 16 23:27:42 2009
@@ -47,7 +47,7 @@
     }
 
     @Override
-    protected void destroyInstance(InjectionPoint instance)
+    protected void destroyInstance(InjectionPoint instance, CreationalContext<InjectionPoint> creationalContext)
     {
         this.injectionPoint = null;
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewBean.java Mon Nov 16 23:27:42 2009
@@ -41,9 +41,9 @@
     }
 
     @Override
-    protected void destroyInstance(T instance)
+    protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
-        super.destroyInstance(instance);
+        super.destroyInstance(instance, creationalContext);
     }
 
     /**

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java Mon Nov 16 23:27:42 2009
@@ -92,7 +92,7 @@
             }
             else
             {
-                parentInstance = getParentInstance();
+                parentInstance = getParentInstance(creationalContext);
                 instance = (T) producerField.get(parentInstance);
             }
         }catch(Exception e)
@@ -103,7 +103,7 @@
         {
             if (this.ownerComponent.getScope().equals(Dependent.class))
             {
-                destroyBean(this.ownerComponent, parentInstance);
+                destroyBean(this.ownerComponent, parentInstance, creationalContext);
             }
         }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java Mon Nov 16 23:27:42 2009
@@ -160,10 +160,10 @@
         {
             if (!Modifier.isStatic(creatorMethod.getModifiers()))
             {
-                parentInstance = getParentInstance();
+                parentInstance = getParentInstance(creationalContext);
             }
 
-            InjectableMethods<T> m = new InjectableMethods<T>(creatorMethod, parentInstance, this, null);
+            InjectableMethods<T> m = new InjectableMethods<T>(creatorMethod, parentInstance, this, creationalContext);
 
             instance = m.doInjection();
 
@@ -172,7 +172,7 @@
         {
             if (getParent().getScope().equals(Dependent.class))
             {
-                destroyBean(getParent(), parentInstance);
+                destroyBean(getParent(), parentInstance, creationalContext);
             }
         }
 
@@ -184,15 +184,15 @@
      * {@inheritDoc}
      */
     @Override
-    protected void destroyInstance(T instance)
+    protected void destroyInstance(T instance, CreationalContext<T> creationalContext)
     {
-        dispose(instance);
+        dispose(instance,creationalContext);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void dispose(T instance)
+    public void dispose(T instance, CreationalContext<T> creationalContext)
     {
         if (isProducerSet())
         {
@@ -200,7 +200,7 @@
         }
         else
         {
-            disposeDefault(instance);
+            disposeDefault(instance, creationalContext);
         }
     }
 
@@ -209,7 +209,7 @@
      * 
      * @param instance bean instance
      */
-    protected void disposeDefault(T instance)
+    protected void disposeDefault(T instance, CreationalContext<T> creationalContext)
     {
         if (disposalMethod != null)
         {
@@ -219,7 +219,7 @@
             {
                 if (!Modifier.isStatic(disposalMethod.getModifiers()))
                 {
-                    parentInstance = getParentInstance();
+                    parentInstance = getParentInstance(creationalContext);
                 }
 
                 InjectableMethods<T> m = new InjectableMethods<T>(disposalMethod, parentInstance, this.ownerComponent, null);
@@ -231,7 +231,7 @@
             {
                 if (getParent().getScope().equals(Dependent.class))
                 {
-                    destroyBean(getParent(), parentInstance);
+                    destroyBean(getParent(), parentInstance, creationalContext);
 
                 }
             }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java Mon Nov 16 23:27:42 2009
@@ -119,7 +119,7 @@
 
 
     @Override
-    protected void destroyInstance(T instance)
+    protected void destroyInstance(T instance,CreationalContext<T> creationalContext)
     {
         throw new UnsupportedOperationException();
         

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLProducerBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLProducerBean.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLProducerBean.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/xml/XMLProducerBean.java Mon Nov 16 23:27:42 2009
@@ -76,7 +76,7 @@
         if (disposalMethod != null)
         {
 
-            Object object = getParentInstance();
+            Object object = getParentInstance(null);
 
             XMLInjectableMethods<T> methods = new XMLInjectableMethods<T>(creatorMethod, object, this, this.disposalMethodParameters,this.creationalContext);
             methods.doInjection();
@@ -89,7 +89,7 @@
         this.creationalContext = creationalContext;
         
         T instance = null;
-        Object parentInstance = getParentInstance();
+        Object parentInstance = getParentInstance(creationalContext);
 
         try
         {
@@ -100,7 +100,7 @@
         {
             if (getParent().getScope().equals(Dependent.class))
             {
-                destroyBean(getParent(), parentInstance);
+                destroyBean(getParent(), parentInstance,creationalContext);
             }
         }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Mon Nov 16 23:27:42 2009
@@ -120,19 +120,7 @@
         try
         {
             if (!deployed)
-            {
-                // Register Manager built-in component
-                BeanManagerImpl.getManager().addBean(WebBeansUtil.getManagerBean());
-
-                // Register Conversation built-in component
-                BeanManagerImpl.getManager().addBean(WebBeansUtil.getConversationBean());
-                
-                // Register InjectionPoint bean
-                BeanManagerImpl.getManager().addBean(WebBeansUtil.getInjectionPointBean());
-                
-                //Register Instance Bean
-                BeanManagerImpl.getManager().addBean(WebBeansUtil.getInstanceBean());
-                
+            {                
                 //Load Extensions
                 ExtensionLoader.getInstance().loadExtensionServices();
 
@@ -154,6 +142,9 @@
                 
                 //Configure Decorators
                 configureDecorators(scanner);
+                
+                //Configure Default Beans
+                configureDefaultBeans();
                                 
                 //Discover classpath classes
                 deployFromClassPath(scanner);
@@ -194,6 +185,21 @@
         }
     }
     
+    private void configureDefaultBeans()
+    {
+        // Register Manager built-in component
+        BeanManagerImpl.getManager().addBean(WebBeansUtil.getManagerBean());
+
+        // Register Conversation built-in component
+        BeanManagerImpl.getManager().addBean(WebBeansUtil.getConversationBean());
+        
+        // Register InjectionPoint bean
+        BeanManagerImpl.getManager().addBean(WebBeansUtil.getInjectionPointBean());
+        
+        //Register Instance Bean
+        BeanManagerImpl.getManager().addBean(WebBeansUtil.getInstanceBean());        
+    }
+    
     /**
      * Fires event before bean discovery.
      */

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Mon Nov 16 23:27:42 2009
@@ -305,7 +305,7 @@
     }
     
     @Deprecated
-    public Object getInstanceByName(String name)
+    public Object getInstanceByName(String name, CreationalContext<?> creationalContext)
     {
         AbstractBean<?> component = null;
         Object object = null;
@@ -323,7 +323,7 @@
 
         component = (AbstractBean<?>) set.iterator().next();
 
-        object = getInstance(component);
+        object = getInstance(component, creationalContext);
 
         return object;
     }
@@ -350,7 +350,9 @@
 
         ResolutionUtil.checkResolvedBeans(set, type, bindingTypes);
 
-        return (T)getInstance(set.iterator().next());
+        Bean<?> bean = set.iterator().next();
+        
+        return (T)getInstance(bean, createCreationalContext(bean));
     }
 
     @Deprecated
@@ -361,7 +363,9 @@
 
         ResolutionUtil.checkResolvedBeans(set, type.getRawType(),bindingTypes);
 
-        return (T)getInstance(set.iterator().next());
+        Bean<?> bean = set.iterator().next();
+        
+        return (T)getInstance(bean, createCreationalContext(bean));
     }
 
     @Deprecated
@@ -411,9 +415,13 @@
 
     
     @Deprecated
-    public <T> T getInstance(Bean<T> bean)
+    public <T> T getInstance(Bean<T> bean, CreationalContext<?> creationalContext)
     {
-        return (T)getReference(bean, null, createCreationalContext(bean));
+        if(creationalContext == null)
+        {
+            creationalContext = createCreationalContext(bean);
+        }
+        return (T)getReference(bean, null, creationalContext);
     }
     
     /**
@@ -599,7 +607,7 @@
      * {@inheritDoc}
      */
     @Override
-    public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> context)
+    public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
     {
         Object instance = null;
         
@@ -614,18 +622,21 @@
         //Find the injection point Bean
         Bean<?> bean = injectionResolver.getInjectionPointBean(injectionPoint);
         
-        if(context != null && (context instanceof CreationalContextImpl))
+        if(creationalContext != null && (creationalContext instanceof CreationalContextImpl))
         {
-            CreationalContextImpl<?> creationalContext = (CreationalContextImpl<?>)context;
+            CreationalContextImpl<?> creationalContextImpl = (CreationalContextImpl<?>)creationalContext;
             
-            instance = creationalContext.get(bean);
+            if(creationalContextImpl.getBean().equals(bean))
+            {
+                instance = creationalContextImpl.get();   
+            }            
             
         }
                 
         if(instance == null)
         {
             //Creating a new creational context for target bean instance
-            instance = getReference(bean, injectionPoint.getType(), createCreationalContext(bean));
+            instance = getReference(bean, injectionPoint.getType(), creationalContext);
         }
         
         return instance;
@@ -667,7 +678,7 @@
      * {@inheritDoc}
      */
     @Override
-    public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> ctx)
+    public Object getReference(Bean<?> bean, Type beanType, CreationalContext<?> creationalContext)
     {
         Context context = null;
         Object instance = null;
@@ -682,20 +693,20 @@
             
         }
         
-        //Some casts for generic!
-        AbstractBean<Object> beanInstance = (AbstractBean<Object>)bean;
-        CreationalContext<Object> creationalContext = (CreationalContext<Object>)ctx;
-        
-        //Set creational context
-        beanInstance.setCreationalContext(creationalContext);
-        
         //Get bean context
-        context = getContext(beanInstance.getScope());
+        context = getContext(bean.getScope());
         
         //Scope is normal
         if (WebBeansUtil.isScopeTypeNormal(bean.getScope()))
         {
-            instance = getEjbOrJmsProxyReference(beanInstance, beanType);
+            instance = context.get(bean);
+            
+            if(instance != null)
+            {
+                return instance;
+            }
+            
+            instance = getEjbOrJmsProxyReference(bean, beanType,creationalContext);
             
             if(instance != null)
             {
@@ -710,7 +721,7 @@
                 }
                 else
                 {
-                    instance = JavassistProxyFactory.createNewProxyInstance(bean);
+                    instance = JavassistProxyFactory.createNewProxyInstance(bean,creationalContext);
                     this.proxyMap.put(bean, instance);
                 }
             }            
@@ -718,21 +729,21 @@
         //Create Pseudo-Scope Bean Instance
         else
         {
-            instance = getEjbOrJmsProxyReference(beanInstance, beanType);
+            instance = getEjbOrJmsProxyReference(bean, beanType, creationalContext);
             
             if(instance != null)
             {
                 return instance;
             }
             
-            context = getContext(bean.getScope());
-            instance = context.get((Bean<Object>)bean, creationalContext);                                
+            
+            instance = context.get((Bean<Object>)bean, (CreationalContext<Object>)creationalContext);                                
         }
         
         return instance;
     }
     
-    private Object getEjbOrJmsProxyReference(Bean<?> bean,Type beanType)
+    private Object getEjbOrJmsProxyReference(Bean<?> bean,Type beanType, CreationalContext<?> creationalContext)
     {
         //Create session bean proxy
         if(bean instanceof EnterpriseBeanMarker)
@@ -743,7 +754,7 @@
                 throw new IllegalStateException("There is no EJB plugin provider. Injection is failed for bean : " + bean);
             }
             
-            return ejbPlugin.getSessionBeanProxy(bean,ClassUtil.getClazz(beanType));
+            return ejbPlugin.getSessionBeanProxy(bean,ClassUtil.getClazz(beanType), creationalContext);
         }
         
         //Create JMS Proxy

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextFactory.java Mon Nov 16 23:27:42 2009
@@ -30,15 +30,11 @@
  */
 public final class CreationalContextFactory<T>
 {
-    /**Ceational context that is used for generating other creational contexts*/
-    private CreationalContextImpl<T> impl;
-    
     /**
      * Creates a new <code>CreationalContextFactory</code> instance.
      */
     public CreationalContextFactory()
     {
-        impl = new CreationalContextImpl<T>();
     }
     
     /**
@@ -60,15 +56,6 @@
      */
     public CreationalContext<T> getCreationalContext(Contextual<T> contextual)
     {        
-        return impl.getCreationalContextImpl(contextual);   
-    }
-        
-    /**
-     * Clear all incomplete instance cache.
-     */
-    public void clear()
-    {
-        impl.clear();
-        impl = null;
-    }
+        return new CreationalContextImpl<T>(contextual);   
+    }        
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java Mon Nov 16 23:27:42 2009
@@ -20,7 +20,6 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
@@ -30,40 +29,70 @@
 /** {@inheritDoc} */
 public class CreationalContextImpl<T> implements CreationalContext<T>
 {
-    /**Map of bean with its incomplete instance*/
-    private Map<Contextual<?>,Object> incompleteInstancesMap = new ConcurrentHashMap<Contextual<?>, Object>();
-
-    /**Contextual bean*/
-    private Contextual<T> incompleteBean = null;
+    private Object incompleteInstance = null;
     
     /**Contextual bean dependent instances*/
-    private Map<Object, Contextual<?>> dependentObjects = new WeakHashMap<Object, Contextual<?>>();
+    private Map<Object, DependentCreationalContext<?>> dependentObjects = new WeakHashMap<Object, DependentCreationalContext<?>>();
+     
+    private Contextual<T> contextual = null;
     
-    /**
-     * Package private
-     */
-    CreationalContextImpl()
+    private static class DependentCreationalContext<S>
     {
-        //Empty
+        private CreationalContext<S> creationalContext;
+        
+        private Contextual<S> contextual;
+        
+        /**
+         * @return the creationalContext
+         */
+        public CreationalContext<S> getCreationalContext()
+        {
+            return creationalContext;
+        }
+
+        /**
+         * @param creationalContext the creationalContext to set
+         */
+        public void setCreationalContext(CreationalContext<S> creationalContext)
+        {
+            this.creationalContext = creationalContext;
+        }
+
+        /**
+         * @return the contextual
+         */
+        public Contextual<S> getContextual()
+        {
+            return contextual;
+        }
+
+        /**
+         * @param contextual the contextual to set
+         */
+        public void setContextual(Contextual<S> contextual)
+        {
+            this.contextual = contextual;
+        }
+
+        public DependentCreationalContext(CreationalContext<S> cc, Contextual<S> contextual)
+        {
+            this.contextual = contextual;
+            this.creationalContext = cc;
+        }
+        
+        
     }
     
+    
     /**
-     * Returns new creational context.
-     * 
-     * @param incompleteBean incomplete instance owner
-     * @return new creational context
+     * Package private
      */
-    protected CreationalContextImpl<T> getCreationalContextImpl(Contextual<T> incompleteBean)
+    CreationalContextImpl(Contextual<T> contextual)
     {
-        CreationalContextImpl<T> impl = new CreationalContextImpl<T>();        
-        
-        impl.incompleteBean = incompleteBean;
-        impl.incompleteInstancesMap = this.incompleteInstancesMap;
-        
-        return impl;
-        
+        this.contextual = contextual;
     }
     
+    
     /**
      * Save this incomplete instance.
      * 
@@ -71,7 +100,7 @@
      */
     public void push(T incompleteInstance)
     {
-        this.incompleteInstancesMap.put(this.incompleteBean, incompleteInstance);
+        this.incompleteInstance = incompleteInstance;
         
     }
     
@@ -82,16 +111,13 @@
      * @param dependent dependent contextual
      * @param instance dependent instance
      */
-    public <K> void addDependent(Contextual<K> dependent, Object instance)
+    public <K> void addDependent(Contextual<K> dependent, Object instance, CreationalContext<K> cc)
     {
         Asserts.assertNotNull(dependent,"dependent parameter cannot be null");
         
         if(instance != null)
         {
-            synchronized (this.dependentObjects)
-            {
-                this.dependentObjects.put(instance, dependent);   
-            }            
+           this.dependentObjects.put(instance, new DependentCreationalContext<K>(cc,dependent));   
         }
     }
     
@@ -101,9 +127,9 @@
      * @param incompleteBean instance owner
      * @return incomplete instance
      */
-    public Object get(Contextual<?> incompleteBean)
+    public Object get()
     {
-        return incompleteInstancesMap.get(incompleteBean);
+        return this.incompleteInstance;
     }
     
     
@@ -114,10 +140,7 @@
      */
     public void  remove()
     {
-        if(this.incompleteInstancesMap.containsKey(this.incompleteBean))
-        {
-            this.incompleteInstancesMap.remove(this.incompleteBean);
-        }        
+        this.incompleteInstance = null;
     }
     
     /**
@@ -126,33 +149,20 @@
     @SuppressWarnings("unchecked")
     private void  removeDependents()
     {
-        //Clear its dependence objects
-        synchronized (this.dependentObjects)
+        Collection<?> values = this.dependentObjects.keySet();
+        Iterator<?> iterator = values.iterator();
+        
+        while(iterator.hasNext())
         {
-            Collection<?> values = this.dependentObjects.keySet();
-            Iterator<?> iterator = values.iterator();
-            
-            while(iterator.hasNext())
-            {
-                T instance = (T)iterator.next();
-                Contextual<T> dependent = (Contextual<T>)this.dependentObjects.get(instance);
-                dependent.destroy(instance, (CreationalContext<T>)this);                
-            }
-            
-            this.dependentObjects.clear();
+            T instance = (T)iterator.next();
+            DependentCreationalContext<T> dependent = (DependentCreationalContext<T>)this.dependentObjects.get(instance);
+            dependent.getContextual().destroy(instance, (CreationalContext<T>)dependent.getCreationalContext());                
         }
         
+        this.dependentObjects.clear();
     }
     
     /**
-     * Clear registry.
-     */
-    public void clear()
-    {
-        this.incompleteInstancesMap.clear();
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -161,5 +171,11 @@
         removeDependents();        
         
     }
+    
+    
+    public Contextual<T> getBean()
+    {
+        return this.contextual;
+    }
 
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/conversation/ConversationManager.java Mon Nov 16 23:27:42 2009
@@ -20,6 +20,7 @@
 
 import javax.enterprise.context.Conversation;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
 
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.config.WebBeansFinder;
@@ -161,9 +162,9 @@
     @SuppressWarnings("unchecked")
     public Conversation getConversationInstance()
     {
-
-        Bean<Conversation> bean = (Bean<Conversation>)BeanManagerImpl.getManager().resolveByType(Conversation.class, new DefaultLiteral()).iterator().next();
-        Conversation conversation = BeanManagerImpl.getManager().getInstance(bean);
+        BeanManagerImpl beanManager = BeanManagerImpl.getManager();
+        Bean<Conversation> bean = (Bean<Conversation>)beanManager.resolveByType(Conversation.class, new DefaultLiteral()).iterator().next();
+        Conversation conversation = BeanManagerImpl.getManager().getInstance(bean, beanManager.createCreationalContext(bean));
 
         return conversation;
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java Mon Nov 16 23:27:42 2009
@@ -236,9 +236,7 @@
     @SuppressWarnings("unchecked")    
     protected  T createInstance(CreationalContext<T> creationalContext)
     {
-        T proxy = (T)JavassistProxyFactory.createNewProxyInstance(this);
-        
-        this.wrappedBean.setCreationalContext(creationalContext);
+        T proxy = (T)JavassistProxyFactory.createNewProxyInstance(this, creationalContext);
 
         return proxy;
         

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecoratorConfig.java Mon Nov 16 23:27:42 2009
@@ -88,7 +88,7 @@
         {
             WebBeansDecorator<?> decorator = (WebBeansDecorator<?>) itList.next();
             
-            Object decoratorInstance = BeanManagerImpl.getManager().getInstance(decorator);
+            Object decoratorInstance = BeanManagerImpl.getManager().getInstance(decorator,null);
 
             decorator.setInjections(decoratorInstance);
             decorator.setDelegate(decoratorInstance, instance);

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/el/WebBeansELResolver.java Mon Nov 16 23:27:42 2009
@@ -15,6 +15,7 @@
 
 import java.beans.FeatureDescriptor;
 import java.util.Iterator;
+import java.util.Set;
 
 import javax.el.ELContext;
 import javax.el.ELException;
@@ -22,6 +23,7 @@
 import javax.el.PropertyNotFoundException;
 import javax.el.PropertyNotWritableException;
 import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.servlet.jsp.JspApplicationContext;
 
@@ -78,31 +80,39 @@
      * {@inheritDoc}
      */    
     @Override
+    @SuppressWarnings("unchecked")
     public Object getValue(ELContext context, Object obj, Object property) throws NullPointerException, PropertyNotFoundException, ELException
     {
         BeanManagerImpl manager = BeanManagerImpl.getManager();
 
         Object object = null;
-        Bean<?> bean = null;
+        Bean<Object> bean = null;
 
         boolean isResolution = false;
+        CreationalContext<Object> creationalContext = null;
         try
-        {
+        {            
             if (obj == null)
             {
-                String name = (String) property;
-                object = manager.getInstanceByName(name);
+                String name = (String) property;            
+                Set<Bean<?>> beans = manager.getBeans(name);
+                
+                if(beans != null && !beans.isEmpty())
+                {
+                    bean = (Bean<Object>)beans.iterator().next();
+                    creationalContext = manager.createCreationalContext(bean);                    
+   
+                }
+                
+                object = manager.getInstanceByName(name,creationalContext);
                 
                 if (object != null)
                 {
                     isResolution = true;
                     context.setPropertyResolved(true);
-                    //It is used for destroying
-                    bean = manager.resolveByName(name).iterator().next();
                 }
-
             }
-
+            
         }
         finally
         {
@@ -110,7 +120,7 @@
             {
                 if (bean != null)
                 {
-                    destroyBean(bean, object);
+                    destroyBean(bean, object, creationalContext);
                 }                
             }
         }
@@ -126,14 +136,13 @@
      * @param instance bean instance
      */
     @SuppressWarnings("unchecked")
-    private <T> void destroyBean(Bean<T> bean, Object instance)
+    private <T> void destroyBean(Bean<T> bean, Object instance, CreationalContext<T> creationalContext)
     {
         if (bean.getScope().equals(Dependent.class))
         {
             T inst = (T) instance;
 
-            //TODO Creational Context
-            bean.destroy(inst,null);
+            bean.destroy(inst,creationalContext);
         }
     }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java Mon Nov 16 23:27:42 2009
@@ -29,9 +29,11 @@
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
 import javax.enterprise.event.Reception;
 import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ObserverMethod;
 
 import org.apache.webbeans.annotation.DefaultLiteral;
@@ -154,20 +156,24 @@
         AbstractBean<Object> baseComponent = (AbstractBean<Object>) bean;
         AbstractBean<Object> specializedComponent = null;
         Object object = null;
-
+        
+        CreationalContext<?> creationalContext = null;
+        
         try
         {
             BeanManagerImpl manager = ActivityManager.getInstance().getCurrentActivity();
             specializedComponent = (AbstractBean<Object>)WebBeansUtil.getMostSpecializedBean(manager, baseComponent);        
             Context context = manager.getContext(specializedComponent.getScope());
             
+            creationalContext = manager.createCreationalContext(specializedComponent);
+            
             if(this.ifExist)
             {
                 object = context.get(specializedComponent);
             }
             else
             {
-                object = manager.getInstance(specializedComponent);    
+                object = manager.getInstance(specializedComponent, creationalContext);    
             }
             
 
@@ -207,7 +213,7 @@
         {
             if (baseComponent.getScope().equals(Dependent.class))
             {
-                baseComponent.destroy(object,baseComponent.getCreationalContext());
+                baseComponent.destroy(object,(CreationalContext<Object>)creationalContext);
             }
         }
 
@@ -263,7 +269,8 @@
 
                     if (bindingTypes.length > 0)
                     {
-                        list.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(type, bindingTypes).iterator().next()));
+                        Bean<?> bean = InjectionResolver.getInstance().implResolveByType(type, bindingTypes).iterator().next();
+                        list.add(manager.getInstance(bean, manager.createCreationalContext(bean)));
                     }
                     else
                     {

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/xml/BeanObserverXMLImpl.java Mon Nov 16 23:27:42 2009
@@ -57,7 +57,7 @@
             Set<Annotation> setBindingTypes = model.getBindingTypes();
             Annotation[] anns = new Annotation[setBindingTypes.size()];
             anns = setBindingTypes.toArray(anns);
-            params.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(model.getInjectionGenericType(), anns).iterator().next()));
+            params.add(manager.getInstance(InjectionResolver.getInstance().implResolveByType(model.getInjectionGenericType(), anns).iterator().next(),null));
         }
 
         return params;

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AbstractInjectable.java Mon Nov 16 23:27:42 2009
@@ -139,7 +139,7 @@
     private Object injectForDependent(Bean<?> bean, InjectionPoint injectionPoint)
     {
         Object object = null;
-        object = this.injectionOwnerComponent.getDependent(bean,injectionPoint);
+        object = this.injectionOwnerComponent.getDependent(bean,injectionPoint, this.creationalContext);
 
         return object;
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java Mon Nov 16 23:27:42 2009
@@ -78,7 +78,7 @@
         ResolutionUtil.checkResolvedBeans(beans, ClassUtil.getClazz(this.injectionClazz),anns);
 
         Bean<?> bean = beans.iterator().next();
-        instance = (T)BeanManagerImpl.getManager().getInstance(bean);
+        instance = (T)BeanManagerImpl.getManager().getInstance(bean,null);
 
         return instance;
     }
@@ -205,7 +205,7 @@
         Set<T> instances = new HashSet<T>();
         for(Bean<?> bean : beans)
         {
-            T instance = (T)BeanManagerImpl.getManager().getInstance(bean);
+            T instance = (T)BeanManagerImpl.getManager().getInstance(bean,null);
             instances.add(instance);
         }
         

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java Mon Nov 16 23:27:42 2009
@@ -144,10 +144,13 @@
     private transient boolean isSameDecMethod = false;
     
     private transient boolean isInDecoratorCall = false;
+    
+    private CreationalContext<?> creationalContext = null;
 
-    public InterceptorHandler(AbstractBean<?> component)
+    public InterceptorHandler(AbstractBean<?> component, CreationalContext<?> creationalContext)
     {
         this.component = component;
+        this.creationalContext = creationalContext;
     }
 
     @SuppressWarnings("unchecked")
@@ -161,7 +164,7 @@
         Context webbeansContext = BeanManagerImpl.getManager().getContext(component.getScope());
         
         //Get bean instance from context
-        Object webbeansInstance = webbeansContext.get((Contextual<Object>)this.component, (CreationalContext<Object>)this.component.getCreationalContext());
+        Object webbeansInstance = webbeansContext.get((Contextual<Object>)this.component, (CreationalContext<Object>)this.creationalContext);
         
         //toString is supported but no other object method names!!!
         if ((!ClassUtil.isObjectMethod(method.getName()) || method.getName().equals("toString")) && InterceptorUtil.isWebBeansBusinessMethod(method))
@@ -386,7 +389,7 @@
                 {
                     if (intData.isDefinedWithWebBeansInterceptor())
                     {
-                        Object interceptorProxy = BeanManagerImpl.getManager().getInstance(intData.getWebBeansInterceptor());
+                        Object interceptorProxy = BeanManagerImpl.getManager().getInstance(intData.getWebBeansInterceptor(),null);
                         WebBeansInterceptor<?> interceptor = (WebBeansInterceptor<?>) intData.getWebBeansInterceptor();
                         interceptor.setInjections(interceptorProxy);
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java Mon Nov 16 23:27:42 2009
@@ -56,6 +56,7 @@
     /** Used for numbering interceptors */
     private int currentMethod = 1;
     
+    private CreationalContext<?> creationalContext;
     
     /**
      * Initializes the context.
@@ -82,6 +83,11 @@
             this.target = instance;
         }
     }
+    
+    public void setCreationalContext(CreationalContext<?> creationalContext)
+    {
+        this.creationalContext = creationalContext;
+    }
 
     
     @SuppressWarnings("unchecked")
@@ -89,7 +95,7 @@
     {
         Context webbeansContext = BeanManagerImpl.getManager().getContext(bean.getScope());
         
-        this.target = webbeansContext.get((Contextual<Object>)bean, (CreationalContext<Object>)bean.getCreationalContext());        
+        this.target = webbeansContext.get((Contextual<Object>)bean, (CreationalContext<Object>)this.creationalContext);        
         
     }
     

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java Mon Nov 16 23:27:42 2009
@@ -254,9 +254,7 @@
     @SuppressWarnings("unchecked")
     protected T createInstance(CreationalContext<T> creationalContext)
     {
-        T proxy = (T)JavassistProxyFactory.createNewProxyInstance(this);
-        
-        this.delegateComponent.setCreationalContext(creationalContext);
+        T proxy = (T)JavassistProxyFactory.createNewProxyInstance(this,creationalContext);
 
         return proxy;
         

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/EnterpriseLifeCycle.java Mon Nov 16 23:27:42 2009
@@ -35,7 +35,6 @@
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.activity.ActivityManager;
 import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.conversation.ConversationManager;
 import org.apache.webbeans.el.WebBeansELResolver;
 import org.apache.webbeans.exception.WebBeansException;
@@ -228,9 +227,6 @@
         //Clear extensions
         ExtensionLoader.getInstance().clear();
         
-        //Clear CreationalContext
-        CreationalContextFactory.getInstance().clear();
-
         //Clear singleton list
         WebBeansFinder.clearInstances();
                 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/StandaloneLifeCycle.java Mon Nov 16 23:27:42 2009
@@ -24,7 +24,6 @@
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.activity.ActivityManager;
 import org.apache.webbeans.context.ContextFactory;
-import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.plugins.PluginLoader;
@@ -147,9 +146,6 @@
             
             //Clear extensions
             ExtensionLoader.getInstance().clear();
-            
-            //Clear CreationalContext
-            CreationalContextFactory.getInstance().clear();
 
             //Clear singleton list
             WebBeansFinder.clearInstances();

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbPlugin.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbPlugin.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbPlugin.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbPlugin.java Mon Nov 16 23:27:42 2009
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.plugins;
 
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
 /**
@@ -68,5 +69,5 @@
      * @param proxy interface
      * @return session bean proxy
      */
-    public Object getSessionBeanProxy(Bean<?> bean, Class<?> iface);
+    public Object getSessionBeanProxy(Bean<?> bean, Class<?> iface, CreationalContext<?> creationalContext);
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/JavassistProxyFactory.java Mon Nov 16 23:27:42 2009
@@ -22,6 +22,7 @@
 
 import javassist.util.proxy.ProxyFactory;
 
+import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
 import org.apache.webbeans.annotation.WebBeansAnnotation;
@@ -39,7 +40,7 @@
 
     }
 
-    public static <T> Object createNewProxyInstance(Bean<T> bean)
+    public static Object createNewProxyInstance(Bean<?> bean, CreationalContext<?> creationalContext)
     {
         Object result = null;
         try
@@ -76,7 +77,7 @@
 
             if (!(bean instanceof WebBeansDecorator) && !(bean instanceof WebBeansInterceptor))
             {
-                fact.setHandler(new InterceptorHandler((AbstractBean<?>) bean));
+                fact.setHandler(new InterceptorHandler((AbstractBean<?>) bean, creationalContext));
             }
 
             result = fact.createClass().newInstance();

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProvidedBeansProxyHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProvidedBeansProxyHandler.java?rev=881046&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProvidedBeansProxyHandler.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProvidedBeansProxyHandler.java Mon Nov 16 23:27:42 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.proxy;
+
+import java.lang.reflect.Method;
+
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.apache.webbeans.container.BeanManagerImpl;
+
+import javassist.util.proxy.MethodHandler;
+
+public class ProvidedBeansProxyHandler implements MethodHandler
+{
+    private Bean<?> bean  = null;
+    
+    public ProvidedBeansProxyHandler(Bean<?> bean)
+    {
+        this.bean = bean;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
+    {
+        BeanManager beanManager = BeanManagerImpl.getManager();
+        
+        Context context = beanManager.getContext(bean.getScope());
+        
+        return context.get((Bean<Object>)bean, (CreationalContext<Object>)beanManager.createCreationalContext(bean));
+        
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/ProvidedBeansProxyHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ServiceLoader.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ServiceLoader.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ServiceLoader.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ServiceLoader.java Mon Nov 16 23:27:42 2009
@@ -29,9 +29,7 @@
  * 
  */
 public class ServiceLoader
-{
-    private static OpenWebBeansConfiguration config = OpenWebBeansConfiguration.getInstance();
-    
+{   
     /**
      * Get a new service singleton instance for the given interface.
      * 
@@ -41,7 +39,7 @@
     @SuppressWarnings("unchecked")
     public static <T> T getService(Class<T> serviceInterface)
     {
-        String implName = config.getProperty(serviceInterface.getName());
+        String implName = OpenWebBeansConfiguration.getInstance().getProperty(serviceInterface.getName());
         if (implName == null)
         {
             throw new WebBeansConfigurationException("Cannot find Service configuration for " + 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=881046&r1=881045&r2=881046&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Mon Nov 16 23:27:42 2009
@@ -755,7 +755,9 @@
         conversationComp.addQualifier(new DefaultLiteral());
         conversationComp.addQualifier(new AnyLiteral());
         conversationComp.setName("javax.context.conversation");
-
+        
+        WebBeansDecoratorConfig.configureDecarotors(conversationComp);
+        
         return conversationComp;
     }
     

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java?rev=881046&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java Mon Nov 16 23:27:42 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.newtests.contexts.session.common;
+
+import java.io.Serializable;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+
+@Named("org.apache.webbeans.newtests.contexts.session.common.PersonalDataBean")
+@SessionScoped
+public class PersonalDataBean implements Serializable
+{
+    public static boolean POST_CONSTRUCT = false;
+    
+    public static boolean PRE_DESTROY = false;
+    
+    public PersonalDataBean()
+    {
+        
+    }
+    
+    public void business(){}
+    
+    @PostConstruct
+    public void postConstruct()
+    {
+        POST_CONSTRUCT = true;
+    }
+
+    @PreDestroy
+    public void preDestroy()
+    {
+        PRE_DESTROY = true;
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/common/PersonalDataBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java?rev=881046&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java Mon Nov 16 23:27:42 2009
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.newtests.contexts.session.tests;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.inject.spi.Bean;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.common.AbstractUnitTest;
+import org.apache.webbeans.newtests.contexts.session.common.PersonalDataBean;
+import org.junit.Test;
+
+public class SessionContextTest extends AbstractUnitTest
+{
+    public SessionContextTest()
+    {
+        
+    }
+    
+    @Test
+    public void testPersonalDataBean()
+    {
+        Collection<Class<?>> classes = new ArrayList<Class<?>>();
+        classes.add(PersonalDataBean.class);
+        
+        startContainer(classes);
+        
+        Bean<?> bean = getBeanManager().getBeans("org.apache.webbeans.newtests.contexts.session.common.PersonalDataBean").iterator().next();
+        Object instance = getBeanManager().getReference(bean, PersonalDataBean.class, getBeanManager().createCreationalContext(bean));
+        
+        PersonalDataBean dataBean = (PersonalDataBean)instance;
+        Assert.assertNotNull(dataBean);
+        
+        dataBean.business();
+        
+        Assert.assertTrue(PersonalDataBean.POST_CONSTRUCT);
+                
+        shutDownContainer();
+        
+        Assert.assertTrue(PersonalDataBean.PRE_DESTROY);
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/contexts/session/tests/SessionContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/ConversationDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/ConversationDecorator.java?rev=881046&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/ConversationDecorator.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/ConversationDecorator.java Mon Nov 16 23:27:42 2009
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.newtests.decorators.common;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.context.Conversation;
+
+@Decorator
+public class ConversationDecorator implements Conversation
+{
+    private @Delegate Conversation conversation;
+    
+    public static boolean CALLED = false;
+
+    @Override
+    public void begin()
+    {
+        CALLED = true;
+        conversation.begin();
+    }
+
+    @Override
+    public void begin(String id)
+    {
+        
+        
+    }
+
+    @Override
+    public void end()
+    {
+        
+        
+    }
+
+    @Override
+    public String getId()
+    {
+        
+        return null;
+    }
+
+    @Override
+    public long getTimeout()
+    {
+        
+        return 0;
+    }
+
+    @Override
+    public boolean isTransient()
+    {
+        
+        return false;
+    }
+
+    @Override
+    public void setTimeout(long milliseconds)
+    {
+        
+        
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/common/ConversationDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java?rev=881046&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java Mon Nov 16 23:27:42 2009
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.newtests.decorators.tests;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.common.AbstractUnitTest;
+import org.apache.webbeans.config.OpenWebBeansConfiguration;
+import org.apache.webbeans.newtests.decorators.common.ConversationDecorator;
+import org.apache.webbeans.spi.ServiceLoader;
+import org.apache.webbeans.spi.conversation.ConversationService;
+import org.junit.Test;
+
+public class ConversationDecoratorTest extends AbstractUnitTest
+{
+    public static final String PACKAGE_NAME = ConversationDecoratorTest.class.getPackage().getName();
+    
+    public static class DummyConversationService implements ConversationService
+    {
+
+        @Override
+        public String getConversationId()
+        {
+            return null;
+        }
+
+        @Override
+        public String getConversationSessionId()
+        {
+            return null;
+        }
+        
+    }
+    
+    @Test
+    public void testConversationDecorator()
+    {
+        Collection<Class<?>> classes = new ArrayList<Class<?>>();
+        classes.add(ConversationDecorator.class);
+        
+        Collection<URL> xmls = new ArrayList<URL>();
+        xmls.add(getXMLUrl(PACKAGE_NAME, "ConversationDecoratorTest"));
+        
+        startContainer(classes,xmls);
+        
+        Bean<?> bean = getBeanManager().getBeans(Conversation.class , new AnnotationLiteral<Default>(){}).iterator().next();
+        Object instance = getBeanManager().getReference(bean, Conversation.class, getBeanManager().createCreationalContext(bean));
+        
+        OpenWebBeansConfiguration.getInstance().setProperty("org.apache.webbeans.spi.conversation.ConversationService", DummyConversationService.class.getName());
+
+        Assert.assertTrue(instance instanceof Conversation);
+        Conversation conversation = (Conversation)instance;
+        conversation.begin();
+        
+        Assert.assertTrue(ConversationDecorator.CALLED);
+        
+        shutDownContainer();
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message