PooledObjectState.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.pool2;

  18. /**
  19.  * Provides all possible states of a {@link PooledObject}.
  20.  *
  21.  * @since 2.0
  22.  */
  23. public enum PooledObjectState {

  24.     /**
  25.      * In the queue, not in use.
  26.      */
  27.     IDLE,

  28.     /**
  29.      * In use.
  30.      */
  31.     ALLOCATED,

  32.     /**
  33.      * In the queue, currently being tested for possible eviction.
  34.      */
  35.     EVICTION,

  36.     /**
  37.      * Not in the queue, currently being tested for possible eviction. An attempt to borrow the object was made while
  38.      * being tested which removed it from the queue. It should be returned to the head of the queue once eviction
  39.      * testing completes.
  40.      * <p>
  41.      * TODO: Consider allocating object and ignoring the result of the eviction test.
  42.      * </p>
  43.      */
  44.     EVICTION_RETURN_TO_HEAD,

  45.     /**
  46.      * In the queue, currently being validated.
  47.      */
  48.     VALIDATION,

  49.     /**
  50.      * Not in queue, currently being validated. The object was borrowed while being validated and since testOnBorrow was
  51.      * configured, it was removed from the queue and pre-allocated. It should be allocated once validation completes.
  52.      */
  53.     VALIDATION_PREALLOCATED,

  54.     /**
  55.      * Not in queue, currently being validated. An attempt to borrow the object was made while previously being tested
  56.      * for eviction which removed it from the queue. It should be returned to the head of the queue once validation
  57.      * completes.
  58.      */
  59.     VALIDATION_RETURN_TO_HEAD,

  60.     /**
  61.      * Failed maintenance (e.g. eviction test or validation) and will be / has been destroyed
  62.      */
  63.     INVALID,

  64.     /**
  65.      * Deemed abandoned, to be invalidated.
  66.      */
  67.     ABANDONED,

  68.     /**
  69.      * Returning to the pool.
  70.      */
  71.     RETURNING
  72. }