users@glassfish.java.net

Re: GF v3: Singleton pass by reference problem

From: <glassfish_at_javadesktop.org>
Date: Tue, 13 Apr 2010 02:09:04 PDT

second jar (TestEJB01.jar) contains:
EJB01Bean - implementation of EJB01;
EJB02Bean - implementation of EJB02;

Code:
--------------------------------------------------------
package test;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateful;
@Stateful
public class EJB01Bean implements EJB01, Registerable{
    @EJB Manager manager;
    public void init() {
        manager.register("EJB01", this);
    }
    public void method1(int i) {
        Logger.getLogger(getClass().getName()).severe("method1 i=="+i);
    }
    public void notRemoteMethod(){
        Logger.getLogger(getClass().getName()).severe("notRemoteMethod called.");
    }
}
--------------------------------------------------------
package test;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.Stateful;
@Stateful
public class EJB02Bean implements EJB02, Registerable{
    @EJB Manager manager;
    public void init() {
        manager.register("EJB02", this);
    }
    public void method2(int i) {
        Logger.getLogger(getClass().getName()).severe("method2 i=="+i);
        if (true){ // some kind of user independent clause
            // get last registered by user (init()) EJB01
            EJB01Bean ejb01=(EJB01Bean)manager.get("EJB01");
            //call method
            ejb01.notRemoteMethod();
        }
    }
}
--------------------------------------------------------
[Message sent by forum member 'lft']

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