1 23 24 package com.sun.ejb.containers; 25 26 import java.io.Serializable ; 27 import java.lang.reflect.Method ; 28 29 30 import javax.ejb.*; 31 import javax.naming.*; 32 33 import com.sun.ejb.*; 34 import com.sun.enterprise.Switch; 35 36 import java.util.logging.*; 37 import com.sun.logging.*; 38 39 import java.io.IOException ; 40 41 import com.sun.ejb.spi.io.IndirectlySerializable; 42 import com.sun.ejb.spi.io.SerializableObjectFactory; 43 44 53 public abstract class EJBLocalHomeImpl 54 implements EJBLocalHome, IndirectlySerializable 55 { 56 protected BaseContainer container; 57 private static Logger _logger; 58 static { 59 _logger=LogDomains.getLogger(LogDomains.EJB_LOGGER); 60 } 61 62 65 final void setContainer(BaseContainer c) { 66 container = c; 67 } 68 69 72 protected final BaseContainer getContainer() { 73 return container; 74 } 75 76 84 protected EJBLocalHome getEJBLocalHome() { 85 return this; 86 } 87 88 93 protected final EJBLocalObjectImpl createEJBLocalObjectImpl() 94 throws CreateException 95 { 96 return container.createEJBLocalObjectImpl(); 97 } 98 99 102 protected final EJBLocalObjectImpl createEJBLocalBusinessObjectImpl() 103 throws CreateException 104 { 105 return container.createEJBLocalBusinessObjectImpl(); 106 } 107 108 111 public final void remove(Object primaryKey) 112 throws RemoveException, EJBException 113 { 114 if ( !(container instanceof EntityContainer) ) { 115 throw new RemoveException("Attempt to call remove(Object primaryKey) on a session bean."); 117 } 118 119 container.authorizeLocalMethod(BaseContainer.EJBLocalHome_remove_Pkey); 120 121 Method method=null; 122 try { 123 method = EJBLocalHome.class.getMethod("remove", 124 new Class []{Object .class}); 125 } catch ( NoSuchMethodException e ) { 126 _logger.log(Level.FINE, "Exception in method remove()", e); 127 } 128 129 try { 130 ((EntityContainer)container).removeBean(primaryKey, method, true); 131 } catch(java.rmi.RemoteException re) { 132 EJBException ejbEx =new EJBException("unexpected RemoteException"); 136 ejbEx.initCause(re); 137 throw ejbEx; 138 } 139 } 140 141 public SerializableObjectFactory getSerializableObjectFactory() { 142 return new SerializableLocalHome( 143 container.getEjbDescriptor().getUniqueId()); 144 } 145 146 public static final class SerializableLocalHome 147 implements SerializableObjectFactory 148 { 149 private long ejbId; 150 151 public SerializableLocalHome(long uniqueId) { 152 this.ejbId = uniqueId; 153 } 154 155 public Object createObject() 156 throws IOException 157 { 158 BaseContainer container = (BaseContainer) 164 Switch.getSwitch().getContainerFactory().getContainer(ejbId); 165 return container.getEJBLocalHome(); 166 } 167 } 168 } 169 170 | Popular Tags |