View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
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" BASIS,
12   *  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 net.sf.ehcache.transaction.xa.commands;
17  
18  import net.sf.ehcache.store.ElementValueComparator;
19  import net.sf.ehcache.store.Store;
20  import net.sf.ehcache.transaction.SoftLockFactory;
21  import net.sf.ehcache.transaction.xa.XidTransactionID;
22  
23  /***
24   * @author Ludovic Orban
25   */
26  public interface Command {
27  
28      /***
29       * Is this command represents adding a key to the store
30       * @param key the key
31       * @return true, if this command would try to add an Element for key, otherwise false
32       */
33      public boolean isPut(Object key);
34  
35      /***
36       * Is this command represents removing a key to the store
37       * @param key the key
38       * @return true, if this command would try to remove an Element for key, otherwise false
39       */
40      public boolean isRemove(Object key);
41  
42      /***
43       * Prepare the commmand un the underlying store
44       * @param store the underdyling store
45       * @param softLockFactory the soft lock factory
46       * @param transactionId the transaction ID
47       * @param comparator the element value comparator
48       * @return true if prepare updated the store, false otherwise
49       */
50      boolean prepare(Store store, SoftLockFactory softLockFactory, XidTransactionID transactionId, ElementValueComparator comparator);
51  
52      /***
53       * Rollback the prepared change
54       * @param store the underlying store
55       */
56      public void rollback(Store store);
57  
58      /***
59       * Get the key of the element this command is working on
60       * @return the element's key
61       */
62      Object getObjectKey();
63  
64  }