~ubuntu-branches/ubuntu/trusty/ehcache/trusty

« back to all changes in this revision

Viewing changes to src/main/java/net/sf/ehcache/transaction/TransactionIDFactoryImpl.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-05-06 14:53:07 UTC
  • mfrom: (1.1.7) (2.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130506145307-v5bhw5yu70re00l3
Tags: 2.6.7-1
* Team upload.
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 *  Copyright 2003-2010 Terracotta, Inc.
 
2
 *  Copyright Terracotta, Inc.
3
3
 *
4
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
5
 *  you may not use this file except in compliance with the License.
15
15
 */
16
16
package net.sf.ehcache.transaction;
17
17
 
 
18
import java.util.concurrent.ConcurrentHashMap;
 
19
import java.util.concurrent.ConcurrentMap;
 
20
 
 
21
import net.sf.ehcache.Ehcache;
18
22
import net.sf.ehcache.transaction.xa.XidTransactionID;
19
23
import net.sf.ehcache.transaction.xa.XidTransactionIDImpl;
20
24
 
25
29
 
26
30
 * @author Ludovic Orban
27
31
 */
28
 
public class TransactionIDFactoryImpl implements TransactionIDFactory {
 
32
public class TransactionIDFactoryImpl extends AbstractTransactionIDFactory {
29
33
 
30
 
    /**
31
 
     * Create a new TransactionIDFactory
32
 
     */
33
 
    public TransactionIDFactoryImpl() {
34
 
        //
35
 
    }
 
34
    private final ConcurrentMap<TransactionID, Decision> transactionStates = new ConcurrentHashMap<TransactionID, Decision>();
36
35
 
37
36
    /**
38
37
     * {@inheritDoc}
39
38
     */
40
39
    public TransactionID createTransactionID() {
41
 
        return new TransactionIDImpl();
42
 
    }
43
 
 
44
 
    /**
45
 
     * {@inheritDoc}
46
 
     */
47
 
    public XidTransactionID createXidTransactionID(Xid xid) {
48
 
        return new XidTransactionIDImpl(xid);
49
 
    }
50
 
 
 
40
        TransactionID id = new TransactionIDImpl();
 
41
        getTransactionStates().putIfAbsent(id, Decision.IN_DOUBT);
 
42
        return id;
 
43
    }
 
44
 
 
45
    /**
 
46
     * {@inheritDoc}
 
47
     */
 
48
    public TransactionID restoreTransactionID(TransactionIDSerializedForm serializedForm) {
 
49
        throw new UnsupportedOperationException("unclustered transaction IDs are directly deserializable!");
 
50
    }
 
51
 
 
52
    /**
 
53
     * {@inheritDoc}
 
54
     */
 
55
    public XidTransactionID createXidTransactionID(Xid xid, Ehcache cache) {
 
56
        XidTransactionID id = new XidTransactionIDImpl(xid, cache.getName());
 
57
        getTransactionStates().putIfAbsent(id, Decision.IN_DOUBT);
 
58
        return id;
 
59
    }
 
60
 
 
61
    /**
 
62
     * {@inheritDoc}
 
63
     */
 
64
    public XidTransactionID restoreXidTransactionID(XidTransactionIDSerializedForm serializedForm) {
 
65
        throw new UnsupportedOperationException("unclustered transaction IDs are directly deserializable!");
 
66
    }
 
67
 
 
68
    @Override
 
69
    protected ConcurrentMap<TransactionID, Decision> getTransactionStates() {
 
70
        return transactionStates;
 
71
    }
 
72
 
 
73
    @Override
 
74
    public Boolean isPersistent() {
 
75
        return Boolean.FALSE;
 
76
    }
 
77
 
 
78
    @Override
 
79
    public boolean isExpired(TransactionID transactionID) {
 
80
        return false;
 
81
    }
51
82
}