Singletons with EJB3.0 on JBoss 5.1

To create a singleton bean that can be injected into EJB:
– annotated the class with org.jboss.ejb3.annotation.Service
– let the class implement some Local or Remote interface.

Moreover, when you want to perform some setup upon singleton startup, you can:
– create an *MBean interface with void start()
– make singleton implement the interface
– add @Management([interface class]) annotation on singleton class


public interface SingletonExample{}
public interface SingletonExampleMBean {
    void start();
public class SingletonExampleImpl implements SingletonExample, SingletonExampleMBean {
    public void start() {
        // some initialization stuff

More info can be found in: JBoss reference


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s