1 22 package org.jboss.test.web.ejb; 23 24 import java.security.Principal ; 25 import javax.ejb.CreateException ; 26 import javax.ejb.SessionBean ; 27 import javax.ejb.SessionContext ; 28 29 import org.jboss.logging.Logger; 30 import org.jboss.test.web.interfaces.ReferenceTest; 31 import org.jboss.test.web.interfaces.ReturnData; 32 33 38 public class StatelessSessionBean implements SessionBean 39 { 40 static Logger log = Logger.getLogger(StatelessSessionBean.class); 41 42 private SessionContext sessionContext; 43 44 public void ejbCreate() throws CreateException 45 { 46 log.debug("ejbCreate() called"); 47 } 48 49 public void ejbActivate() 50 { 51 log.debug("ejbActivate() called"); 52 } 53 54 public void ejbPassivate() 55 { 56 log.debug("ejbPassivate() called"); 57 } 58 59 public void ejbRemove() 60 { 61 log.debug("ejbRemove() called"); 62 } 63 64 public void setSessionContext(SessionContext context) 65 { 66 sessionContext = context; 67 } 68 69 public String echo(String arg) 70 { 71 log.debug("echo, arg=" + arg); 72 Principal p = sessionContext.getCallerPrincipal(); 73 log.debug("echo, callerPrincipal=" + p); 74 return p.getName(); 75 } 76 77 public String forward(String echoArg) 78 { 79 log.debug("StatelessSessionBean2.forward, echoArg=" + echoArg); 80 return echo(echoArg); 81 } 82 83 public void noop(ReferenceTest test, boolean optimized) 84 { 85 log.debug("noop"); 86 } 87 88 public ReturnData getData() 89 { 90 ReturnData data = new ReturnData(); 91 data.data = "TheReturnData"; 92 return data; 93 } 94 95 96 public void unchecked() 97 { 98 log.debug("unchecked"); 99 } 100 101 104 public void checkRunAs() 105 { 106 Principal caller = sessionContext.getCallerPrincipal(); 107 log.debug("checkRunAs, caller="+caller); 108 boolean isInternalUser = sessionContext.isCallerInRole("InternalUser"); 109 log.debug("Caller isInternalUser: "+isInternalUser); 110 } 111 } 112 | Popular Tags |