1 22 package org.jboss.test.web.ejb; 23 24 import javax.naming.InitialContext ; 25 import javax.ejb.CreateException ; 26 import javax.ejb.EJBException ; 27 import javax.ejb.SessionBean ; 28 import javax.ejb.SessionContext ; 29 30 import org.jboss.test.web.interfaces.ReferenceTest; 31 import org.jboss.test.web.interfaces.StatelessSession; 32 import org.jboss.test.web.interfaces.StatelessSessionHome; 33 import org.jboss.test.web.interfaces.ReturnData; 34 import org.jboss.logging.Logger; 35 36 41 public class StatelessSessionBean2 implements SessionBean 42 { 43 static Logger log = Logger.getLogger(StatelessSessionBean2.class); 44 45 private SessionContext sessionContext; 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 sessionContext = context; 70 } 71 72 public String echo(String arg) 73 { 74 log.debug("echo, arg=" + arg); 75 return arg; 76 } 77 78 public String forward(String echoArg) 79 { 80 log.debug("forward, echoArg=" + echoArg); 81 String echo = null; 82 try 83 { 84 InitialContext ctx = new InitialContext (); 85 StatelessSessionHome home = (StatelessSessionHome) ctx.lookup("java:comp/env/ejb/Session"); 86 StatelessSession bean = home.create(); 87 echo = bean.echo(echoArg); 88 } 89 catch (Exception e) 90 { 91 log.debug("failed", e); 92 e.fillInStackTrace(); 93 throw new EJBException (e); 94 } 95 return echo; 96 } 97 98 public void noop(ReferenceTest test, boolean optimized) 99 { 100 boolean wasSerialized = test.getWasSerialized(); 101 log.debug("noop, test.wasSerialized=" + wasSerialized + ", optimized=" + optimized); 102 if (optimized && wasSerialized == true) 103 throw new EJBException ("Optimized call had serialized argument"); 104 if (optimized == false && wasSerialized == false) 105 throw new EJBException ("NotOptimized call had non serialized argument"); 106 } 107 108 public ReturnData getData() 109 { 110 ReturnData data = new ReturnData(); 111 data.data = "TheReturnData2"; 112 return data; 113 } 114 115 116 public void unchecked() 117 { 118 log.debug("unchecked"); 119 } 120 121 124 public void checkRunAs() 125 { 126 log.debug("checkRunAs"); 127 } 128 } 129 | Popular Tags |