1 package org.csc.phynixx.connection;
2
3 /*
4 * #%L
5 * phynixx-connection
6 * %%
7 * Copyright (C) 2014 csc
8 * %%
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * #L%
21 */
22
23
24 /**
25 * a managed connection is managed by the phynixx system.
26 * it takes care of integrating the connection into the phynixx XA Implementation
27 * and/or provides persistent logger to store transaction data.
28 * <p/>
29 * It decorates the origin Connection with one or more aspects an. You can declare new decorators by {@link PhynixxManagedConnectionFactory}
30 * <p/>
31 * <p/>
32 * this IF combines the role of a core connection and the role of a connection proxy.
33 * <p/>
34 * Impl. of this IF represents the access to the core connections in this FW
35 *
36 * h1. Thread Safeness
37 *
38 * When this connection is used in a pool ({@link org.csc.phynixx.connection.PooledPhynixxManagedConnectionFactory} it is strongly recommend to synchronized
39 * the connection {@link #setSynchronized(boolean)}.
40 *
41 * When a connection is get from the pool or if it is released to it some functionality of the connection is used.
42 * It is no obvious if the pools implementation of {@link org.apache.commons.pool2.impl.GenericObjectPool} is strictly thread safe.
43 * @author christoph
44 */
45 public interface IPhynixxManagedConnection<C extends IPhynixxConnection> extends IPhynixxConnection, ICloseable //, IPhynixxConnectionHandle<C>
46 {
47 /**
48 * set the thread safeness of the connection.
49 * @param state
50 */
51 void setSynchronized(boolean state);
52
53 /**
54 *
55 * @return shows if the connection is thread safe
56 */
57 boolean isSynchronized();
58
59 /**
60 * @return Id unique for the scope of the factory
61 */
62 long getManagedConnectionId();
63
64 /**
65 * @return the managed Core Connection
66 */
67 C getCoreConnection();
68
69 /**
70 *
71 * @return shows if the connection has transactional data
72 */
73 boolean hasTransactionalData();
74
75 /**
76 * @return current connection interpreted as core connection, but still managed
77 */
78 C toConnection();
79
80
81 /**
82 * marks a connection a freed. This connection won't be used any more
83 */
84 void free();
85
86 boolean hasCoreConnection();
87
88 void recover();
89
90
91 void commit(boolean onePhaseCommit);
92
93
94 /**
95 * opens a connection that may have been reset. After calling this method
96 * {@link #isClosed()}==false and {@link IPhynixxConnection#reset()} is called on the physical connection.
97 *
98 * @throws java.lang.IllegalStateException connection has transactional data
99 */
100 void reopen();
101
102 void addConnectionListener(IPhynixxManagedConnectionListener<C> listener);
103
104 void removeConnectionListener(IPhynixxManagedConnectionListener<C> listener);
105
106 }