1 package org.csc.phynixx.xa;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import org.csc.phynixx.connection.*;
25
26
27
28
29
30 class LocalTransactionProxy<C extends IPhynixxConnection> extends PhynixxManagedConnectionListenerAdapter<C> implements IPhynixxManagedConnectionListener<C>, ITransactionBinding<C> {
31
32
33
34 private IPhynixxManagedConnection<C> connection;
35
36
37 LocalTransactionProxy(IPhynixxManagedConnection<C> connection) {
38 this.connection = connection;
39 this.connection.addConnectionListener(this);
40 }
41
42
43
44
45 boolean hasTransactionalData() {
46 return this.connection!=null && connection.hasTransactionalData();
47 }
48
49 boolean isClosed() {
50 return this.getConnection() == null || this.getConnection().isClosed();
51 }
52
53
54 @Override
55 public TransactionBindingType getTransactionBindingType() {
56 return TransactionBindingType.LocalTransaction;
57 }
58
59
60
61
62 @Override
63 public void release() {
64 if (connection != null) {
65 this.connection.removeConnectionListener(this);
66 }
67 this.connection = null;
68 }
69
70 @Override
71 public void close() {
72 if (connection != null) {
73 IPhynixxManagedConnection<C> connection=this.connection;
74 this.release();
75 connection.close();
76 }
77
78 }
79
80 @Override
81 public IPhynixxManagedConnection<C> getConnection() {
82 return connection;
83 }
84
85
86
87
88 @Override
89 public void connectionReleased(IManagedConnectionEvent<C> event) {
90 event.getManagedConnection().removeConnectionListener(this);
91 }
92
93 @Override
94 public void connectionFreed(IManagedConnectionEvent<C> event) {
95 event.getManagedConnection().removeConnectionListener(this);
96 }
97 }