1 22 package org.jboss.ejb3.test.reference21_30; 23 24 import javax.naming.*; 25 import javax.ejb.EJB ; 26 import javax.ejb.EJBs ; 27 import javax.ejb.Remote ; 28 import javax.ejb.Stateless ; 29 import javax.ejb.Local ; 30 31 import org.jboss.annotation.ejb.LocalBinding; 32 import org.jboss.annotation.ejb.RemoteBinding; 33 import org.jboss.ejb3.Container; 34 import org.jboss.logging.Logger; 35 36 40 @Stateless (name="Session30") 41 @Remote (Session30.class) 42 @Local (LocalSession30.class) 43 @RemoteBinding(jndiBinding = "Session30") 44 @LocalBinding(jndiBinding = "LocalSession30") 45 @EJBs ({@EJB (name="injected", beanInterface=org.jboss.ejb3.test.reference21_30.Session21.class, beanName="Session21")}) 46 public class Session30Bean 47 { 48 private static final Logger log = Logger.getLogger(Session30Bean.class); 49 50 @EJB (mappedName="Session21") Object testMappedName; 51 52 public String access() 53 { 54 return "Session30"; 55 } 56 57 public String access21() 58 { 59 try { 60 InitialContext jndiContext = new InitialContext(); 61 Session21 session = (Session21)jndiContext.lookup(Container.ENC_CTX_NAME + "/env/injected"); 62 return session.access(); 63 } catch (Exception e) 64 { 65 e.printStackTrace(); 66 return null; 67 } 68 } 69 70 public String globalAccess21() 71 { 72 try { 73 InitialContext jndiContext = new InitialContext(); 74 Session21Home home = (Session21Home)jndiContext.lookup("Session21"); 75 Session21 session = (Session21)home.create(); 76 return session.access(); 77 } catch (Exception e) 78 { 79 e.printStackTrace(); 80 return null; 81 } 82 } 83 84 public String accessLocalStateful() 85 { 86 try { 87 InitialContext jndiContext = new InitialContext(); 88 StatefulSession30LocalHome localHome = (StatefulSession30LocalHome)jndiContext.lookup("LocalStatefulSession30Home"); 89 LocalStatefulSession30 localSession = localHome.create(); 90 return localSession.getLocalValue(); 91 } catch (Exception e) 92 { 93 e.printStackTrace(); 94 return null; 95 } 96 } 97 98 public String accessLocalStateful(String value) 99 { 100 try { 101 InitialContext jndiContext = new InitialContext(); 102 StatefulSession30LocalHome localHome = (StatefulSession30LocalHome)jndiContext.lookup("LocalStatefulSession30Home"); 103 LocalStatefulSession30 localSession = localHome.create(value); 104 return localSession.getLocalValue(); 105 } catch (Exception e) 106 { 107 e.printStackTrace(); 108 return null; 109 } 110 } 111 112 public String accessLocalStateful(String value, Integer suffix) 113 { 114 try { 115 InitialContext jndiContext = new InitialContext(); 116 StatefulSession30LocalHome localHome = (StatefulSession30LocalHome)jndiContext.lookup("LocalStatefulSession30Home"); 117 LocalStatefulSession30 localSession = localHome.create(value, suffix); 118 return localSession.getLocalValue(); 119 } catch (Exception e) 120 { 121 e.printStackTrace(); 122 return null; 123 } 124 } 125 126 } 127 | Popular Tags |