1 package org.apache.ojb.broker.locking; 2 3 17 18 import org.apache.ojb.broker.OJBRuntimeException; 19 import org.apache.ojb.broker.util.factory.ConfigurableFactory; 20 21 25 public class LockManagerHelper 26 { 27 31 public static LockManager getLockManagerSpecifiedByConfiguration() 32 { 33 try 34 { 35 LockManager lm = (new LockManagerFactory()).createNewLockManager(); 37 lm.setLockTimeout(LockManager.DEFAULT_LOCK_TIMEOUT); 38 return lm; 39 } 40 catch(Exception e) 41 { 42 throw new OJBRuntimeException("Unexpected failure while start LockManager", e); 43 } 44 } 45 46 49 private static class LockManagerFactory extends ConfigurableFactory 50 { 51 protected String getConfigurationKey() 52 { 53 return "LockManagerClass"; 54 } 55 56 LockManager createNewLockManager() 57 { 58 return (LockManager) this.createNewInstance(); 59 } 60 } 61 62 66 public static LockManager getCommonsLockManager() 67 { 68 LockManager lm = new LockManagerCommonsImpl(); 69 lm.setLockTimeout(LockManager.DEFAULT_LOCK_TIMEOUT); 70 return lm; 71 } 72 } 73 | Popular Tags |