1 28 29 package com.caucho.ejb.session; 30 31 import com.caucho.ejb.AbstractEJBObject; 32 import com.caucho.ejb.AbstractServer; 33 import com.caucho.ejb.protocol.ObjectSkeletonWrapper; 34 import com.caucho.util.Log; 35 36 import javax.ejb.EJBHome ; 37 import javax.ejb.EJBLocalHome ; 38 import javax.ejb.EJBLocalObject ; 39 import javax.ejb.EJBObject ; 40 import javax.ejb.Handle ; 41 import javax.ejb.SessionBean ; 42 import java.io.ObjectStreamException ; 43 import java.io.Serializable ; 44 import java.rmi.RemoteException ; 45 import java.util.logging.Level ; 46 import java.util.logging.Logger ; 47 48 51 abstract public class AbstractSessionObject extends AbstractEJBObject 52 implements EJBObject, EJBLocalObject , Serializable 53 { 54 private static final Logger log = Log.open(AbstractSessionObject.class); 55 56 public SessionBean _getObject() 57 { 58 throw new UnsupportedOperationException ("_getObject is not implemented"); 59 } 60 61 64 abstract public AbstractServer getServer(); 65 66 69 public Handle getHandle() 70 { 71 return getServer().getHandleEncoder().createHandle(__caucho_getId()); 72 } 73 74 77 public EJBHome getEJBHome() 78 { 79 try { 80 return getServer().getEJBHome(); 81 } catch (Exception e) { 82 log.log(Level.FINE, e.toString(), e); 83 return null; 84 } 85 } 86 87 90 public EJBLocalHome getEJBLocalHome() 91 { 92 try { 93 return (EJBLocalHome ) getServer().getEJBLocalHome(); 94 } catch (Exception e) { 95 log.log(Level.FINE, e.toString(), e); 96 return null; 97 } 98 } 99 100 public Object getPrimaryKey() 101 { 102 throw new UnsupportedOperationException (); 103 } 104 105 108 public EJBObject getEJBObject() 109 { 110 return this; 111 } 112 113 116 public EJBLocalObject getEJBLocalObject() 117 { 118 return this; 119 } 120 121 124 public AbstractServer __caucho_getServer() 125 { 126 return getServer(); 127 } 128 129 132 public String __caucho_getId() 133 { 134 return getServer().encodeId(getPrimaryKey()); 135 } 136 137 140 public boolean isIdentical(EJBObject obj) throws RemoteException 141 { 142 System.out.println("GETH: " + getHandle() + " " + obj.getHandle()); 143 144 return getHandle().equals(obj.getHandle()); 145 } 146 147 150 public boolean isIdentical(EJBLocalObject obj) 151 { 152 return this == obj; 153 } 154 155 160 public Object writeReplace() throws ObjectStreamException 161 { 162 return new ObjectSkeletonWrapper(getHandle()); 163 } 164 } 165 | Popular Tags |