/* * 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 an * {@link ObjectPool}. *
* By contract, when an {@link ObjectPool} delegates to a * {@link PooledObjectFactory}, *
*PoolableObjectFactory
* at a time.
* * While clients of a {@link KeyedObjectPool} borrow and return instances of * the underlying value type {@code 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 information about the objects that * they manage. *
* * @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 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 ObjectPool#invalidateObject */ void destroyObject(PooledObjectfalse if obj is not valid and should
* be dropped from the pool, true otherwise.
*/
boolean validateObject(PooledObjectobj,
* this exception may be swallowed by the pool.
*
* @see #destroyObject
*/
void activateObject(PooledObjectobj,
* this exception may be swallowed by the pool.
*
* @see #destroyObject
*/
void passivateObject(PooledObject