1 25 26 package org.objectweb.jonas.container; 27 28 import org.objectweb.jonas_ejb.container.EntityCounters; 29 import org.objectweb.jonas_ejb.container.JEntityFactory; 30 import org.objectweb.jonas_ejb.deployment.api.EntityDesc; 31 32 37 public class EntityBean extends EJB { 38 39 private static final int LOCK_CONTAINER_READ_UNCOMMITTED = EntityDesc.LOCK_CONTAINER_READ_UNCOMMITTED; 41 private static final int LOCK_CONTAINER_SERIALIZED = EntityDesc.LOCK_CONTAINER_SERIALIZED; 42 private static final int LOCK_CONTAINER_READ_COMMITTED = EntityDesc.LOCK_CONTAINER_READ_COMMITTED; 43 private static final int LOCK_DATABASE = EntityDesc.LOCK_DATABASE; 44 private static final int LOCK_READ_ONLY = EntityDesc.LOCK_READ_ONLY; 45 46 private String persistency; 47 48 public EntityBean(String objectName, JEntityFactory factoryToManage, String persistency) { 49 super(objectName, factoryToManage); 50 this.persistency = persistency; 51 } 52 53 56 public String getPersistency() { 57 return persistency; 58 } 59 60 64 public int getPassivationTimeOut() { 65 return ejbToManage.getContainer().getSwapTime(); 66 } 67 68 72 public void setPassivationTimeOut(int timeOut) { 73 ejbToManage.getContainer().setSwapTime(timeOut); 74 } 75 76 80 public int getInactivityTimeOut() { 81 return ((JEntityFactory) ejbToManage).getInactivityTimeout(); 82 } 83 84 87 public boolean getShared() { 88 return ((JEntityFactory) ejbToManage).isShared(); 89 } 90 91 94 public int getMinPoolSize() { 95 return ((JEntityFactory) ejbToManage).getMinPoolSize(); 96 } 97 98 101 public int getMaxCacheSize() { 102 return ((JEntityFactory) ejbToManage).getMaxCacheSize(); 103 } 104 105 108 public int getPoolSize() { 109 return ((JEntityFactory) ejbToManage).getPoolSize(); 110 } 111 112 115 public String getLockPolicy() { 116 int lockPolicy = ((JEntityFactory) ejbToManage).lockPolicy(); 117 String sLockPolicy = null; 118 switch (lockPolicy) { 119 case LOCK_CONTAINER_READ_UNCOMMITTED: 120 sLockPolicy = "container-read-uncommitted"; 121 break; 122 case LOCK_CONTAINER_SERIALIZED: 123 sLockPolicy = "container-serialized"; 124 break; 125 case LOCK_CONTAINER_READ_COMMITTED: 126 sLockPolicy = "container-read-committed"; 127 break; 128 case LOCK_DATABASE: 129 sLockPolicy = "database"; 130 break; 131 case LOCK_READ_ONLY: 132 sLockPolicy = "read-only"; 133 break; 134 } 135 return sLockPolicy; 136 } 137 138 public boolean getPrefetch() { 139 return ((JEntityFactory) ejbToManage).isPrefetch(); 140 } 141 144 public int getCacheSize() { 145 return ((JEntityFactory) ejbToManage).getCacheSize(); 146 } 147 148 152 public Integer [] getEntityCounters() { 153 EntityCounters ec = ((JEntityFactory) ejbToManage).getEntityCounters(); 154 Integer [] result = new Integer [5]; 155 result[0] = new Integer (ec.inTx); 156 result[1] = new Integer (ec.outTx); 157 result[2] = new Integer (ec.idle); 158 result[3] = new Integer (ec.passive); 159 result[4] = new Integer (ec.removed); 160 return result; 161 } 162 163 166 public void synchronize() { 167 ((JEntityFactory) ejbToManage).sync(); 168 } 169 170 173 public void reduceCache() { 174 ((JEntityFactory) ejbToManage).reduceCache(); 175 } 176 } 177 | Popular Tags |