1 29 30 package com.caucho.ejb.entity; 31 32 import com.caucho.amber.entity.EntityFactory; 33 import com.caucho.amber.entity.EntityItem; 34 import com.caucho.amber.manager.AmberConnection; 35 import com.caucho.util.L10N; 36 import com.caucho.util.Log; 37 38 import javax.ejb.FinderException ; 39 import java.util.Map ; 40 import java.util.logging.Logger ; 41 42 45 public class AmberEntityFactory extends EntityFactory { 46 private static final L10N L = new L10N(AmberEntityFactory.class); 47 private static final Logger log = Log.open(AmberEntityFactory.class); 48 49 private EntityServer _entityServer; 50 51 AmberEntityFactory(EntityServer entityServer) 52 { 53 _entityServer = entityServer; 54 } 55 56 59 public Object getEntity(AmberConnection aConn, EntityItem item) 60 { 61 try { 62 Object key = item.getEntity().__caucho_getPrimaryKey(); 63 64 return _entityServer.getContext(key, false).getEJBLocalObject(); 65 } catch (FinderException e) { 66 throw new RuntimeException (e); 67 } 68 } 69 70 73 public Object getEntity(AmberConnection aConn, 74 EntityItem item, 75 Map preloadedProperties) 76 { 77 return getEntity(aConn, item); 78 } 79 80 83 public void delete(AmberConnection aConn, Object proxy) 84 { 85 try { 86 EntityObject entity = (EntityObject) proxy; 87 88 entity.remove(); 89 } catch (Exception e) { 90 throw new RuntimeException (e); 91 } 92 } 93 } 94 | Popular Tags |