/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.dbcp.pool2; /** * An interface defining life-cycle methods for * instances to be served by a {@link KeyedObjectPool}. *
* By contract, when an {@link KeyedObjectPool} * delegates to a {@link KeyedPooledObjectFactory}, *
*validateObject may also be used to test an
* instance being {@link KeyedObjectPool#returnObject returned} to the pool
* before it is {@link #passivateObject passivated}. It will only be invoked
* on an activated instance.
* validateObject,
* or for reasons specific to the pool implementation.) There is no
* guarantee that the instance being destroyed will
* be considered active, passive or in a generally consistent state.
* KeyedPoolableObjectFactory at a time.
* * While clients of a {@link KeyedObjectPool} borrow and return instances of * the underlying value type V, the factory methods act on instances of * {@link PooledObject PooledObject<V>}. These are the object wrappers that * pools use to track and maintain state informations about the objects that * they manage. *
* * @see KeyedObjectPool * @see BaseKeyedPooledObjectFactory * * @param
* It is important for implementations of this method to be aware that there
* is no guarantee about what state obj will be in and the
* implementation should be prepared to handle unexpected errors.
*
* Also, an implementation must take in to consideration that instances lost * to the garbage collector may never be destroyed. *
* * @param key the key used when selecting the instance * @param p a {@code PooledObject} wrapping the instance to be destroyed * * @throws Exception should be avoided as it may be swallowed by * the pool implementation. * * @see #validateObject * @see KeyedObjectPool#invalidateObject */ void destroyObject(K key, PooledObjectfalse if obj is not valid and should
* be dropped from the pool, true otherwise.
*/
boolean validateObject(K key, PooledObjectobj,
* this exception may be swallowed by the pool.
*
* @see #destroyObject
*/
void activateObject(K key, PooledObjectobj,
* this exception may be swallowed by the pool.
*
* @see #destroyObject
*/
void passivateObject(K key, PooledObject