1 23 package com.sun.ejb.containers; 24 25 import java.rmi.Remote ; 26 import java.rmi.RemoteException ; 27 import java.lang.reflect.Method ; 28 29 import javax.ejb.*; 30 31 import com.sun.ejb.*; 32 import com.sun.ejb.portable.*; 33 import com.sun.enterprise.*; 34 35 import com.sun.enterprise.log.Log; 36 import com.sun.enterprise.util.LocalStringManagerImpl; 37 38 import java.util.Map ; 39 import java.util.HashMap ; 40 41 import java.util.logging.*; 42 import com.sun.logging.*; 43 44 53 54 public abstract class EJBObjectImpl 55 extends EJBLocalRemoteObject 56 implements EJBObject 57 { 58 private static Logger _logger; 59 private static Class [] NO_PARAMS = new Class [] {}; 60 private static LocalStringManagerImpl localStrings = 61 new LocalStringManagerImpl(EJBObjectImpl.class); 62 private static Method REMOVE_METHOD = null; 63 64 static { 65 _logger=LogDomains.getLogger(LogDomains.EJB_LOGGER); 66 67 try { 68 REMOVE_METHOD = EJBObject.class.getMethod("remove", NO_PARAMS); 69 } catch ( NoSuchMethodException e ) { 70 _logger.log(Level.FINE, "Exception retrieving remove method", e); 71 } 72 } 73 74 transient private java.rmi.Remote stub; 75 transient private java.rmi.Remote ejbObject; 76 transient private Map businessStubs = new HashMap (); 77 transient private Map businessEJBObjects = new HashMap (); 78 transient private boolean beingCreated=false; 79 80 private boolean isRemoteHomeView; 83 84 protected EJBObjectImpl() throws RemoteException { 85 } 86 87 final void setStub(java.rmi.Remote stub) { 88 this.stub = stub; 89 } 90 91 95 final void setStub(String generatedBusinessInterface, 96 java.rmi.Remote stub) { 97 businessStubs.put(generatedBusinessInterface, stub); 98 } 99 100 public final java.rmi.Remote getStub() { 101 return stub; 102 } 103 104 public final java.rmi.Remote getStub(String generatedBusinessInterface) { 105 return (java.rmi.Remote ) businessStubs.get(generatedBusinessInterface); 106 } 107 108 void setIsRemoteHomeView(boolean flag) { 109 isRemoteHomeView = flag; 110 } 111 112 boolean isRemoteHomeView() { 113 return isRemoteHomeView; 114 } 115 116 120 public java.rmi.Remote getEJBObject() { 121 return ejbObject; 122 } 123 124 128 public java.rmi.Remote getEJBObject(String generatedBusinessInterface) { 129 return (java.rmi.Remote ) businessEJBObjects.get 130 (generatedBusinessInterface); 131 } 132 133 public void setEJBObject(java.rmi.Remote ejbObject) { 134 this.ejbObject = ejbObject; 135 } 136 137 public void setEJBObject(String generatedBusinessInterface, 138 java.rmi.Remote ejbObject) { 139 businessEJBObjects.put(generatedBusinessInterface, ejbObject); 140 } 141 142 final void setBeingCreated(boolean b) { 143 beingCreated = b; 144 } 145 146 final boolean isBeingCreated() { 147 return beingCreated; 148 } 149 150 153 155 public boolean isIdentical(EJBObject ejbo) throws RemoteException { 156 container.authorizeRemoteMethod(BaseContainer.EJBObject_isIdentical); 157 158 return container.isIdentical(this, ejbo); 159 } 160 161 162 164 public Object getPrimaryKey() throws RemoteException { 165 if ( container instanceof EntityContainer ) { 166 container.authorizeRemoteMethod( 167 BaseContainer.EJBObject_getPrimaryKey); 168 169 return primaryKey; 170 } 171 else { 172 throw new RemoteException (localStrings.getLocalString( 173 "containers.invalid_operation", 174 "Invalid operation for Session EJBs.")); 175 } 176 } 177 178 181 public final EJBHome getEJBHome() throws RemoteException { 182 container.authorizeRemoteMethod(BaseContainer.EJBObject_getEJBHome); 183 184 return container.getEJBHomeStub(); 185 } 186 187 193 public final void remove() throws RemoteException , RemoveException { 194 container.authorizeRemoteMethod(BaseContainer.EJBObject_remove); 195 196 container.removeBean(this, REMOVE_METHOD, false); 197 } 198 199 203 public final Handle getHandle() throws RemoteException { 204 container.authorizeRemoteMethod(BaseContainer.EJBObject_getHandle); 205 206 return new HandleImpl((EJBObject)stub); 209 } 210 } 211 | Popular Tags |