commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ozeigerm...@apache.org
Subject cvs commit: jakarta-commons/transaction/src/java/org/apache/commons/transaction/file FileResourceManager.java
Date Fri, 07 Jan 2005 13:32:33 GMT
ozeigermann    2005/01/07 05:32:33

  Modified:    transaction/src/java/org/apache/commons/transaction/locking
                        LockManager.java
               transaction RELEASE-NOTES.txt
               transaction/src/java/org/apache/commons/transaction/file
                        FileResourceManager.java
  Added:       transaction/src/java/org/apache/commons/transaction/locking
                        LockManager2.java
  Log:
  Introduced LockManager2 to assure 1.0 compatibility for 1.1 and later
  
  Revision  Changes    Path
  1.4       +9 -121    jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/LockManager.java
  
  Index: LockManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/LockManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LockManager.java	17 Dec 2004 00:14:08 -0000	1.3
  +++ LockManager.java	7 Jan 2005 13:32:33 -0000	1.4
  @@ -23,8 +23,6 @@
   
   package org.apache.commons.transaction.locking;
   
  -import java.util.Set;
  -
   /**
    * 
    * A manager for multi level locks on resources. Encapsulates creation, removal, and retrieval
of locks.
  @@ -38,136 +36,26 @@
   public interface LockManager {
   
       /**
  -     * Tries to acquire a lock on a resource. <br>
  -     * <br>
  -     * This method does not block, but immediatly returns. If a lock is not
  -     * available <code>false</code> will be returned.
  -     * 
  -     * @param ownerId
  -     *            a unique id identifying the entity that wants to acquire this
  -     *            lock
  -     * @param resourceId
  -     *            the resource to get the level for
  -     * @param targetLockLevel
  -     *            the lock level to acquire
  -     * @param reentrant
  -     *            <code>true</code> if this request shall not be blocked by
  -     *            other locks held by the same owner
  -     * @return <code>true</code> if the lock has been acquired, <code>false</code>
otherwise
  -     *  
  -     */
  -    public boolean tryLock(Object ownerId, Object resourceId, int targetLockLevel, boolean
reentrant);
  -
  -    /**
  -     * Tries to acquire a lock on a resource. <br>
  -     * <br>
  -     * This method blocks and waits for the lock in case it is not avaiable. If
  -     * there is a timeout or a deadlock or the thread is interrupted a
  -     * LockException is thrown.
  -     * 
  -     * @param ownerId
  -     *            a unique id identifying the entity that wants to acquire this
  -     *            lock
  -     * @param resourceId
  -     *            the resource to get the level for
  -     * @param targetLockLevel
  -     *            the lock level to acquire
  -     * @param reentrant
  -     *            <code>true</code> if this request shall not be blocked by
  -     *            other locks held by the same owner
  -     * @throws LockException
  -     *             will be thrown when the lock can not be acquired
  -     */
  -    public void lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant)
  -            throws LockException;
  -
  -    /**
  -     * Tries to acquire a lock on a resource. <br>
  -     * <br>
  -     * This method blocks and waits for the lock in case it is not avaiable. If
  -     * there is a timeout or a deadlock or the thread is interrupted a
  -     * LockException is thrown.
  -     * 
  -     * @param ownerId
  -     *            a unique id identifying the entity that wants to acquire this
  -     *            lock
  -     * @param resourceId
  -     *            the resource to get the level for
  -     * @param targetLockLevel
  -     *            the lock level to acquire
  -     * @param reentrant
  -     *            <code>true</code> if this request shall not be blocked by
  -     *            other locks held by the same owner
  -     * @param timeoutMSecs
  -     *            specifies the maximum wait time in milliseconds
  -     * @throws LockException
  -     *             will be thrown when the lock can not be acquired
  -     */
  -    public void lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant,
  -            long timeoutMSecs) throws LockException;
  -
  -    /**
  -     * Gets the lock level held by certain owner on a certain resource.
  -     * 
  -     * @param ownerId the id of the owner of the lock
  -     * @param resourceId the resource to get the level for
  -     */
  -    public int getLevel(Object ownerId, Object resourceId);
  -
  -    /**
  -     * Releases all locks for a certain resource held by a certain owner.
  -     * 
  -     * @param ownerId the id of the owner of the lock
  -     * @param resourceId the resource to releases the lock for
  -     */
  -    public void release(Object ownerId, Object resourceId);
  -
  -    /**
  -     * Releases all locks (partially) held by an owner.
  -     * 
  -     * @param ownerId the id of the owner
  -     */
  -    public void releaseAll(Object ownerId);
  -    
  -    /**
  -     * Gets all locks (partially) held by an owner.
  +     * Either gets an existing lock on the specified resource or creates one if none exists.

  +     * This methods guarantees to do this atomically. 
        * 
  -     * @param ownerId the id of the owner
  -     * @return all locks held by ownerId
  +     * @param resourceId the resource to get or create the lock on
  +     * @return the lock for the specified resource
        */
  -    public Set getAll(Object ownerId);
  +    public MultiLevelLock atomicGetOrCreateLock(Object resourceId);
   
  -    
       /**
        * Gets an existing lock on the specified resource. If none exists it returns <code>null</code>.

        * 
        * @param resourceId the resource to get the lock for
        * @return the lock on the specified resource
  -     * 
        */
       public MultiLevelLock getLock(Object resourceId);
   
       /**
        * Removes the specified lock from the associated resource. 
        * 
  -     * <em>Caution:</em> This does not release the lock, but only moves it
out
  -     * of the scope of this manager. Use {@link #release(Object, Object)} for that.
  -     * 
        * @param lock the lock to be removed
        */
       public void removeLock(MultiLevelLock lock);
  -
  -    /**
  -     * Either gets an existing lock on the specified resource or creates one if none exists.

  -     * This methods guarantees to do this atomically. 
  -     * 
  -     * @param resourceId the resource to get or create the lock on
  -     * @return the lock for the specified resource
  -     * 
  -     * @deprecated Direct access to locks is discouraged as dead lock detection and lock
  -     * maintenance now relies on the call to {@link #lock(Object, Object, int, int, long)},

  -     * {@link #tryLock(Object, Object, int, int)}, {@link #release(Object, Object)} and

  -     * {@link #releaseAll(Object)}. This method will be deleted. 
  -     */
  -    public MultiLevelLock atomicGetOrCreateLock(Object resourceId);
   }
  
  
  
  1.1                  jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/LockManager2.java
  
  Index: LockManager2.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/transaction/src/java/org/apache/commons/transaction/locking/LockManager2.java,v
1.1 2005/01/07 13:32:33 ozeigermann Exp $
   * $Revision: 1.1 $
   * $Date: 2005/01/07 13:32:33 $
   *
   * ====================================================================
   *
   * Copyright 1999-2004 The Apache Software Foundation 
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   *
   */
  
  package org.apache.commons.transaction.locking;
  
  import java.util.Set;
  
  /**
   * Extended version of a lock manager that also has global knowledge or all locks and should
be
   * used as a delegate for all locking requests. This allows for things like deadlock detection.
   * 
   * @version $Revision: 1.1 $
   * @see MultiLevelLock
   * @see LockManager
   * @see GenericLockManager
   */
  public interface LockManager2 {
  
      /**
       * Tries to acquire a lock on a resource. <br>
       * <br>
       * This method does not block, but immediatly returns. If a lock is not
       * available <code>false</code> will be returned.
       * 
       * @param ownerId
       *            a unique id identifying the entity that wants to acquire this
       *            lock
       * @param resourceId
       *            the resource to get the level for
       * @param targetLockLevel
       *            the lock level to acquire
       * @param reentrant
       *            <code>true</code> if this request shall not be blocked by
       *            other locks held by the same owner
       * @return <code>true</code> if the lock has been acquired, <code>false</code>
otherwise
       *  
       */
      public boolean tryLock(Object ownerId, Object resourceId, int targetLockLevel, boolean
reentrant);
  
      /**
       * Tries to acquire a lock on a resource. <br>
       * <br>
       * This method blocks and waits for the lock in case it is not avaiable. If
       * there is a timeout or a deadlock or the thread is interrupted a
       * LockException is thrown.
       * 
       * @param ownerId
       *            a unique id identifying the entity that wants to acquire this
       *            lock
       * @param resourceId
       *            the resource to get the level for
       * @param targetLockLevel
       *            the lock level to acquire
       * @param reentrant
       *            <code>true</code> if this request shall not be blocked by
       *            other locks held by the same owner
       * @throws LockException
       *             will be thrown when the lock can not be acquired
       */
      public void lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant)
              throws LockException;
  
      /**
       * Tries to acquire a lock on a resource. <br>
       * <br>
       * This method blocks and waits for the lock in case it is not avaiable. If
       * there is a timeout or a deadlock or the thread is interrupted a
       * LockException is thrown.
       * 
       * @param ownerId
       *            a unique id identifying the entity that wants to acquire this
       *            lock
       * @param resourceId
       *            the resource to get the level for
       * @param targetLockLevel
       *            the lock level to acquire
       * @param reentrant
       *            <code>true</code> if this request shall not be blocked by
       *            other locks held by the same owner
       * @param timeoutMSecs
       *            specifies the maximum wait time in milliseconds
       * @throws LockException
       *             will be thrown when the lock can not be acquired
       */
      public void lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant,
              long timeoutMSecs) throws LockException;
  
      /**
       * Gets the lock level held by certain owner on a certain resource.
       * 
       * @param ownerId the id of the owner of the lock
       * @param resourceId the resource to get the level for
       */
      public int getLevel(Object ownerId, Object resourceId);
  
      /**
       * Releases all locks for a certain resource held by a certain owner.
       * 
       * @param ownerId the id of the owner of the lock
       * @param resourceId the resource to releases the lock for
       */
      public void release(Object ownerId, Object resourceId);
  
      /**
       * Releases all locks (partially) held by an owner.
       * 
       * @param ownerId the id of the owner
       */
      public void releaseAll(Object ownerId);
      
      /**
       * Gets all locks (partially) held by an owner.
       * 
       * @param ownerId the id of the owner
       * @return all locks held by ownerId
       */
      public Set getAll(Object ownerId);
  
      
      /**
       * Gets an existing lock on the specified resource. If none exists it returns <code>null</code>.

       * 
       * @param resourceId the resource to get the lock for
       * @return the lock on the specified resource
       * 
       */
      public MultiLevelLock getLock(Object resourceId);
  
      /**
       * Removes the specified lock from the associated resource. 
       * 
       * <em>Caution:</em> This does not release the lock, but only moves it out
       * of the scope of this manager. Use {@link #release(Object, Object)} for that.
       * 
       * @param lock the lock to be removed
       */
      public void removeLock(MultiLevelLock lock);
  
  }
  
  
  
  1.9       +4 -4      jakarta-commons/transaction/RELEASE-NOTES.txt
  
  Index: RELEASE-NOTES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/transaction/RELEASE-NOTES.txt,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RELEASE-NOTES.txt	18 Dec 2004 23:19:08 -0000	1.8
  +++ RELEASE-NOTES.txt	7 Jan 2005 13:32:33 -0000	1.9
  @@ -1,8 +1,8 @@
  -Jakarta Commons Transaction Release 1.1 beta1
  ----------------------------------------------
  +Jakarta Commons Transaction Release 1.1 beta1 pre
  +-------------------------------------------------
   
  -RELEASE NUMBER: 1.1b1
  -RELEASE TAG / BRANCH: TRANSACTION_1_1_B1_RELEASE / none yet
  +RELEASE NUMBER: 1.1b1-pre
  +RELEASE TAG / BRANCH: none yet / none yet
   
   DESCRIPTION
   -----------
  
  
  
  1.6       +6 -6      jakarta-commons/transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java
  
  Index: FileResourceManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/transaction/src/java/org/apache/commons/transaction/file/FileResourceManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FileResourceManager.java	18 Dec 2004 23:19:09 -0000	1.5
  +++ FileResourceManager.java	7 Jan 2005 13:32:33 -0000	1.6
  @@ -45,7 +45,7 @@
   import org.apache.commons.transaction.locking.GenericLock;
   import org.apache.commons.transaction.locking.GenericLockManager;
   import org.apache.commons.transaction.locking.LockException;
  -import org.apache.commons.transaction.locking.LockManager;
  +import org.apache.commons.transaction.locking.LockManager2;
   import org.apache.commons.transaction.util.FileHelper;
   import org.apache.commons.transaction.util.LoggerFacade;
   
  @@ -192,7 +192,7 @@
   
       protected Map globalTransactions;
       protected List globalOpenResources;
  -    protected LockManager lockManager;
  +    protected LockManager2 lockManager;
       
       protected ResourceIdToPathMapper idMapper = null;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message