users@glassfish.java.net

Re: GF v3: Singleton pass by reference problem

From: <glassfish_at_javadesktop.org>
Date: Tue, 13 Apr 2010 02:18:44 PDT

The third jar (EJBManager.jar) contains:
ManagerBean - imp[lementation of Manager - singleton bean that contains Hash table where registered beans last derived by client (client informs manager by calling init()). I now that it's not good practice to place pieces of the same applications in different jars (no ear). But there are a lot of jars like that contains EJB01Bean and EJB02Bean and when one of them is undeployed or replaced other should not be affected.

Code:
--------------------------------------------------
package test;
import java.util.Hashtable;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
public class ManagerBean implements Manager{
    private Hashtable<String, Registerable> ht;
    public ManagerBean() {
        ht=new Hashtable();
    }
    public void register(String name, Registerable obj) {
        ht.put(name, obj);
    }
    public Registerable get(String name) {
        return ht.get(name);
    }
}
--------------------------------------------------
[Message sent by forum member 'lft']

http://forums.java.net/jive/thread.jspa?messageID=396644