1 22 package org.jboss.test.security.ejb.jbas1852; 23 24 import java.security.Principal ; 25 import java.rmi.RemoteException ; 26 import javax.ejb.CreateException ; 27 import javax.ejb.SessionContext ; 28 import javax.ejb.SessionBean ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 32 36 public class PublicSessionFacade implements SessionBean 37 { 38 private SessionContext sessionContext; 39 40 public void ejbCreate() throws CreateException 41 { 42 System.out.println("PublicSessionBean.ejbCreate() called"); 43 } 44 45 public void ejbActivate() 46 { 47 System.out.println("PublicSessionBean.ejbActivate() called"); 48 } 49 50 public void ejbPassivate() 51 { 52 System.out.println("PublicSessionBean.ejbPassivate() called"); 53 } 54 55 public void ejbRemove() 56 { 57 System.out.println("PublicSessionBean.ejbRemove() called"); 58 } 59 60 public void setSessionContext(SessionContext context) 61 { 62 sessionContext = context; 63 } 64 65 public String callEcho(String arg) 66 throws RemoteException 67 { 68 Principal user = sessionContext.getCallerPrincipal(); 69 String echoMsg = null; 70 try 71 { 72 InitialContext ctx = new InitialContext (); 73 String jndiName = "java:comp/env/ejb/TargetEJB"; 74 SessionHome home = (SessionHome) ctx.lookup(jndiName); 75 Session bean = home.create(); 76 echoMsg = bean.echo("Hello, arg="+arg); 77 echoMsg = bean.echo("Hello 2, arg="+arg); 78 } 79 catch (NamingException e) 80 { 81 throw new RemoteException ("callEcho failed", e); 82 } 83 catch (CreateException e) 84 { 85 throw new RemoteException ("callEcho failed", e); 86 } 87 return echoMsg; 88 } 89 } 90 | Popular Tags |