View Javadoc
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.impl;
18  
19  /**
20   * The interface that defines the information about pooled objects that will be exposed via JMX.
21   * <h2>Note</h2>
22   * <p>
23   * This interface exists only to define those attributes and methods that will be made available via JMX. It must not be implemented by clients as it is subject
24   * to change between major, minor and patch version releases of commons pool. Clients that implement this interface may not, therefore, be able to upgrade to a
25   * new minor or patch release without requiring code changes.
26   * </p>
27   *
28   * @since 2.0
29   */
30  public interface DefaultPooledObjectInfoMBean {
31  
32      /**
33       * Gets the number of times this object has been borrowed.
34       *
35       * @return The number of times this object has been borrowed.
36       * @since 2.1
37       */
38      long getBorrowedCount();
39  
40      /**
41       * Gets the time (using the same basis as {@link java.time.Clock#instant()}) that pooled object was created.
42       *
43       * @return The creation time for the pooled object.
44       */
45      long getCreateTime();
46  
47      /**
48       * Gets the time that pooled object was created.
49       *
50       * @return The creation time for the pooled object formatted as {@code yyyy-MM-dd HH:mm:ss Z}.
51       */
52      String getCreateTimeFormatted();
53  
54      /**
55       * Gets the time (using the same basis as {@link java.time.Clock#instant()}) the polled object was last borrowed.
56       *
57       * @return The time the pooled object was last borrowed.
58       */
59      long getLastBorrowTime();
60  
61      /**
62       * Gets the time that pooled object was last borrowed.
63       *
64       * @return The last borrowed time for the pooled object formatted as {@code yyyy-MM-dd HH:mm:ss Z}.
65       */
66      String getLastBorrowTimeFormatted();
67  
68      /**
69       * Gets the stack trace recorded when the pooled object was last borrowed.
70       *
71       * @return The stack trace showing which code last borrowed the pooled object.
72       */
73      String getLastBorrowTrace();
74  
75      /**
76       * Gets the time (using the same basis as {@link java.time.Clock#instant()})the wrapped object was last returned.
77       *
78       * @return The time the object was last returned.
79       */
80      long getLastReturnTime();
81  
82      /**
83       * Gets the time that pooled object was last returned.
84       *
85       * @return The last returned time for the pooled object formatted as {@code yyyy-MM-dd HH:mm:ss Z}.
86       */
87      String getLastReturnTimeFormatted();
88  
89      /**
90       * Gets a String form of the wrapper for debug purposes. The format is not fixed and may change at any time.
91       *
92       * @return A string representation of the pooled object.
93       *
94       * @see Object#toString()
95       */
96      String getPooledObjectToString();
97  
98      /**
99       * Gets the name of the class of the pooled object.
100      *
101      * @return The pooled object's class name.
102      *
103      * @see Class#getName()
104      */
105     String getPooledObjectType();
106 }