It's not a secret anymore!
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes @Singleton and @Stateless Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "@Singleton and @Stateless" Watch "@Singleton and @Stateless" New topic

@Singleton and @Stateless

Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117

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

Joined: Jul 10, 2002
Posts: 214

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

I agree. Here's the link:
subject: @Singleton and @Stateless
It's not a secret anymore!