Hoi! The problem is not that CreationalContext is not thread safe, but that NormalScopedBeanInterceptorHandler is not thread safe if you store the CreationalContext as member variable :)
And yes, I'm eating the provided CreationalContext for NormalScoped bean proxies, because in my opinion it must not get used. The argument: 1.) All contextual instances created within a CreationalContext hierarchy chain will get stored _within_ that CreationalContext (for later being able to #destroy() them) 2.) The CreationalContext will gets stored along with the uppermost contextual instance into the Context (the one who triggered Contextual#create(CreationalContext)), as an example in the JSF ViewMap (ViewScopedContext) 3.) Only @Dependent objects must get stored in the same CreationalContext hierarchy, because they need to get stored on the same storage. 4.) injected @NormalScoped contextual instances must _NOT_ get added to the parents CreationalContext hierarchy chain, because otherwise this would lead to storing them alongside with the uppermost contextual instances CreationalContext. So if a @ViewScoped BeanV gets an @ApplicationScoped BeanA injected, a reference to BeanA would get stored in the ViewMap. And since BeanA is not serializable (application scoped beans most likely aren't) this did lead to the known serialization problems we faced. Imo a @NormalScoped bean _always_ breaks the CreationalContext hierarchy chain and _always_ gets it's own one. I think the whole wording of the CreationalContext in the spec is a bit obsolete and thus misleading now. This is from an area where we didn't have the mandatory proxying requisite in the spec - but never got cleared up properly. LieGrue, strub --- Gurkan Erdogdu <[email protected]> schrieb am Di, 13.4.2010: > Von: Gurkan Erdogdu <[email protected]> > Betreff: Re: svn commit: r933348 - in > /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: > ApplicationScopedBeanIntereptorHandler.java > DependentScopedBeanInterceptorHandler.java InterceptorHandler.java > NormalScopedBeanInterceptorHand > An: [email protected] > Datum: Dienstag, 13. April, 2010 10:11 Uhr > Hi; > > CreationalContext is a thread safe, you have to provide > thread safety when running multiple threads and the most > important object in CreationalContext is objectInstance and > its thread safe. > > There is no problem I have seen. Also, your solution eats > client provided CreatinalContext because you create > CreationalContext instead of using client's CC. > > >>>But there is only ONE instance of > MailService#user! And this will got > hit by 10.000 requests from different users concurrently. > What is the problem here? Where is the location that > CreationalContext is updated by multiple threads and not > thread safe? > > So, I really do no understand why you insist on keeping > wrong code there via some assumptions. It will have some > thread safe problem of CreationalContext but it needs > updating not changing logic. > > --Gurkan > > > > > ________________________________ > From: Mark Struberg <[email protected]> > To: [email protected] > Sent: Tue, April 13, 2010 9:35:04 AM > Subject: Re: svn commit: r933348 - in > /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: > ApplicationScopedBeanIntereptorHandler.java > DependentScopedBeanInterceptorHandler.java > InterceptorHandler.java NormalScopedBeanInterceptorHand > > Gurkan, it's really easy > > the method chain is > NormalScopedBeanInterceptorHandler#invoke > -> super.invoke > -> > NormalScopedBeanInterceptorHandler#aroundInvoke > > and all those functions pass their information NOT by > parameter (super.invoke does it partly) but directly access > NormalScopedBeanInterceptorHandler#creationalContext. > > So since the MethodHandler from an @ApplicationScoped or > @SessionScoped bean may easily get invoked in parallel from > multiple threads, they WILL override each other! > > There is nothing we need to proof with a unit test because > a) this is clear as water > b) such concurrency problems are really hard to proof in a > unit test (you can only 'likely' produce them because we > have no control over thread timing > > The Situation where this may easily occur (and it did > already pretty often on my 4-core workstation and in > production). > > I already posted an example: > > > @SessionScoped public class User [ > public String getEmail().. > } > > @ApplicationScoped class MailService { > private @Inject User usr; > > public void sendMail(String content) { > sendInternal(user.getEmail(), content); > } > } > > > Now imagine you use this MailService in a JSF backing bean > > @RequestScoped > class MailFormBean { > private @Inject MailService mailSvc; > private String content; > ... > > public send() { > mailSvc.sendMail(content); > } > } > > And now consider a webserver with 10.000 different users > clicking on the send button at the same time... > > ALL those MailFormBean instances will use the same instance > of MailService since this is @ApplicationScoped, right? > And the MailService#user is a proxy to the User, still ok? > But there is only ONE instance of MailService#user! And > this will got hit by 10.000 requests from different users > concurrently. > > That's why my change simply passes the CreationalContext > around as parameter. > > I will go on and revert the change back. > > LieGrue, > strub > > --- Gurkan Erdogdu <[email protected]> > schrieb am Di, 13.4.2010: > > > Von: Gurkan Erdogdu <[email protected]> > > Betreff: Re: svn commit: r933348 - in > /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: > ApplicationScopedBeanIntereptorHandler.java > DependentScopedBeanInterceptorHandler.java > InterceptorHandler.java NormalScopedBeanInterceptorHand > > An: [email protected] > > Datum: Dienstag, 13. April, 2010 00:18 Uhr > > As long as the CreationalContext > > related with the bean is in the > > AbstractContext#CreationalContextMap, no thread can > > override it, just use > > old creational context. > > > > 2010/4/13 Gurkan Erdogdu <[email protected]> > > > > > >>>....But if in the meantime _another_ > > thread overwrites this > > > NormalScopedBeanInterceptorHan > > > >>>dler.creationalContext (by using the > same > > proxy instance), then we get > > > into troubles. > > > > > > Where is the location of this code, i.e > _another_ > > thread overwrites this > > > > NormalScopedBeanInterceptorHandler.creationalContext > > > > > > Thanks; > > > > > > --Gurkan > > > > > > > > > 2010/4/13 Mark Struberg <[email protected]> > > > > > > This makes no difference, really. > > >> The problem is that we store a > CreationalContext > > as a member in > > >> NormalScopedBeanInterceptorHandler. And > subsequent > > function calls rely on > > >> it. But if in the meantime _another_ thread > > overwrites this > > >> > > NormalScopedBeanInterceptorHandler.creationalContext > (by > > using the same > > >> proxy instance), then we get into troubles. > > >> > > >> Tbis is hard to debug and write tests for, > but > > this is really obvious from > > >> looking at the code. And I already had this > > problem in my apps. It's not > > >> funny to randomly pickup instances from > other > > sessions... > > >> > > >> LieGrue, > > >> strub > > >> > > >> --- Gurkan Erdogdu <[email protected]> > > schrieb am Mo, 12.4.2010: > > >> > > >> > Von: Gurkan Erdogdu <[email protected]> > > >> > Betreff: Re: svn commit: r933348 - in > > >> > > > /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: > > >> ApplicationScopedBeanIntereptorHandler.java > > >> DependentScopedBeanInterceptorHandler.java > > InterceptorHandler.java > > >> NormalScopedBeanInterceptorHand > > >> > An: [email protected] > > >> > Datum: Montag, 12. April, 2010 22:29 > Uhr > > >> > Please look at AbstractContext, > > >> > creationalContextMap#putIfAbsent call > > >> > > > >> > 2010/4/12 Mark Struberg <[email protected]> > > >> > > > >> > > Sorry, I think we need to rollback > the > > rollback, since > > >> > this re-introduces > > >> > > really heavy concurrency problems. > > >> > > > > >> > > @SessionScoped public class User [ > > >> > > public String getEmail().. > > >> > > } > > >> > > > > >> > > @ApplicationScoped class > MailService { > > >> > > private @Inject User usr; > > >> > > > > >> > > public void sendMail(String > > content) { > > >> > > > > sendInternal(user.getEmail(), content); > > >> > > } > > >> > > } > > >> > > > > >> > > now, with this change whenever 2 > threads > > (from 2 > > >> > sessions of a webserver) > > >> > > invoke sendMail and hit the > > user.getEmail() the > > >> > > NormalScopedBeanInterceptorHandler > gets > > called and > > >> > those 2 threads override > > >> > > each other the > > >> > > private transient > > >> > > > WeakReference<CreationalContext<?>> > > >> > creationalContext = > > >> > > null; > > >> > > because there is only one single > proxy > > instance being > > >> > used by those 2 > > >> > > threads. > > >> > > > > >> > > Got me? > > >> > > > > >> > > LieGrue, > > >> > > strub > > >> > > > > >> > > --- [email protected] > > >> > <[email protected]> > > >> > schrieb am Mo, 12.4.2010: > > >> > > > > >> > > > Von: [email protected] > > >> > <[email protected]> > > >> > > > Betreff: svn commit: r933348 - > in > > >> > > > > >> > > > >> > > > /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: > > >> > > > > ApplicationScopedBeanIntereptorHandler.java > > >> > > > > DependentScopedBeanInterceptorHandler.java > > >> > InterceptorHandler.java > > >> > > > NormalScopedBeanInterceptorHandler.java > > >> > > > An: [email protected] > > >> > > > Datum: Montag, 12. April, > 2010 > > 20:20 Uhr > > >> > > > Author: gerdogdu > > >> > > > Date: Mon Apr 12 18:20:06 > 2010 > > >> > > > New Revision: 933348 > > >> > > > > > >> > > > URL: http://svn.apache.org/viewvc?rev=933348&view=rev > > >> > > > Log: > > >> > > > [OWB-351] OWB picks up > > @SessionScoped contextual > > >> > instances > > >> > > > from expired sessions. > Corrects > > eating client > > >> > provided > > >> > > > creational context via > > BeanManager#getReference > > >> > > > > > >> > > > 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/DependentScopedBeanInterceptorHandler.java > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/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=933348&r1=933347&r2=933348&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 > > >> > > > Mon Apr 12 18:20:06 2010 > > >> > > > @@ -21,7 +21,6 @@ package > > >> > org.apache.webbeans.intercept; > > >> > > > import > > >> > > > javax.enterprise.context.spi.CreationalContext; > > >> > > > > > >> > > > import > > >> > org.apache.webbeans.component.OwbBean; > > >> > > > -import > > >> > > > > > >> > > > > org.apache.webbeans.context.creational.CreationalContextImpl; > > >> > > > > > >> > > > > > >> > > > /** > > >> > > > @@ -43,7 +42,7 @@ public > class > > >> > ApplicationScopedBeanIntere > > >> > > > /** > > >> > > > > * > > Creates a new > > >> > handler. > > >> > > > > * > > @param bean > > >> > bean > > >> > > > - * > @param > > >> > creationalContext > > >> > > > creational context > > >> > > > + * > @param > > >> > creationalContext > > >> > > > creaitonal context > > >> > > > > */ > > >> > > > public > > >> > > > > > >> > > > > ApplicationScopedBeanIntereptorHandler(OwbBean<?> > > >> > > > bean, > CreationalContext<?> > > >> > creationalContext) > > >> > > > { > > >> > > > @@ -53,11 +52,11 @@ public > class > > >> > > > ApplicationScopedBeanIntere > > >> > > > /** > > >> > > > > * > > {...@inheritdoc} > > >> > > > > */ > > >> > > > - protected > Object > > >> > > > > > getContextualInstance(OwbBean<Object> > > >> > bean, > > >> > > > > CreationalContextImpl<?> > > >> > creationalContext) > > >> > > > + protected > Object > > >> > > > > > getContextualInstance(OwbBean<Object> > > >> > bean) > > >> > > > { > > >> > > > > > > if > > >> > (cachedInstance > > >> > > > == null) > > >> > > > > > > { > > >> > > > - > > >> > cachedInstance = > > >> > > > > super.getContextualInstance(bean, > > >> > creationalContext); > > >> > > > + > > >> > cachedInstance = > > >> > > > > super.getContextualInstance(bean); > > >> > > > > > > } > > >> > > > > > >> > > > > > > return > > >> > > > cachedInstance; > > >> > > > > > >> > > > Modified: > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java > > >> > > > URL: > > >> > > > > >> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java?rev=933348&r1=933347&r2=933348&view=diff > > >> > > > > > >> > > > > >> > > > >> > > > ============================================================================== > > >> > > > --- > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java > > >> > > > (original) > > >> > > > +++ > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java > > >> > > > Mon Apr 12 18:20:06 2010 > > >> > > > @@ -67,12 +67,10 @@ public > class > > >> > > > DependentScopedBeanIntercep > > >> > > > /** > > >> > > > > * > > {...@inheritdoc} > > >> > > > > */ > > >> > > > - protected > Object > > >> > callAroundInvokes(Method > > >> > > > proceed, Object[] arguments, > > >> > List<InterceptorData> > > >> > > > stack, > > >> > > > - > > >> > > > > > >> > > > > > >> > > > > > CreationalContextImpl<?> cc) > > >> > > > - throws > Exception > > >> > > > + protected > Object > > >> > callAroundInvokes(Method > > >> > > > proceed, Object[] arguments, > > >> > List<InterceptorData> > > >> > > > stack) throws Exception > > >> > > > { > > >> > > > > > >> > > > > InvocationContextImpl > > impl = new > > >> > > > > InvocationContextImpl(this.bean, > > >> > this.actualInstance > > >> > > > ,proceed, arguments, stack, > > >> > InterceptorType.AROUND_INVOKE); > > >> > > > - > > >> > > > > impl.setCreationalContext(cc); > > >> > > > + > > >> > > > > > impl.setCreationalContext(creationalContext); > > >> > > > > > >> > > > > > > return > > >> > > > impl.proceed(); > > >> > > > } > > >> > > > > > >> > > > Modified: > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java > > >> > > > URL: > > >> > > > > >> http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=933348&r1=933347&r2=933348&view=diff > > >> > > > > > >> > > > > >> > > > >> > > > ============================================================================== > > >> > > > --- > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java > > >> > > > (original) > > >> > > > +++ > > >> > > > > > >> > > > > >> > > > >> > > > openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java > > >> > > > Mon Apr 12 18:20:06 2010 > > >> > > > @@ -169,13 +169,11 @@ public > > abstract class > > >> > > > InterceptorHandler > > >> > > > > * > > @param method > > >> > business method > > >> > > > > * > > @param proceed > > >> > proceed method > > >> > > > > * > > @param arguments > > >> > method arguments > > >> > > > - * > @param > > >> > creationalContext bean > > >> > > > creational context > > >> > > > + * > @param > > >> > ownerCreationalContext > > >> > > > bean creational context > > >> > > > > * > > @return method > > >> > result > > >> > > > > * > > @throws > > >> > Exception for exception > > >> > > > > */ > > >> > > > - public Object > > invoke(Object > > >> > instance, Method > > >> > > > method, Method proceed, > Object[] > > arguments, > > >> > > > - > > >> > > > > > >> > > > > > CreationalContextImpl<?> > > >> > > > creationalContext) > > >> > > > - throws > Exception > > >> > > > + public Object > > invoke(Object > > >> > instance, Method > > >> > > > method, Method proceed, > Object[] > > arguments, > > >> > > > > CreationalContextImpl<?> > > >> > ownerCreationalContext) > > >> > > > throws Exception > > >> > > > { > > >> > > > > > > //Result of > > >> > > > invocation > > >> > > > > > > Object result > > >> > = > > >> > > > null; > > >> > > > @@ -212,7 +210,7 @@ public > abstract > > class > > >> > > > InterceptorHandler > > >> > > > > > >> > > > > > >> > > > > > >> > > > > ((ProxyObject)delegate).setHandler(this.delegateHandler); > > >> > > > > > >> > > > > > >> > > > > > > // Gets > > >> > component > > >> > > > decorator stack > > >> > > > - > > >> > > > > > decorators > > >> > = > > >> > > > > > >> > > > > WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, > > >> > > > instance, delegate, > > creationalContext); > > >> > > > > > >> > > > > > >> > > > + > > >> > > > > > decorators > > >> > = > > >> > > > > > >> > > > > WebBeansDecoratorConfig.getDecoratorStack(injectionTarget, > > >> > > > instance, delegate, > > ownerCreationalContext); > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > > //Sets > > >> > decorator > > >> > > > stack of delegate > > >> > > > > > >> > > > > > >> > > > > > >> > > > this.delegateHandler.setDecorators(decorators); > > >> > > > > > >> > > > > > >> > > > @@ -249,10 +247,7 @@ public > > abstract class > > >> > > > InterceptorHandler > > >> > > > > > >> > > > > > > // Call Around > > >> > > > Invokes > > >> > > > > > >> > > > > > > if > > >> > > > > > >> > > > > >> > > > >> > > > (WebBeansUtil.isContainsInterceptorMethod(this.interceptedMethodMap.get(method), > > >> > > > > InterceptorType.AROUND_INVOKE)) > > >> > > > > > >> > > > > > > { > > >> > > > - > > >> > > > > > >> > return > > >> > > > callAroundInvokes(method, > > arguments, > > >> > > > - > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > InterceptorUtil.getInterceptorMethods(this.interceptedMethodMap.get(method), > > >> > > > - > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > InterceptorType.AROUND_INVOKE), > > >> > > > - > > >> > > > > > >> > > > > > >> > > > > > creationalContext); > > >> > > > + > > >> > > > > > >> > return > > >> > > > callAroundInvokes(method, > > arguments, > > >> > > > > > >> > > > > >> > > > >> > > > InterceptorUtil.getInterceptorMethods(this.interceptedMethodMap.get(method), > > >> > > > > InterceptorType.AROUND_INVOKE)); > > >> > > > > > >> > > > > > > } > > >> > > > > > >> > > > > > >> > > > > > >> > > > } > > >> > > > @@ -307,9 +302,7 @@ public > abstract > > class > > >> > > > InterceptorHandler > > >> > > > > * > > @return return > > >> > of method > > >> > > > > * > > @throws > > >> > Exception for any exception > > >> > > > > */ > > >> > > > - protected > abstract > > Object > > >> > > > callAroundInvokes(Method > > interceptedMethod, > > >> > Object[] > > >> > > > arguments, > > >> > > > - > > >> > > > > > >> > > > > > >> > > > List<InterceptorData> > stack, > > >> > > > > CreationalContextImpl<?> > > >> > creationalContext) > > >> > > > - throws > Exception; > > >> > > > + protected > abstract > > Object > > >> > > > callAroundInvokes(Method > > interceptedMethod, > > >> > Object[] > > >> > > > arguments, > > List<InterceptorData> stack) > > >> > throws > > >> > > > Exception; > > >> > > > > > >> > > > /** > > >> > > > > * > > >> > > > > > >> > > > 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=933348&r1=933347&r2=933348&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 > > >> > > > Mon Apr 12 18:20:06 2010 > > >> > > > @@ -18,6 +18,7 @@ > > >> > > > */ > > >> > > > package > > org.apache.webbeans.intercept; > > >> > > > > > >> > > > +import > > java.lang.ref.WeakReference; > > >> > > > import > > java.lang.reflect.Method; > > >> > > > import java.util.List; > > >> > > > > > >> > > > @@ -42,6 +43,9 @@ public > class > > >> > NormalScopedBeanInterceptor > > >> > > > /**Serial > id*/ > > >> > > > private > static > > final long > > >> > > > serialVersionUID = 1L; > > >> > > > > > >> > > > + /**Creational > > context*/ > > >> > > > + private > transient > > >> > > > > > WeakReference<CreationalContext<?>> > > >> > > > creationalContext = null; > > >> > > > + > > >> > > > /** > > >> > > > > * > > Creates a new > > >> > bean instance > > >> > > > > * > > @param bean > > >> > bean > > >> > > > @@ -50,6 +54,7 @@ public > class > > >> > NormalScopedBeanInterceptor > > >> > > > public > > >> > > > > > >> > > > NormalScopedBeanInterceptorHandler(OwbBean<?> > bean, > > >> > > > CreationalContext<?> > > creationalContext) > > >> > > > { > > >> > > > > > > super(bean); > > >> > > > + > > >> > this.creationalContext = new > > >> > > > > > >> > > > > WeakReference<CreationalContext<?>>(creationalContext); > > >> > > > } > > >> > > > > > >> > > > /** > > >> > > > @@ -58,38 +63,21 @@ public > class > > >> > > > NormalScopedBeanInterceptor > > >> > > > @Override > > >> > > > public > Object > > invoke(Object > > >> > > > instance, Method method, > Method > > proceed, Object[] > > >> > arguments) > > >> > > > throws Exception > > >> > > > { > > >> > > > - > > >> > CreationalContextImpl<?> > > >> > > > creationalContext = null; > > >> > > > - > > >> > > > - > > > //Context of the > > >> > bean > > >> > > > - > > > Context > > >> > webbeansContext = > > >> > > > > > getBeanManager().getContext(bean.getScope()); > > >> > > > - > > >> > > > - > if > > (webbeansContext > > >> > instanceof > > >> > > > AbstractContext) > > >> > > > - > { > > >> > > > - > > >> > > > creationalContext = > > >> > (CreationalContextImpl<?>) > > >> > > > > > >> > > > > ((AbstractContext)webbeansContext).getCreationalContext(bean); > > >> > > > - > } > > >> > > > - > if > > >> > (creationalContext == > > >> > > > null) > > >> > > > - > { > > >> > > > - > > > // if > > >> > there was > > >> > > > no CreationalContext set from > > external, we create > > >> > a new one > > >> > > > - > > >> > > > creationalContext = > > >> > (CreationalContextImpl<?>) > > >> > > > > > >> > > > > CreationalContextFactory.getInstance().getCreationalContext(bean); > > >> > > > - > } > > >> > > > - > > >> > > > > > > //Get instance > > >> > from > > >> > > > context > > >> > > > - > > > Object > > >> > webbeansInstance = > > >> > > > > > getContextualInstance((OwbBean<Object>) > > >> > this.bean, > > >> > > > creationalContext); > > >> > > > + > > > Object > > >> > webbeansInstance = > > >> > > > > > getContextualInstance((OwbBean<Object>) > > >> > this.bean); > > >> > > > > > >> > > > > > > //Call super > > >> > > > - > > > return > > >> > > > > super.invoke(webbeansInstance, > > method, proceed, > > >> > arguments, > > >> > > > creationalContext); > > >> > > > + > > > return > > >> > > > > super.invoke(webbeansInstance, > > method, proceed, > > >> > arguments, > > >> > > > > (CreationalContextImpl<?>) > > >> > > > > this.creationalContext.get()); > > >> > > > } > > >> > > > > > >> > > > /** > > >> > > > > * > > {...@inheritdoc} > > >> > > > > */ > > >> > > > - protected > Object > > >> > callAroundInvokes(Method > > >> > > > proceed, Object[] arguments, > > >> > List<InterceptorData> > > >> > > > stack, > > CreationalContextImpl<?> > > >> > creationalContext) > > >> > > > - throws > Exception > > >> > > > + protected > Object > > >> > callAroundInvokes(Method > > >> > > > proceed, Object[] arguments, > > >> > List<InterceptorData> > > >> > > > stack) throws Exception > > >> > > > { > > >> > > > - > > >> > InvocationContextImpl impl = > > >> > > > new > > InvocationContextImpl(this.bean, > > >> > > > - > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > getContextualInstance((OwbBean<Object>) > > >> > > > this.bean, > creationalContext), > > >> > > > + > > >> > InvocationContextImpl impl = > > >> > > > new > > InvocationContextImpl(this.bean, > > >> > > > > > getContextualInstance((OwbBean<Object>) > > >> > this.bean), > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > proceed, arguments, stack, > > >> > InterceptorType.AROUND_INVOKE); > > >> > > > - > > >> > > > > > impl.setCreationalContext(creationalContext); > > >> > > > + > > >> > > > > > >> > > > impl.setCreationalContext(creationalContext.get()); > > >> > > > > > >> > > > > > > return > > >> > > > impl.proceed(); > > >> > > > > > >> > > > @@ -99,10 +87,9 @@ public > class > > >> > > > NormalScopedBeanInterceptor > > >> > > > /** > > >> > > > > * > > Gets instance > > >> > from context. > > >> > > > > * > > @param bean bean > > >> > instance > > >> > > > - * > @param > > >> > creationalContext > > >> > > > > * > > @return the > > >> > underlying contextual > > >> > > > instance, either cached or > resolved > > from the > > >> > context > > >> > > > > */ > > >> > > > - protected > Object > > >> > > > > > getContextualInstance(OwbBean<Object> > > >> > bean, > > >> > > > > CreationalContextImpl<?> > > >> > creationalContext) > > >> > > > + protected > Object > > >> > > > > > getContextualInstance(OwbBean<Object> > > >> > bean) > > >> > > > { > > >> > > > > > > Object > > >> > > > webbeansInstance = null; > > >> > > > > > >> > > > @@ -117,8 +104,22 @@ public > class > > >> > > > NormalScopedBeanInterceptor > > >> > > > > > >> > return > > >> > > > webbeansInstance; > > >> > > > > > > } > > >> > > > > > >> > > > + > if > > (webbeansContext > > >> > instanceof > > >> > > > AbstractContext) > > >> > > > + > { > > >> > > > + > > >> > > > CreationalContext<?> cc > = > > >> > > > > > >> > > > > ((AbstractContext)webbeansContext).getCreationalContext(bean); > > >> > > > + > > > if (cc > > >> > != null) > > >> > > > + > > > { > > >> > > > + > > >> > > > creationalContext = new > > >> > > > > > >> > > > WeakReference<CreationalContext<?>>(cc); > > >> > > > + > > > } > > >> > > > + > } > > >> > > > + > if > > >> > (creationalContext == > > >> > > > null) > > >> > > > + > { > > >> > > > + > > > // if > > >> > there was > > >> > > > no CreationalContext set from > > external, we create > > >> > a new one > > >> > > > + > > >> > > > creationalContext = new > > >> > > > > > >> > > > > >> > > > >> > > > WeakReference<CreationalContext<?>>(CreationalContextFactory.getInstance().getCreationalContext(bean)); > > >> > > > + > } > > >> > > > + > > >> > > > > > > // finally, we > > >> > > > create a new contextual > instance > > >> > > > - > > > webbeansInstance = > > >> > > > > > >> > > > > webbeansContext.get((Contextual<Object>)this.bean, > > >> > > > > (CreationalContext<Object>) > > >> > creationalContext); > > >> > > > + > > > webbeansInstance = > > >> > > > > > >> > > > > webbeansContext.get((Contextual<Object>)this.bean, > > >> > > > > (CreationalContext<Object>) > > >> > creationalContext.get()); > > >> > > > > > >> > > > > > > return > > >> > > > webbeansInstance; > > >> > > > } > > >> > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > > __________________________________________________ > > >> > > Do You Yahoo!? > > >> > > Sie sind Spam leid? Yahoo! Mail > verfügt > > über einen > > >> > herausragenden Schutz > > >> > > gegen Massenmails. > > >> > > http://mail.yahoo.com > > >> > > > > >> > > > >> > > > >> > > > >> > -- > > >> > Gurkan Erdogdu > > >> > http://gurkanerdogdu.blogspot.com > > >> > > > >> > > >> > > >> > > __________________________________________________ > > >> Do You Yahoo!? > > >> Sie sind Spam leid? Yahoo! Mail verfügt > über > > einen herausragenden Schutz > > >> gegen Massenmails. > > >> http://mail.yahoo.com > > >> > > > > > > > > > > > > -- > > > Gurkan Erdogdu > > > http://gurkanerdogdu.blogspot.com > > > > > > > > > > > -- > > Gurkan Erdogdu > > http://gurkanerdogdu.blogspot.com > > > > __________________________________________________ > Do You Yahoo!? > Sie sind Spam leid? Yahoo! Mail verfügt über einen > herausragenden Schutz gegen Massenmails. > http://mail.yahoo.com > > > > > ___________________________________________________________________ > Yahoo! Türkiye açıldı! http://yahoo.com.tr > İnternet üzerindeki en iyi içeriği Yahoo! Türkiye > sizlere sunuyor! __________________________________________________ Do You Yahoo!? Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. http://mail.yahoo.com
