1 package org.apache.ojb.broker.util.configuration.impl; 2 3 17 18 import org.apache.ojb.broker.ManageableCollection; 19 import org.apache.ojb.broker.PersistenceBroker; 20 import org.apache.ojb.broker.cache.ObjectCache; 21 import org.apache.ojb.broker.cache.ObjectCacheDefaultImpl; 22 import org.apache.ojb.broker.core.PBPoolConfiguration; 23 import org.apache.ojb.broker.core.PersistenceBrokerConfiguration; 24 import org.apache.ojb.broker.core.PersistenceBrokerImpl; 25 import org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl; 26 import org.apache.ojb.broker.core.proxy.IndirectionHandler; 27 import org.apache.ojb.broker.core.proxy.IndirectionHandlerJDKImpl; 28 import org.apache.ojb.broker.core.proxy.ListProxyDefaultImpl; 29 import org.apache.ojb.broker.core.proxy.ProxyConfiguration; 30 import org.apache.ojb.broker.core.proxy.ProxyFactory; 31 import org.apache.ojb.broker.core.proxy.ProxyFactoryJDKImpl; 32 import org.apache.ojb.broker.core.proxy.SetProxyDefaultImpl; 33 import org.apache.ojb.broker.metadata.MetadataConfiguration; 34 import org.apache.ojb.broker.metadata.fieldaccess.PersistentField; 35 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl; 36 import org.apache.ojb.broker.util.pooling.PoolConfiguration; 37 import org.apache.ojb.odmg.OdmgConfiguration; 38 import org.apache.ojb.odmg.collections.DListImpl; 39 40 49 public class OjbConfiguration extends ConfigurationAbstractImpl 50 implements OdmgConfiguration, 51 PersistenceBrokerConfiguration, 52 ProxyConfiguration, 53 PBPoolConfiguration, 54 MetadataConfiguration 55 { 56 57 public static final String OJB_PROPERTIES_FILE = "OJB.properties"; 58 59 public static final String OJB_METADATA_FILE = "repository.xml"; 60 61 62 private String repositoryFilename; 63 private Class objectCacheClass; 64 private Class persistentFieldClass; 65 private Class persistenceBrokerClass; 66 67 private Class listProxyClass; 69 private Class setProxyClass; 70 private Class collectionProxyClass; 71 private Class indirectionHandlerClass; 72 private Class proxyFactoryClass; 73 74 private int sqlInLimit; 76 77 private int maxActive; 79 private int maxIdle; 80 private long maxWait; 81 private long timeBetweenEvictionRunsMillis; 82 private long minEvictableIdleTimeMillis; 83 private byte whenExhaustedAction; 84 85 private boolean useImplicitLocking; 87 private boolean lockAssociationAsWrites; 88 private Class oqlCollectionClass; 89 90 private boolean useSerializedRepository; 92 93 94 95 public OjbConfiguration() 96 { 97 super(); 98 } 99 100 public boolean useSerializedRepository() 101 { 102 return useSerializedRepository; 103 } 104 105 public boolean lockAssociationAsWrites() 106 { 107 return lockAssociationAsWrites; 108 } 109 110 public String getRepositoryFilename() 111 { 112 return repositoryFilename; 113 } 114 115 public int getMaxActive() 118 { 119 return maxActive; 120 } 121 122 public int getMaxIdle() 123 { 124 return maxIdle; 125 } 126 127 public long getMaxWaitMillis() 128 { 129 return maxWait; 130 } 131 132 public long getTimeBetweenEvictionRunsMilli() 133 { 134 return timeBetweenEvictionRunsMillis; 135 } 136 137 public long getMinEvictableIdleTimeMillis() 138 { 139 return minEvictableIdleTimeMillis; 140 } 141 142 public byte getWhenExhaustedAction() 143 { 144 return whenExhaustedAction; 145 } 146 148 149 151 public Class getObjectCacheClass() 152 { 153 return objectCacheClass; 154 } 155 156 public Class getOqlCollectionClass() 157 { 158 return oqlCollectionClass; 159 } 160 161 public Class getPersistentFieldClass() 162 { 163 return persistentFieldClass; 164 } 165 166 public Class getPersistenceBrokerClass() 167 { 168 return persistenceBrokerClass; 169 } 170 171 177 public Class getIndirectionHandlerClass() 178 { 179 return indirectionHandlerClass; 180 } 181 182 188 public Class getListProxyClass() 189 { 190 return listProxyClass; 191 } 192 193 199 public Class getSetProxyClass() 200 { 201 return setProxyClass; 202 } 203 204 210 public Class getCollectionProxyClass() 211 { 212 return collectionProxyClass; 213 } 214 215 216 221 public Class getProxyFactoryClass() { 222 return proxyFactoryClass; 223 } 224 225 231 protected void load() 232 { 233 String fn = System.getProperty(OJB_PROPERTIES_FILE, OJB_PROPERTIES_FILE); 236 setFilename(fn); 237 super.load(); 238 239 repositoryFilename = getString("repositoryFile", OJB_METADATA_FILE); 241 242 objectCacheClass = getClass("ObjectCacheClass", ObjectCacheDefaultImpl.class, ObjectCache.class); 244 245 persistentFieldClass = 247 getClass("PersistentFieldClass", PersistentFieldDirectImpl.class, PersistentField.class); 248 249 persistenceBrokerClass = 251 getClass("PersistenceBrokerClass", PersistenceBrokerImpl.class, PersistenceBroker.class); 252 253 listProxyClass = getClass("ListProxyClass", ListProxyDefaultImpl.class); 255 256 setProxyClass = getClass("SetProxyClass", SetProxyDefaultImpl.class); 258 259 collectionProxyClass = getClass("CollectionProxyClass", CollectionProxyDefaultImpl.class); 261 262 indirectionHandlerClass = 264 getClass("IndirectionHandlerClass", IndirectionHandlerJDKImpl.class, IndirectionHandler.class); 265 266 proxyFactoryClass = 268 getClass("ProxyFactoryClass", ProxyFactoryJDKImpl.class, ProxyFactory.class); 269 270 useImplicitLocking = getBoolean("ImplicitLocking", false); 272 273 lockAssociationAsWrites = (getString("LockAssociations", "WRITE").equalsIgnoreCase("WRITE")); 275 276 oqlCollectionClass = getClass("OqlCollectionClass", DListImpl.class, ManageableCollection.class); 278 279 sqlInLimit = getInteger("SqlInLimit", -1); 281 282 maxActive = getInteger(PoolConfiguration.MAX_ACTIVE, 284 PoolConfiguration.DEFAULT_MAX_ACTIVE); 285 maxIdle = getInteger(PoolConfiguration.MAX_IDLE, 286 PoolConfiguration.DEFAULT_MAX_IDLE); 287 maxWait = getLong(PoolConfiguration.MAX_WAIT, 288 PoolConfiguration.DEFAULT_MAX_WAIT); 289 timeBetweenEvictionRunsMillis = getLong(PoolConfiguration.TIME_BETWEEN_EVICTION_RUNS_MILLIS, 290 PoolConfiguration.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS); 291 minEvictableIdleTimeMillis = getLong(PoolConfiguration.MIN_EVICTABLE_IDLE_TIME_MILLIS, 292 PoolConfiguration.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS); 293 whenExhaustedAction = getByte(PoolConfiguration.WHEN_EXHAUSTED_ACTION, 294 PoolConfiguration.DEFAULT_WHEN_EXHAUSTED_ACTION); 295 296 useSerializedRepository = getBoolean("useSerializedRepository", false); 297 } 298 299 303 public int getSqlInLimit() 304 { 305 return sqlInLimit; 306 } 307 308 312 public void setPersistentFieldClass(Class persistentFieldClass) 313 { 314 this.persistentFieldClass = persistentFieldClass; 315 } 316 317 320 public boolean useImplicitLocking() 321 { 322 return useImplicitLocking; 323 } 324 325 public void setUseImplicitLocking(boolean implicitLocking) 326 { 327 this.useImplicitLocking = implicitLocking; 328 } 329 330 } 331 | Popular Tags |