Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@Singleton and @Stateless

 
Shankar sanjay
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can any one explain when to use singleton and when to use stateless?

I am clear that stateless bean will be created by the container based on bandwidth(number of request using the created bean).

But i am not quite clear how singleton is related to stateless bean?

Can you please explain?
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A singleton is a type of stateless session bean that is instantiated once and only once per application per JVM. I think the main use case is to share state between components in an application. Basically the same use case as the standard singleton pattern, or anti-pattern depending on your point of view.

A singleton might be a good choice for running some piece of code on a periodic basis, for example.

Check this thread

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic