*
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
Author

@Singleton and @Stateless

Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117
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

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


SCJP, SCWCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: @Singleton and @Stateless
 
Similar Threads
why stateless bean is not singleton
Stateless Session Bean Problems Singleton
Doubt about ejbCreate() for stateless session bean
Pooling stateless session beans vs singleton approach
EJB3 and the Singleton