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
021 * exposed via JMX.
022 * <p>
023 * NOTE: This interface exists only to define those attributes and methods that
024 *       will be made available via JMX. It must not be implemented by clients
025 *       as it is subject to change between major, minor and patch version
026 *       releases of commons pool. Clients that implement this interface may
027 *       not, therefore, be able to upgrade to a new minor or patch release
028 *       without requiring code changes.
029 * </p>
030 *
031 * @since 2.0
032 */
033public interface DefaultPooledObjectInfoMBean {
034
035    /**
036     * Gets the number of times this object has been borrowed.
037     * @return The number of times this object has been borrowed.
038     * @since 2.1
039     */
040    long getBorrowedCount();
041
042    /**
043     * Gets the time (using the same basis as
044     * {@link System#currentTimeMillis()}) that pooled object was created.
045     *
046     * @return The creation time for the pooled object
047     */
048    long getCreateTime();
049
050    /**
051     * Gets the time that pooled object was created.
052     *
053     * @return The creation time for the pooled object formatted as
054     *         {@code yyyy-MM-dd HH:mm:ss Z}
055     */
056    String getCreateTimeFormatted();
057
058    /**
059     * Gets the time (using the same basis as
060     * {@link System#currentTimeMillis()}) the polled object was last borrowed.
061     *
062     * @return The time the pooled object was last borrowed
063     */
064    long getLastBorrowTime();
065
066    /**
067     * Gets the time that pooled object was last borrowed.
068     *
069     * @return The last borrowed time for the pooled object formatted as
070     *         {@code yyyy-MM-dd HH:mm:ss Z}
071     */
072    String getLastBorrowTimeFormatted();
073
074    /**
075     * Gets the stack trace recorded when the pooled object was last borrowed.
076     *
077     * @return The stack trace showing which code last borrowed the pooled
078     *         object
079     */
080    String getLastBorrowTrace();
081
082    /**
083     * Gets the time (using the same basis as
084     * {@link System#currentTimeMillis()})the wrapped object was last returned.
085     *
086     * @return The time the object was last returned
087     */
088    long getLastReturnTime();
089
090    /**
091     * Gets the time that pooled object was last returned.
092     *
093     * @return The last returned time for the pooled object formatted as
094     *         {@code yyyy-MM-dd HH:mm:ss Z}
095     */
096    String getLastReturnTimeFormatted();
097
098    /**
099     * Gets a String form of the wrapper for debug purposes. The format is
100     * not fixed and may change at any time.
101     *
102     * @return A string representation of the pooled object
103     *
104     * @see Object#toString()
105     */
106    String getPooledObjectToString();
107
108    /**
109     * Gets the name of the class of the pooled object.
110     *
111     * @return The pooled object's class name
112     *
113     * @see Class#getName()
114     */
115    String getPooledObjectType();
116}