View Javadoc

1   /*
2    * Copyright 2007 Hippo
3    *
4    * Licensed under the Apache License, Version 2.0 (the  "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" 
12   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  package nl.hippo.portal.locking;
17  
18  import org.apache.commons.transaction.locking.ReadWriteUpgradeLockManager;
19  import org.apache.commons.transaction.util.Log4jLogger;
20  import org.apache.log4j.Logger;
21  
22  /***
23   * @version $Id:CMSRequestLockManager.java 19178 2007-02-06 10:52:55Z adouma $
24   *
25   */
26  public class RequestLockManager
27  {
28      private static Logger lockLogger = Logger.getLogger(RequestLockManager.class);
29      
30      private ReadWriteUpgradeLockManager lockManager;
31      private long defaultReadLockTimeout;
32      private long defaultWriteLockTimeout;
33  
34      public RequestLockManager(long lockWaitTimeout, long defaultReadLockTimeout, long defaultWriteLockTimeout)
35      {
36          this.defaultReadLockTimeout = defaultReadLockTimeout;
37          this.defaultWriteLockTimeout = defaultWriteLockTimeout;
38          lockManager = new ReadWriteUpgradeLockManager(new Log4jLogger(lockLogger), lockWaitTimeout);
39      }
40  
41      /***
42       * @return the defaultReadLockTimeout
43       */
44      public long getDefaultReadLockTimeout()
45      {
46          return defaultReadLockTimeout;
47      }
48  
49      /***
50       * @return the defaultWriteLockTimeout
51       */
52      public long getDefaultWriteLockTimeout()
53      {
54          return defaultWriteLockTimeout;
55      }
56  
57      /***
58       * @return the manager
59       */
60      public ReadWriteUpgradeLockManager getLockManager()
61      {
62          return lockManager;
63      }
64  }