1 Reply Latest reply: Mar 22, 2002 3:36 AM by Trevor Squires RSS

MBeans and Singleton Objects

frank starsinic Newbie

is there any problem with an MBean and other code i write sharing a singleton object?

basically, my mbean listens on a port by connecting to a "Broker" object and acts as a server. i put this into a spearate thread, e.g., my startService() method calls
Thread t = new Thread(this);
t.start();
and my run method loops forever waiting for stuff to do.

I also have a client that shares this same "Broker" object and sends messages to the Broker whenever necessary.

This Broker Object is a Singleton and stays connected
to a remote machine (sort of like a database connection with a pool of 1)

does anyone see a potential problem with this architecture.


thanks,

frank

  • 1. Re: MBeans and Singleton Objects
    Trevor Squires Novice

    Hi Frank,

    your MBean is a java object like any other - there's no additional behaviour (as found in EJBs) that force you to limit your activities.

    Obviously normal VM issues like making sure dynamic classloading doesn't interfere with your conceptual "singleton" need to be addressed. (i.e. "hey, how come I've got 2 Brokers in the VM?" == screwed up dynamic classloading hierarchy).

    Trev