KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > connectionmanager > ConnectionListener


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.resource.connectionmanager;
23
24 import javax.resource.ResourceException JavaDoc;
25 import javax.resource.spi.ConnectionEventListener JavaDoc;
26 import javax.resource.spi.ManagedConnection JavaDoc;
27 import javax.transaction.SystemException JavaDoc;
28
29 /**
30  * A jboss connection listener
31  *
32  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
33  * @author <a HREF="mailto:weston.price@jboss.com">Weston Price</a>
34  *
35  * @version $Revision: 45410 $
36  */

37 public interface ConnectionListener extends ConnectionEventListener JavaDoc
38 {
39    /** Normal state */
40    public static final int NORMAL = 0;
41    
42    /** Destroy this connection */
43    public static final int DESTROY = 1;
44    
45    /** This connection has been destroyed */
46    public static final int DESTROYED = 2;
47    
48    /**
49     * Retrieve the managed connection for this listener
50     *
51     * @return the managed connection
52     */

53    ManagedConnection JavaDoc getManagedConnection();
54    
55    /**
56     * Retrieve the managed connection pool for this listener
57     *
58     * @return the managed connection pool
59     */

60    ManagedConnectionPool getManagedConnectionPool();
61
62    /**
63     * Tidyup<p>
64     *
65     * Invoked just before returning the connection to the pool
66     * when the connection is not being destroyed
67     *
68     * @throws ResourceException for any error
69     */

70    void tidyup() throws ResourceException JavaDoc;
71    
72    /**
73     * Retrieve the context used by the pool
74     *
75     * @return the context
76     */

77    Object JavaDoc getContext();
78    
79    /**
80     * Retrieve the state of this connection
81     *
82     * @return the state
83     */

84    int getState();
85    
86    /**
87     * Set the state of this connection
88     */

89    void setState(int newState);
90    
91    /**
92     * Has the connection timed out?
93     *
94     * @param timeout the timeout
95     * @return true for timed out, false otherwise
96     */

97    boolean isTimedOut(long timeout);
98    
99    /**
100     * Mark the connection as used
101     */

102    void used();
103
104    /**
105     * Register a new connection
106     *
107     * @param handle the connection handle
108     */

109    void registerConnection(Object JavaDoc handle);
110
111    /**
112     * Unregister a connection
113     *
114     * @param handle the connection handle
115     */

116    void unregisterConnection(Object JavaDoc handle);
117
118    /**
119     * Is the managed connection free?
120     *
121     * @return true when it is free
122     */

123    boolean isManagedConnectionFree();
124
125    /**
126     * Enlist the managed connection
127     */

128    void enlist() throws SystemException JavaDoc;
129
130    /**
131     * Delist the managed connection
132     */

133    void delist() throws ResourceException JavaDoc;
134    
135    /**
136     * Get whether the listener is track by transaction
137     *
138     * @return true for track by transaction, false otherwise
139     */

140    boolean isTrackByTx();
141    
142    /**
143     * Set whether the listener is track by transaction
144     *
145     * @param trackByTx true for track by transaction, false otherwise
146     */

147    void setTrackByTx(boolean trackByTx);
148    
149    /**
150     * Whether the connection has a permit
151     *
152     * @return true when it has permit, false otherwise
153     */

154    boolean hasPermit();
155    
156    /**
157     * Tell the connection listener whether it owns the permit.
158     *
159     * @param value true for owning the permit, false otherwise
160     */

161    void grantPermit(boolean value);
162
163    /**
164     * Retrieve the last time this connection was validated.
165     *
166     * @return the last time the connection was validated
167     */

168    long getLastValidatedTime();
169    
170    
171    /**
172     * Set the last time, in milliseconds, that this connection was validated.
173     *
174     * @param interval the last time the connection was validated in milliseconds.
175     */

176    void setLastValidatedTime(long interval);
177 }
178
Popular Tags