From dca.pub at gmail.com Sun May 4 00:30:55 2014 From: dca.pub at gmail.com (Daniel Pub) Date: Sun, 4 May 2014 01:30:55 -0300 Subject: [weld-dev] CDI + RequestScoped + thread safety Message-ID: Hi all, I've been developing some code with CDI. I was wondering what happens when I mark a servlet property with @Inject and define the bean with @RequestScoped but the bean class itself is not thread safe but it's a property of my servlet so looking by the servlet perspective it could be accessed by multiple threads. Do we have something that makes these properties accessible to just one request / thread even tough they are servlet's class properties? Thanks, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20140504/e25c80c1/attachment.html From stuart.w.douglas at gmail.com Sun May 4 13:00:48 2014 From: stuart.w.douglas at gmail.com (Stuart Douglas) Date: Sun, 04 May 2014 10:00:48 -0700 Subject: [weld-dev] CDI + RequestScoped + thread safety In-Reply-To: References: Message-ID: <53667240.4030509@gmail.com> This is not the correct mailing list for these questions, this list is for discussing the development of weld. User questions should be asked on the weld forums. What actually gets injected into your servlet is a proxy, and the proxy is thread safe. When a thread calls a method on the proxy Weld looks up the appropriate request scoped instance, and then delegates the invocation to that instance. If two threads are invoking on the same proxy it does not matter, as the underlying instances that the proxy delegates to will be different. Stuart Daniel Pub wrote: > Hi all, > > I've been developing some code with CDI. > > I was wondering what happens when I mark a servlet property with @Inject > and define the bean with @RequestScoped but the bean class itself is not > thread safe but it's a property of my servlet so looking by the servlet > perspective it could be accessed by multiple threads. > > Do we have something that makes these properties accessible to just one > request / thread even tough they are servlet's class properties? > > Thanks, > Daniel > > _______________________________________________ > weld-dev mailing list > weld-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/weld-dev