1 22 package org.jboss.ejb3.stateful; 23 24 import java.rmi.RemoteException ; 25 import java.rmi.ServerException ; 26 import java.security.AccessControlException ; 27 import java.util.Hashtable ; 28 import java.lang.reflect.InvocationHandler ; 29 import java.lang.reflect.Method ; 30 import java.lang.reflect.Proxy ; 31 32 import javax.ejb.EJBObject ; 33 import javax.ejb.Handle ; 34 import javax.naming.InitialContext ; 35 36 import org.jboss.invocation.Invoker; 37 import org.jboss.logging.Logger; 38 import org.jboss.naming.NamingContextFactory; 39 40 49 public class StatefulHandleImpl 50 implements Handle 51 { 52 private static final Logger log = Logger.getLogger(StatefulHandleImpl.class); 53 54 55 static final long serialVersionUID = -6324520755180597156L; 56 57 58 protected static final Method GET_EJB_OBJECT; 59 60 61 private Object invokerID = null; 62 63 66 static 67 { 68 try 69 { 70 GET_EJB_OBJECT = Handle .class.getMethod("getEJBObject", new Class [0]); 71 } 72 catch(Exception e) 73 { 74 e.printStackTrace(); 75 throw new ExceptionInInitializerError (e); 76 } 77 } 78 79 public StatefulHandleImpl() 80 { 81 82 } 83 84 85 public int objectName; 86 public String jndiName; 87 public String invokerProxyBinding; 88 public Invoker invoker; 89 public Object id; 90 91 92 protected Hashtable jndiEnv; 93 94 101 public StatefulHandleImpl( 102 int objectName, 103 String jndiName, 104 Invoker invoker, 105 String invokerProxyBinding, 106 Object id, 107 Object invokerID) 108 { 109 this.jndiName = jndiName; 110 this.id = id; 111 this.jndiEnv = (Hashtable ) NamingContextFactory.lastInitialContextEnv.get(); 112 try 113 { 114 String property = System.getProperty("org.jboss.ejb.sfsb.handle.V327"); 115 if (property != null) 116 { 117 this.invokerProxyBinding = invokerProxyBinding; 118 this.invokerID = invokerID; 119 this.objectName = objectName; 120 this.invoker = invoker; 121 } 122 } 123 catch (AccessControlException ignored) 124 { 125 } 126 127 } 128 129 132 public Object getID() 133 { 134 return id; 135 } 136 137 140 public String getJNDIName() 141 { 142 return jndiName; 143 } 144 145 163 public EJBObject getEJBObject() throws RemoteException 164 { 165 try 166 { 167 InitialContext ic = null; 168 if( jndiEnv != null ) 169 ic = new InitialContext (jndiEnv); 170 else 171 ic = new InitialContext (); 172 173 Proxy proxy = (Proxy ) ic.lookup(jndiName); 174 175 return (EJBObject ) proxy; 176 } 177 catch (Throwable t) 178 { 179 t.printStackTrace(); 180 throw new RemoteException ("Error during getEJBObject", t); 181 } 182 } 183 } 184 185 | Popular Tags |