I think this is not correct! You can not create CreationalContext via null checking. CreationalContext is used by the container when any clients call getReference in BeanManager and managed by the container.
I was so tired to explain again and again same things that never changes something sorry! --Gurkan ________________________________ From: "[email protected]" <[email protected]> To: [email protected] Sent: Wed, March 24, 2010 8:57:45 PM Subject: svn commit: r927155 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java NormalScopedBeanInterceptorHandler.java Author: struberg Date: Wed Mar 24 18:57:45 2010 New Revision: 927155 URL: http://svn.apache.org/viewvc?rev=927155&view=rev Log: OWB-329 fix serialization and CreationalContext issues in NormalScoped interceptors We can easily drop the CreationalContext in the NormalScoped interceptors, because we only need it if the contextual instance doesn't already exist. In this case, the new @NormalScoped contextual instance needs to get a new CreationalContext anyway! Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java?rev=927155&r1=927154&r2=927155&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java Wed Mar 24 18:57:45 2010 @@ -37,7 +37,7 @@ public class ApplicationScopedBeanIntere private static final long serialVersionUID = 1L; /**Cached bean instance*/ - private Object cachedInstance = null; + private transient Object cachedInstance = null; /** * Creates a new handler. Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java?rev=927155&r1=927154&r2=927155&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java (original) +++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java Wed Mar 24 18:57:45 2010 @@ -26,7 +26,7 @@ import javax.enterprise.context.spi.Cont import javax.enterprise.context.spi.CreationalContext; import org.apache.webbeans.component.OwbBean; -import org.apache.webbeans.context.AbstractContext; +import org.apache.webbeans.context.creational.CreationalContextFactory; import org.apache.webbeans.context.creational.CreationalContextImpl; /** @@ -41,7 +41,7 @@ public class NormalScopedBeanInterceptor private static final long serialVersionUID = 1L; /**Creational context*/ - private CreationalContext<?> creationalContext; + private transient CreationalContext<?> creationalContext; /** * Creates a new bean instance @@ -93,17 +93,21 @@ public class NormalScopedBeanInterceptor //Context of the bean Context webbeansContext = getBeanManager().getContext(bean.getScope()); - //Already saved in context - if((webbeansInstance=webbeansContext.get(bean)) != null) + //Already saved in context? + webbeansInstance=webbeansContext.get(bean); + if (webbeansInstance != null) { - CreationalContext<Object> creational = ((AbstractContext)webbeansContext).getCreationalContext(bean); - if (creational != null) - { - this.creationalContext = creational; - } + // voila, we are finished if we found an existing contextual instance + return webbeansInstance; } - - //create a new instance + + if (creationalContext == null) + { + // if there was no CreationalContext set from external, we create a new one + creationalContext = CreationalContextFactory.getInstance().getCreationalContext(bean); + } + + // finally, we create a new contextual instance webbeansInstance = webbeansContext.get((Contextual<Object>)this.bean, (CreationalContext<Object>) creationalContext); return webbeansInstance; ___________________________________________________________________ Yahoo! Türkiye açıldı! http://yahoo.com.tr İnternet üzerindeki en iyi içeriği Yahoo! Türkiye sizlere sunuyor!
