001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.pool2;
018
019/**
020 * Provides all possible states of a {@link PooledObject}.
021 *
022 * @since 2.0
023 */
024public enum PooledObjectState {
025
026    /**
027     * In the queue, not in use.
028     */
029    IDLE,
030
031    /**
032     * In use.
033     */
034    ALLOCATED,
035
036    /**
037     * In the queue, currently being tested for possible eviction.
038     */
039    EVICTION,
040
041    /**
042     * Not in the queue, currently being tested for possible eviction. An attempt to borrow the object was made while
043     * being tested which removed it from the queue. It should be returned to the head of the queue once eviction
044     * testing completes.
045     * <p>
046     * TODO: Consider allocating object and ignoring the result of the eviction test.
047     * </p>
048     */
049    EVICTION_RETURN_TO_HEAD,
050
051    /**
052     * In the queue, currently being validated.
053     */
054    VALIDATION,
055
056    /**
057     * Not in queue, currently being validated. The object was borrowed while being validated and since testOnBorrow was
058     * configured, it was removed from the queue and pre-allocated. It should be allocated once validation completes.
059     */
060    VALIDATION_PREALLOCATED,
061
062    /**
063     * Not in queue, currently being validated. An attempt to borrow the object was made while previously being tested
064     * for eviction which removed it from the queue. It should be returned to the head of the queue once validation
065     * completes.
066     */
067    VALIDATION_RETURN_TO_HEAD,
068
069    /**
070     * Failed maintenance (e.g. eviction test or validation) and will be / has been destroyed
071     */
072    INVALID,
073
074    /**
075     * Deemed abandoned, to be invalidated.
076     */
077    ABANDONED,
078
079    /**
080     * Returning to the pool.
081     */
082    RETURNING
083}