1 Reply Latest reply on Feb 1, 2005 9:27 AM by Gerald Quintana

    Class with Singleton design pattern shared by 2 applications

    Gerald Quintana Newbie


      I have a singleton class which looks like

      public class MySingleton [
       private MySingleton() {
       System.out.println("Init MySingleton");
       private static MySingleton singleton;
       public static synchronized MySingleton getSingleton() {
       if (singleton == null) {
       singleton = new MySingleton();

      This class is deployed twice in the same JBoss 4.0.1 server
      - once in MyApp1.ear/MyEJB1.jar
      - another time in MyApp2.ear/MyEJB2.jar

      I noticed there was only one instance of these classes for both MyApp1 and MyApp2 (as a result MyApp2 can access data from MyApp1!). I would I like each application to have its own instance, how can I do that?

      Thanks for your help,