Use @Singleton, not @Stateless

Something I’ve been musing over in the background for some time. This is not revolutionary.

In almost any circumstance that I can think of, you probably want to be using @Singleton EJBs, not @Stateless EJBs.

In this day and age with these JVMs and these JITs, the object pooling mechanisms which seemed so necessary back in the EJB 1.x days seem laughable now.

In addition, if you’re careful, you can use concurrent utilities in your @Singleton as well, whereas the specification prevents you from doing so in any other bean type.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s