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-sandbox/transaction/src/java/org/apache/commons/transaction/memory OptimisticMapWrapper.java PessimisticMapWrapper.java TransactionalMapWrapper.java
Date Wed, 02 Jun 2004 21:54:04 GMT
ozeigermann    2004/06/02 14:54:04

  Modified:    transaction/src/java/org/apache/commons/transaction/memory
                        TransactionalMapWrapper.java
  Added:       transaction/src/java/org/apache/commons/transaction/memory
                        OptimisticMapWrapper.java
                        PessimisticMapWrapper.java
  Log:
  Added frame for better isolation using optimistic or pessimistic strategies
  
  Revision  Changes    Path
  1.10      +8 -4      jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/TransactionalMapWrapper.java
  
  Index: TransactionalMapWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/TransactionalMapWrapper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TransactionalMapWrapper.java	2 Jun 2004 20:59:23 -0000	1.9
  +++ TransactionalMapWrapper.java	2 Jun 2004 21:54:04 -0000	1.10
  @@ -33,6 +33,8 @@
   
   /**
    * Wrapper that adds transactional control to all kinds of maps that implement the {@link
Map} interface.
  + * This wrapper has rather weak isolation, but is simply, neven blocks and commits will
never fail for logical
  + * reasons. 
    * <br>
    * Start a transaction by calling {@link #startTransaction()}. Then perform the normal
actions on the map and
    * finally either calls {@link #commitTransaction()} to make your changes permanent or
{@link #rollbackTransaction()} to
  @@ -46,6 +48,8 @@
    * 
    * @author <a href="mailto:ozeigermann@apache.org">Oliver Zeigermann</a>
    * @version $Revision$
  + * @see OptimisticMapWrapper
  + * @see PessimisticMapWrapper
    */
   public class TransactionalMapWrapper implements Map, Status {
   
  
  
  
  1.1                  jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/OptimisticMapWrapper.java
  
  Index: OptimisticMapWrapper.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/OptimisticMapWrapper.java,v
1.1 2004/06/02 21:54:04 ozeigermann Exp $
   * $Revision: 1.1 $
   * $Date: 2004/06/02 21:54:04 $
   *
   * ====================================================================
   *
   * Copyright 1999-2002 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.memory;
  
  import java.util.Map;
  
  /**
   * Wrapper that adds transactional control to all kinds of maps that implement the {@link
Map} interface. By using
   * optimistic transaction control this wrapper has better isolation than {@link TransactionalMapWrapper},
but
   * may also fail to commit. 
   * <br>
   * Start a transaction by calling {@link #startTransaction()}. Then perform the normal actions
on the map and
   * finally either calls {@link #commitTransaction()} to make your changes permanent or {@link
#rollbackTransaction()} to
   * undo them.
   * <br>
   * <em>Caution:</em> Do not modify values retrieved by {@link #get(Object)}
as this will circumvent the transactional mechanism.
   * Rather clone the value or copy it in a way you see fit and store it back using {@link
#put(Object, Object)}.
   * <br>
   * <em>Note:</em> This wrapper guarantees isolation levels <code>REPEATABLE
READ</code> or <code>SERIALIZABLE</code>.
   * 
   * @author <a href="mailto:ozeigermann@apache.org">Oliver Zeigermann</a>
   * @version $Revision: 1.1 $
   * @see TransactionalMapWrapper
   * @see PessimisticMapWrapper
   */
  public class OptimisticMapWrapper extends TransactionalMapWrapper {
  
  	/**
  	 * Creates a new optimistic transactional map wrapper. Temporary maps and sets to store
transactional
  	 * data will be instances of {@link HashMap} and {@link HashSet}. 
  	 * 
  	 * @param wrapped map to be wrapped
  	 */
  	public OptimisticMapWrapper(Map wrapped) {
  		super(wrapped, new HashMapFactory(), new HashSetFactory());
  	}
  
  	/**
  	 * Creates a new optimistic transactional map wrapper. Temporary maps and sets to store
transactional
  	 * data will be created and disposed using {@link MapFactory} and {@link SetFactory}.
  	 * 
  	 * @param wrapped map to be wrapped
  	 * @param mapFactory factory for temporary maps
  	 * @param setFactory factory for temporary sets
  	 */
  	public OptimisticMapWrapper(Map wrapped, MapFactory mapFactory, SetFactory setFactory)
{
  		super(wrapped, mapFactory, setFactory);
  	}
  }
  
  
  
  1.1                  jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/PessimisticMapWrapper.java
  
  Index: PessimisticMapWrapper.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/transaction/src/java/org/apache/commons/transaction/memory/PessimisticMapWrapper.java,v
1.1 2004/06/02 21:54:04 ozeigermann Exp $
   * $Revision: 1.1 $
   * $Date: 2004/06/02 21:54:04 $
   *
   * ====================================================================
   *
   * Copyright 1999-2002 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.memory;
  
  import java.util.Map;
  
  /**
   * Wrapper that adds transactional control to all kinds of maps that implement the {@link
Map} interface. By using
   * pessimistic transaction control (blocking locks) this wrapper has better isolation than
{@link TransactionalMapWrapper}, but
   * also has less possible concurrency and may even deadlock. A commit, however, will never
fail.
   * <br>
   * Start a transaction by calling {@link #startTransaction()}. Then perform the normal actions
on the map and
   * finally either calls {@link #commitTransaction()} to make your changes permanent or {@link
#rollbackTransaction()} to
   * undo them.
   * <br>
   * <em>Caution:</em> Do not modify values retrieved by {@link #get(Object)}
as this will circumvent the transactional mechanism.
   * Rather clone the value or copy it in a way you see fit and store it back using {@link
#put(Object, Object)}.
   * <br>
   * <em>Note:</em> This wrapper guarantees isolation level <code>SERIALIZABLE</code>.
   * 
   * @author <a href="mailto:ozeigermann@apache.org">Oliver Zeigermann</a>
   * @version $Revision: 1.1 $
   * @see TransactionalMapWrapper
   * @see OptimisticMapWrapper
   */
  public class PessimisticMapWrapper extends TransactionalMapWrapper {
  
  	/**
  	 * Creates a new pessimistic transactional map wrapper. Temporary maps and sets to store
transactional
  	 * data will be instances of {@link HashMap} and {@link HashSet}. 
  	 * 
  	 * @param wrapped map to be wrapped
  	 */
  	public PessimisticMapWrapper(Map wrapped) {
  		super(wrapped, new HashMapFactory(), new HashSetFactory());
  	}
  
  	/**
  	 * Creates a new pessimistic transactional map wrapper. Temporary maps and sets to store
transactional
  	 * data will be created and disposed using {@link MapFactory} and {@link SetFactory}.
  	 * 
  	 * @param wrapped map to be wrapped
  	 * @param mapFactory factory for temporary maps
  	 * @param setFactory factory for temporary sets
  	 */
  	public PessimisticMapWrapper(Map wrapped, MapFactory mapFactory, SetFactory setFactory)
{
  		super(wrapped, mapFactory, setFactory);
  	}
  }
  
  
  

---------------------------------------------------------------------
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