View Javadoc

1   /*** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.codehaus.activespace.cache;
19  
20  import javax.cache.Cache;
21  
22  /***
23   * An exception thrown if a commit() fails due to optimistic transaction failures.
24   *
25   * @version $Revision: 1.4 $
26   */
27  public class OptimisticTransactionException extends TransactionException {
28      private Cache cache;
29      private Object key;
30      private Object updateVersion;
31      private Object currentVersion;
32  
33      public OptimisticTransactionException(Cache cache, Object key, Object updateVersion, Object currentVersion) {
34          super("Failed to update key: " + key + " at version: " + currentVersion + " from update version: " + updateVersion);
35          this.cache = cache;
36          this.key = key;
37          this.updateVersion = updateVersion;
38          this.currentVersion = currentVersion;
39      }
40  
41      public Cache getCache() {
42          return cache;
43      }
44  
45      public Object getKey() {
46          return key;
47      }
48  
49      /***
50       * Returns the version at which a change was applied
51       */
52      public Object getUpdateVersion() {
53          return updateVersion;
54      }
55  
56      /***
57       * Returns the current version of the entry
58       */
59      public Object getCurrentVersion() {
60          return currentVersion;
61      }
62  }