01: /**********************************************************************
02: Copyright (c) 2007 Erik Bengtson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: ...
17: **********************************************************************/package org.jpox;
18:
19: import javax.transaction.xa.XAResource;
20:
21: /**
22: * Wrapper for a connection to the datastore, allowing management.
23: *
24: * @version $Revision: 1.6 $
25: */
26: public interface ManagedConnection {
27: /**
28: * Connection to the datastore
29: * @return The underlying connection for this datastore
30: */
31: Object getConnection();
32:
33: /**
34: * An XAResoure for this datastore connection.
35: * Returns null if the connection is not transactional
36: * @return The XAResource
37: */
38: XAResource getXAResource();
39:
40: /**
41: * Method to release the connection when non-transactional.
42: * If this is a managed connection resource does nothing.
43: */
44: void release();
45:
46: /**
47: * Close the connection to the datastore. It most invoke the operations
48: * {@link ManagedConnectionResourceListener#managedConnectionPreClose()} and
49: * {@link ManagedConnectionResourceListener#managedConnectionPostClose()}.
50: * The listeners are unregistered after this method is invoked.
51: */
52: void close();
53:
54: /**
55: * Whether this connection is managed by a transaction manager
56: */
57: void setManagedResource();
58:
59: /**
60: * whether access to this ManagedConnection has been locked.
61: * @return true if locked
62: */
63: boolean isLocked();
64:
65: /**
66: * lock the access to this ManagedConnection
67: */
68: void lock();
69:
70: /**
71: * unlock the access to this ManagedConnection
72: */
73: void unlock();
74:
75: /**
76: * Flush the connection. It must invoke the operation
77: * {@link ManagedConnectionResourceListener#managedConnectionFlushed()}
78: */
79: void flush();
80:
81: /**
82: * Registers a ManagedConnectionResourceListener
83: * @param listener The listener
84: */
85: void addListener(ManagedConnectionResourceListener listener);
86:
87: /**
88: * Deregister a ManagedConnectionResourceListener
89: * @param listener The listener
90: */
91: void removeListener(ManagedConnectionResourceListener listener);
92: }
|