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.impl;
018
019/**
020 * The interface that defines the information about pooled objects that will be exposed via JMX.
021 * <h2>Note</h2>
022 * <p>
023 * 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
024 * 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
025 * new minor or patch release without requiring code changes.
026 * </p>
027 *
028 * @since 2.0
029 */
030public interface DefaultPooledObjectInfoMBean {
031
032    /**
033     * Gets the number of times this object has been borrowed.
034     *
035     * @return The number of times this object has been borrowed.
036     * @since 2.1
037     */
038    long getBorrowedCount();
039
040    /**
041     * Gets the time (using the same basis as {@link java.time.Clock#instant()}) that pooled object was created.
042     *
043     * @return The creation time for the pooled object.
044     */
045    long getCreateTime();
046
047    /**
048     * Gets the time that pooled object was created.
049     *
050     * @return The creation time for the pooled object formatted as {@code yyyy-MM-dd HH:mm:ss Z}.
051     */
052    String getCreateTimeFormatted();
053
054    /**
055     * Gets the time (using the same basis as {@link java.time.Clock#instant()}) the polled object was last borrowed.
056     *
057     * @return The time the pooled object was last borrowed.
058     */
059    long getLastBorrowTime();
060
061    /**
062     * Gets the time that pooled object was last borrowed.
063     *
064     * @return The last borrowed time for the pooled object formatted as {@code yyyy-MM-dd HH:mm:ss Z}.
065     */
066    String getLastBorrowTimeFormatted();
067
068    /**
069     * Gets the stack trace recorded when the pooled object was last borrowed.
070     *
071     * @return The stack trace showing which code last borrowed the pooled object.
072     */
073    String getLastBorrowTrace();
074
075    /**
076     * Gets the time (using the same basis as {@link java.time.Clock#instant()})the wrapped object was last returned.
077     *
078     * @return The time the object was last returned.
079     */
080    long getLastReturnTime();
081
082    /**
083     * Gets the time that pooled object was last returned.
084     *
085     * @return The last returned time for the pooled object formatted as {@code yyyy-MM-dd HH:mm:ss Z}.
086     */
087    String getLastReturnTimeFormatted();
088
089    /**
090     * Gets a String form of the wrapper for debug purposes. The format is not fixed and may change at any time.
091     *
092     * @return A string representation of the pooled object.
093     *
094     * @see Object#toString()
095     */
096    String getPooledObjectToString();
097
098    /**
099     * 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}