1 22 package org.jboss.test.testbeancluster.bean; 23 24 import java.rmi.RemoteException ; 25 import javax.ejb.SessionBean ; 26 import javax.ejb.EJBException ; 27 import javax.ejb.SessionContext ; 28 import javax.naming.InitialContext ; 29 30 import org.jboss.test.testbeancluster.interfaces.StatelessSessionHome; 31 import org.jboss.test.testbeancluster.interfaces.StatelessSession; 32 33 public class StatelessSessionBean implements SessionBean 34 { 35 public static long numberOfCalls = 0; 36 37 public void ejbCreate() 38 { 39 } 40 public void ejbActivate() throws EJBException , RemoteException 41 { 42 } 43 44 public void ejbPassivate() throws EJBException , RemoteException 45 { 46 } 47 48 public void ejbRemove() throws EJBException , RemoteException 49 { 50 } 51 52 public void setSessionContext(SessionContext ctx) throws EJBException , RemoteException 53 { 54 } 55 56 public void callBusinessMethodA() 57 { 58 numberOfCalls++; 59 } 60 61 public String callBusinessMethodB(String jndiURL) 62 { 63 numberOfCalls++; 64 String rtn = "callBusinessMethodB-" + numberOfCalls; 65 testColocation(jndiURL); 66 return rtn; 67 } 68 69 public void testColocation(String jndiURL) 70 { 71 try 72 { 73 System.out.println("begin testColocation"); 74 InitialContext ctx = new InitialContext (); 75 if( jndiURL == null ) 76 jndiURL = "jnp://" + System.getProperty("jboss.bind.address", "localhost") + ":1100/nextgen_StatelessSession"; 77 StatelessSessionHome home = (StatelessSessionHome) ctx.lookup(jndiURL); 78 StatelessSession session = home.create(); 79 session.callBusinessMethodA(); 80 System.out.println("end testColocation"); 81 } 82 catch (Exception ex) 83 { 84 ex.printStackTrace(); 85 } 86 87 } 88 89 public void resetNumberOfCalls () 90 { 91 System.out.println("Number of calls has been reseted"); 92 numberOfCalls = 0; 93 } 94 95 public void makeCountedCall () 96 { 97 System.out.println("makeCountedCall called"); 98 numberOfCalls++; 99 } 100 101 public long getCallCount () 102 { 103 System.out.println("getCallCount called"); 104 return numberOfCalls; 105 } 106 107 public String getBindAddress() 108 { 109 return System.getProperty("jboss.bind.address"); 110 } 111 112 } 113 | Popular Tags |