1 22 package org.jboss.test.naming.ejb; 23 24 import javax.ejb.CreateException ; 25 import javax.ejb.EJBException ; 26 import javax.ejb.SessionBean ; 27 import javax.ejb.SessionContext ; 28 import javax.naming.Context ; 29 import javax.naming.InitialContext ; 30 import javax.naming.NamingException ; 31 import javax.rmi.PortableRemoteObject ; 32 33 import org.jboss.test.naming.interfaces.TestEjbLinkHome; 34 import org.jboss.test.naming.interfaces.TestEjbLink; 35 import org.jboss.test.naming.interfaces.TestEjbLinkLocalHome; 36 import org.jboss.test.naming.interfaces.TestEjbLinkLocal; 37 import org.jboss.test.util.Debug; 38 39 44 public class TestEjbLinkBean implements SessionBean 45 { 46 org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(getClass()); 47 48 public void ejbCreate() throws CreateException 49 { 50 } 51 52 public void ejbActivate() 54 { 55 } 56 57 public void ejbPassivate() 58 { 59 } 60 61 public void ejbRemove() 62 { 63 } 64 65 public void setSessionContext(SessionContext sessionContext) throws EJBException 66 { 67 } 68 69 public String testEjbLinkCaller(String jndiName) 70 { 71 try 72 { 73 InitialContext initial = new InitialContext (); 74 Object object = initial.lookup(jndiName); 75 log.debug("jndiName="+jndiName); 76 77 StringBuffer results = new StringBuffer ("testEjbLinkCaller Proxy info\n"); 78 Debug.displayClassInfo(object.getClass(), results); 79 log.debug(results.toString()); 80 81 results.setLength(0); 82 results.append("testEjbLinkCaller TestEjbLinkLocalHome.class info\n"); 83 Debug.displayClassInfo(TestEjbLinkLocalHome.class, results); 84 log.debug(results.toString()); 85 86 TestEjbLinkHome home = 87 (TestEjbLinkHome) PortableRemoteObject.narrow(object, TestEjbLinkHome.class); 88 TestEjbLink bean = home.create(); 89 return bean.testEjbLinkCalled(); 90 } 91 catch (Exception e) 92 { 93 log.debug("failed", e); 94 return "Failed"; 95 } 96 } 97 98 public String testEjbLinkCallerLocal(String jndiName) 99 { 100 try 101 { 102 InitialContext initial = new InitialContext (); 103 Object object = initial.lookup(jndiName); 104 log.debug("jndiName="+jndiName); 105 106 StringBuffer results = new StringBuffer ("testEjbLinkCallerLocal Proxy info\n"); 107 Debug.displayClassInfo(object.getClass(), results); 108 log.debug(results.toString()); 109 110 results.setLength(0); 111 results.append("testEjbLinkCallerLocal TestEjbLinkLocalHome.class info\n"); 112 Debug.displayClassInfo(TestEjbLinkLocalHome.class, results); 113 log.debug(results.toString()); 114 115 TestEjbLinkLocalHome home = 116 (TestEjbLinkLocalHome) PortableRemoteObject.narrow(object, TestEjbLinkLocalHome.class); 117 TestEjbLinkLocal bean = home.create(); 118 return bean.testEjbLinkCalled(); 119 } 120 catch (Exception e) 121 { 122 log.debug("failed", e); 123 return "Failed"; 124 } 125 } 126 127 public String testEjbLinkCalled() 128 { 129 return "Works"; 130 } 131 132 } 133 | Popular Tags |