This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Injection creates a new instance of stateless bean or reuse an instance?  RSS feed

 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p.430 of JSR 318

lookups of objects in the JNDI java: namespace are required to return a new instance of the requested object every time....
... a new instance of the requested object must be returned on each lookup.



But will the container inject a stateless bean that has been already existing in the bean pool instead of creating a new stateless bean?
If the container reuse a stateless bean and injects it , will the container violate the specification?
 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the discussion on Enthuware Forum :http://enthuware.com/forum/viewtopic.php?f=4&t=479

A stateless bean is shared. So, the container will not create a new instance of a stateless bean all the time upon a dependency injection.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!