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;
17
18 import net.sf.ehcache.Element;
19 import net.sf.ehcache.transaction.local.LocalTransactionContext;
20
21 import java.util.Set;
22
23 /***
24 * A factory for {@link SoftLock}s
25 *
26 * @author Ludovic Orban
27 */
28 public interface SoftLockFactory {
29
30 /***
31 * Create a new, unlocked soft lock
32 * @param transactionID the transaction ID under which the soft lock will operate
33 * @param key the key of the Element this soft lock is protecting
34 * @param newElement the new Element
35 * @param oldElement the actual Element
36 * @return the soft lock
37 */
38 SoftLock createSoftLock(TransactionID transactionID, Object key, Element newElement, Element oldElement);
39
40 /***
41 * Get a Set of keys protected by soft locks which must not be visible to a transaction context
42 * according to the isolation level.
43 * @param transactionContext the transaction context
44 * @return a Set of keys invisible to the context
45 */
46 Set<Object> getKeysInvisibleInContext(LocalTransactionContext transactionContext);
47
48 /***
49 * Get a Set of TransactionIDs for which the soft locks have expired
50 * @return a Set of TransactionIDs for which the soft locks have expired
51 */
52 Set<TransactionID> collectExpiredTransactionIDs();
53
54 /***
55 * Get a the soft locks of the specified transaction ID
56 * @param transactionID the transaction ID
57 * @return a Set of SoftLocks
58 */
59 Set<SoftLock> collectAllSoftLocksForTransactionID(TransactionID transactionID);
60
61 }