001: /*
002: * Distributed as part of c3p0 v.0.9.1.2
003: *
004: * Copyright (C) 2005 Machinery For Change, Inc.
005: *
006: * Author: Steve Waldman <swaldman@mchange.com>
007: *
008: * This library is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU Lesser General Public License version 2.1, as
010: * published by the Free Software Foundation.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public License
018: * along with this software; see the file LICENSE. If not, write to the
019: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: */
022:
023: package com.mchange.v2.resourcepool;
024:
025: import com.mchange.v1.util.ClosableResource;
026:
027: public interface ResourcePool extends ClosableResource {
028: // status in pool return values
029: final static int KNOWN_AND_AVAILABLE = 0;
030: final static int KNOWN_AND_CHECKED_OUT = 1;
031: final static int UNKNOWN_OR_PURGED = -1;
032:
033: public Object checkoutResource() throws ResourcePoolException,
034: InterruptedException;
035:
036: public Object checkoutResource(long timeout)
037: throws TimeoutException, ResourcePoolException,
038: InterruptedException;
039:
040: public void checkinResource(Object resc)
041: throws ResourcePoolException;
042:
043: public void checkinAll() throws ResourcePoolException;
044:
045: public int statusInPool(Object resc) throws ResourcePoolException;
046:
047: /**
048: * Marks a resource as broken. If the resource is checked in,
049: * it will be destroyed immediately. Otherwise, it will be
050: * destroyed on checkin.
051: */
052: public void markBroken(Object resc) throws ResourcePoolException;
053:
054: public int getMinPoolSize() throws ResourcePoolException;
055:
056: public int getMaxPoolSize() throws ResourcePoolException;
057:
058: public int getPoolSize() throws ResourcePoolException;
059:
060: public void setPoolSize(int size) throws ResourcePoolException;
061:
062: public int getAvailableCount() throws ResourcePoolException;
063:
064: public int getExcludedCount() throws ResourcePoolException;
065:
066: public int getAwaitingCheckinCount() throws ResourcePoolException;
067:
068: public long getEffectiveExpirationEnforcementDelay()
069: throws ResourcePoolException;
070:
071: public long getStartTime() throws ResourcePoolException;
072:
073: public long getUpTime() throws ResourcePoolException;
074:
075: public long getNumFailedCheckins() throws ResourcePoolException;
076:
077: public long getNumFailedCheckouts() throws ResourcePoolException;
078:
079: public long getNumFailedIdleTests() throws ResourcePoolException;
080:
081: public int getNumCheckoutWaiters() throws ResourcePoolException;
082:
083: public Throwable getLastAcquisitionFailure()
084: throws ResourcePoolException;
085:
086: public Throwable getLastCheckinFailure()
087: throws ResourcePoolException;
088:
089: public Throwable getLastCheckoutFailure()
090: throws ResourcePoolException;
091:
092: public Throwable getLastIdleCheckFailure()
093: throws ResourcePoolException;
094:
095: public Throwable getLastResourceTestFailure()
096: throws ResourcePoolException;
097:
098: /**
099: * Discards all resources managed by the pool
100: * and reacquires new resources to populate the
101: * pool. Current checked out resources will still
102: * be valid, and should still be checked into the
103: * pool (so the pool can destroy them).
104: */
105: public void resetPool() throws ResourcePoolException;
106:
107: public void close() throws ResourcePoolException;
108:
109: public void close(boolean close_checked_out_resources)
110: throws ResourcePoolException;
111:
112: public interface Manager {
113: public Object acquireResource() throws Exception;
114:
115: public void refurbishIdleResource(Object resc) throws Exception;
116:
117: public void refurbishResourceOnCheckout(Object resc)
118: throws Exception;
119:
120: public void refurbishResourceOnCheckin(Object resc)
121: throws Exception;
122:
123: public void destroyResource(Object resc) throws Exception;
124: }
125: }
|