1 package edu.rice.rubis.beans; 2 3 import java.rmi.*; 4 import javax.ejb.*; 5 import javax.rmi.PortableRemoteObject ; 6 import javax.naming.InitialContext ; 7 8 22 23 public class RegionBean implements EntityBean 24 { 25 private EntityContext entityContext; 26 private transient boolean isDirty; 28 29 30 public Integer id; 31 public String name; 32 33 39 public Integer getId() throws RemoteException 40 { 41 return id; 42 } 43 44 50 public String getName() throws RemoteException 51 { 52 return name; 53 } 54 55 61 public void setName(String newName) throws RemoteException 62 { 63 name = newName; 64 isDirty = true; } 66 67 68 80 public RegionPK ejbCreate(String regionName) throws CreateException, RemoteException, RemoveException 81 { 82 IDManagerHome home = null; 84 IDManager idManager = null; 85 86 try 87 { 88 InitialContext initialContext = new InitialContext (); 89 home = (IDManagerHome)PortableRemoteObject.narrow(initialContext.lookup( 90 "java:comp/env/ejb/IDManager"), IDManagerHome.class); 91 } 92 catch (Exception e) 93 { 94 throw new EJBException("Cannot lookup IDManager: " +e); 95 } 96 try 97 { 98 IDManagerPK idPK = new IDManagerPK(); 99 idManager = home.findByPrimaryKey(idPK); 100 id = idManager.getNextRegionID(); 101 name = regionName; 102 } 103 catch (Exception e) 104 { 105 throw new EJBException("Cannot create region: " +e); 106 } 107 return null; 108 } 109 110 112 public void ejbPostCreate(String regionName) 113 { 114 isDirty = true; } 116 117 119 public void ejbLoad() throws RemoteException 120 { 121 isDirty = false; 122 } 123 124 126 public void ejbStore() throws RemoteException 127 { 128 isDirty = false; 129 } 130 131 132 public void ejbActivate() throws RemoteException {} 133 134 public void ejbPassivate() throws RemoteException {} 135 136 public void ejbRemove() throws RemoteException, RemoveException {} 137 138 139 156 public void setEntityContext(EntityContext context) throws RemoteException 157 { 158 entityContext = context; 159 } 160 161 162 179 public void unsetEntityContext() throws RemoteException 180 { 181 entityContext = null; 182 } 183 184 185 192 public boolean isModified() 193 { 194 return isDirty; 195 } 196 197 } 198 | Popular Tags |