1 22 package org.jboss.test.cluster.ejb; 23 24 import java.rmi.RemoteException ; 25 import java.rmi.dgc.VMID ; 26 import java.util.Properties ; 27 import javax.ejb.SessionBean ; 28 import javax.ejb.SessionContext ; 29 import javax.ejb.CreateException ; 30 import javax.naming.InitialContext ; 31 import javax.naming.Context ; 32 import javax.rmi.PortableRemoteObject ; 33 34 import org.jboss.logging.Logger; 35 36 42 public class CalledBean implements SessionBean 43 { 44 private static Logger log = Logger.getLogger(CalledBean.class); 45 private static VMID vmid = new VMID (); 46 47 public void ejbCreate() throws CreateException 48 { 49 log.debug("ejbCreate() called"); 50 } 51 52 public void ejbActivate() 53 { 54 log.debug("ejbActivate() called"); 55 } 56 57 public void ejbPassivate() 58 { 59 log.debug("ejbPassivate() called"); 60 } 61 62 public void ejbRemove() 63 { 64 log.debug("ejbRemove() called"); 65 } 66 67 public void setSessionContext(SessionContext context) 68 { 69 } 70 71 73 public VMID [] invokeCall(String jndiURL, String jndiName) 74 throws RemoteException 75 { 76 log.info("invokeCall, jndiURL="+jndiURL+", jndiName="+jndiName); 77 VMID [] ids = {vmid, null}; 78 try 79 { 80 Properties props = new Properties (); 81 props.setProperty(Context.PROVIDER_URL, jndiURL); 82 InitialContext ic = new InitialContext (props); 83 Object ref = ic.lookup(jndiName); 84 CalleeHome localHome = (CalleeHome) PortableRemoteObject.narrow(ref, 85 CalleeHome.class); 86 CalleeRemote remoteBean = localHome.create(); 87 ids[1] = remoteBean.call("invokeCall"); 88 log.info("echo, CalleeRemote.call="+ids[1]+", vmid="+ids[0]); 89 } 90 catch(Exception e) 91 { 92 log.error("Failed to invoke CalleeRemote.call", e); 93 throw new RemoteException ("Failed to invoke CalleeRemote.call", e); 94 } 95 return ids; 96 } 97 98 } 99 | Popular Tags |