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 /**
20 * Provides all possible states of a {@link PooledObject}.
21 *
22 * @since 2.0
23 */
24 public enum PooledObjectState {
25
26 /**
27 * In the queue, not in use.
28 */
29 IDLE,
30
31 /**
32 * In use.
33 */
34 ALLOCATED,
35
36 /**
37 * In the queue, currently being tested for possible eviction.
38 */
39 EVICTION,
40
41 /**
42 * Not in the queue, currently being tested for possible eviction. An attempt to borrow the object was made while
43 * being tested which removed it from the queue. It should be returned to the head of the queue once eviction
44 * testing completes.
45 * <p>
46 * TODO: Consider allocating object and ignoring the result of the eviction test.
47 * </p>
48 */
49 EVICTION_RETURN_TO_HEAD,
50
51 /**
52 * In the queue, currently being validated.
53 */
54 VALIDATION,
55
56 /**
57 * Not in queue, currently being validated. The object was borrowed while being validated and since testOnBorrow was
58 * configured, it was removed from the queue and pre-allocated. It should be allocated once validation completes.
59 */
60 VALIDATION_PREALLOCATED,
61
62 /**
63 * Not in queue, currently being validated. An attempt to borrow the object was made while previously being tested
64 * for eviction which removed it from the queue. It should be returned to the head of the queue once validation
65 * completes.
66 */
67 VALIDATION_RETURN_TO_HEAD,
68
69 /**
70 * Failed maintenance (e.g. eviction test or validation) and will be / has been destroyed
71 */
72 INVALID,
73
74 /**
75 * Deemed abandoned, to be invalidated.
76 */
77 ABANDONED,
78
79 /**
80 * Returning to the pool.
81 */
82 RETURNING
83 }