1 28 29 package com.caucho.ejb.protocol; 30 31 import com.caucho.ejb.AbstractServer; 32 import com.caucho.ejb.RemoteExceptionWrapper; 33 34 import javax.ejb.EJBObject ; 35 import java.rmi.RemoteException ; 36 37 47 public class HandleImpl extends AbstractHandle { 48 private String _serverId; 49 private String _objectId; 50 51 private transient EJBObject _object; 52 53 56 public HandleImpl() {} 57 58 64 public HandleImpl(String serverId, String objectId) 65 { 66 _serverId = serverId; 67 _objectId = objectId; 68 } 69 70 73 public String getServerId() 74 { 75 return _serverId; 76 } 77 78 81 public String getObjectId() 82 { 83 return _objectId; 84 } 85 86 public String getURL(String protocol) 87 { 88 AbstractServer server = EjbProtocolManager.getJVMServer(_serverId); 89 90 return server.getHandleEncoder(protocol).getURL(_objectId); 91 } 92 93 public EJBObject getEJBObject() 94 throws RemoteException 95 { 96 if (_object == null) { 97 try { 98 SameJVMClientContainer client; 99 client = SameJVMClientContainer.find(_serverId); 100 101 if (client != null) 102 _object = client.createObjectStub(_objectId); 103 } catch (Exception e) { 104 RemoteExceptionWrapper.create(e); 105 } 106 } 107 108 return _object; 109 } 110 111 116 public boolean equals(Object b) 117 { 118 if (! (b instanceof HandleImpl)) 119 return false; 120 121 HandleImpl handle = (HandleImpl) b; 122 123 return (_serverId.equals(handle._serverId) && 124 _objectId.equals(handle._objectId)); 125 } 126 127 130 public int hashCode() 131 { 132 return 65521 * _serverId.hashCode() + _objectId.hashCode(); 133 } 134 135 138 public String toString() 139 { 140 return "HandleImpl[" + _serverId + "," + _objectId + "]"; 141 } 142 } 143 | Popular Tags |