3 Replies Latest reply on Jul 27, 2004 3:36 AM by adco

    How to implement a global persistent singleton in a stateful

    adco

      Hi,

      I use a Java-To-COM bridge in a statefull session bean and I MUST manage here an object (a java handler class containing the reference to the COM object) like a global object over all session beans.

      I tryied this by implementing a singleton class as an attribute of the session bean, but I get an exception when the bean will be passivated - the bridging classes use sockets to communicate to COM :-(

      I cannot destroy and recreate the COM-handler class, because this will
      destroy and recreate the COM object. I need here something like an unremovable singleton object that act like a server or for my session bean.

      Any ideas how to solve this problem ?

      Best thanks in advance,

      Adrian

        • 1. Re: How to implement a global persistent singleton in a stat
          jamesstrachan

          Adrian,

          I suspect that you will need to code and deploy your socket link to COM as a JMX MBean - rather like a database source.

          But I've never tried this. Anyone from JBoss who can contribute ?

          James

          • 2. Re: How to implement a global persistent singleton in a stat
            psevestre

            I'm using the approach sugested by jamesstrachan in a my current project.

            In my case, I have some hardware devices (pinpad, magnetic card reader, printer) which are all accessed via JMX MBeans.

            Upon deployment, those MBeans register themselves on JNDI, so other parts of the system can have acess to them.

            For each device, I choosed to define two different interfaces: a Management interface, which is accessible via the standard jmx-console and used to setup parameters like hardware ports and like; and a Operation interface which exposes high level services associated with the device (eg. for a pinpad I have operations such as getPin(), setMasterKey() and so forth).

            • 3. Re: How to implement a global persistent singleton in a stat
              adco

              Thanks a lot. I have deployed an JMX MBean and I think I'm on the right way to manage my problem. I will post a message back after - hopefully - succesfull - complete this step.

              Adrian