public class PoolLogger extends Object
Pool
or PoolableObject
.
Instances of this class are thread-safe.
This class needs SLF4J to be present on the class path to work. If it isn't nothing will be logged at all.
Modifier and Type | Class and Description |
---|---|
static class |
PoolLogger.Builder
A builder for
PoolLogger objects. |
Modifier and Type | Method and Description |
---|---|
void |
acquiredObject(PoolableObject<?> object,
int idleCount,
int poolSize)
Called when a
PoolableObject is acquired from a Pool . |
void |
createdNonPooledObject(PoolableObject<?> object)
Called when a new
PoolableObject has been created that will not be returned to the pool it was
acquired from. |
void |
createdObject(PoolableObject<?> object)
Called when a new
PoolableObject has been created. |
void |
createdPool(PoolConfig config)
Called when a
Pool has been created. |
void |
creatingPool(PoolConfig config)
Called when a
Pool is being created. |
static PoolLogger.Builder |
custom()
Returns a new builder for creating
PoolLogger objects. |
void |
decreasedObjectRefCount(PoolableObject<?> object,
int refCount)
Called when a reference was removed from a
PoolableObject . |
static PoolLogger |
defaultLogger()
Returns a default
PoolLogger object. |
void |
drainedPool(int poolSize)
Called when a
Pool is drained. |
void |
failedToCreatePool(Exception exception)
Called when a
Pool could not be created. |
void |
increasedObjectRefCount(PoolableObject<?> object,
int refCount)
Called when an additional reference was added to a
PoolableObject . |
boolean |
isEnabled(LogLevel level)
Returns whether or not logging at a specific level is enabled.
|
static PoolLogger |
noopLogger()
Returns a
PoolLogger object that does not perform any actual logging. |
void |
objectEvent(LogLevel level,
PoolableObject<?> object,
String message)
Called when
PoolableObject.logEvent(LogLevel, String) is called. |
void |
objectEvent(LogLevel level,
PoolableObject<?> object,
Supplier<String> messageSupplier)
Called when
PoolableObject.logEvent(LogLevel, Supplier) is called. |
void |
objectIdleTooLong(PoolableObject<?> object,
int idleCount,
int poolSize)
Called when a
PoolableObject has been idle for too long. |
void |
objectInvalidated(PoolableObject<?> object,
int idleCount,
int poolSize)
Called when a
PoolableObject is no longer valid and has been removed from its Pool . |
void |
releasedObjectResources(PoolableObject<?> object)
Called when the resources of a
PoolableObject have been released. |
void |
releaseObjectResourcesFailed(PoolableObject<?> object,
Exception exception)
Called when an error occurs when quietly releasing the resources of a
PoolableObject . |
void |
releasingObjectResources(PoolableObject<?> object)
Called before the resources of a
PoolableObject will be released. |
void |
returnedObject(PoolableObject<?> object,
int idleCount,
int poolSize)
Called when a
PoolableObject is returned to a Pool . |
void |
shutDownPool()
Called when a
Pool has shut down. |
String |
toString() |
public void creatingPool(PoolConfig config)
Pool
is being created.config
- The configuration for the Pool
.public void createdPool(PoolConfig config)
Pool
has been created.config
- The configuration for the Pool
.public void failedToCreatePool(Exception exception)
Pool
could not be created.exception
- The exception that was thrown while creating the Pool
.public void drainedPool(int poolSize)
Pool
is drained. This is like acquiring all available idle PoolableObject
s in one call.poolSize
- The total pool size - the number of acquired PoolableObject
s.public void shutDownPool()
Pool
has shut down.public void createdObject(PoolableObject<?> object)
PoolableObject
has been created.object
- The PoolableObject
.public void createdNonPooledObject(PoolableObject<?> object)
PoolableObject
has been created that will not be returned to the pool it was
acquired from.object
- The PoolableObject
.public void increasedObjectRefCount(PoolableObject<?> object, int refCount)
PoolableObject
.object
- The PoolableObject
.refCount
- The new number of references, including the PoolableObject
itself.PoolableObject.addReference(Object)
public void decreasedObjectRefCount(PoolableObject<?> object, int refCount)
PoolableObject
.object
- The PoolableObject
.refCount
- The new number of references, including the PoolableObject
itself.PoolableObject.removeReference(Object)
public void releasingObjectResources(PoolableObject<?> object)
PoolableObject
will be released.object
- The PoolableObject
.PoolableObject.releaseResources()
public void releasedObjectResources(PoolableObject<?> object)
PoolableObject
have been released.object
- The PoolableObject
.PoolableObject.releaseResources()
public void releaseObjectResourcesFailed(PoolableObject<?> object, Exception exception)
PoolableObject
.object
- The PoolableObject
.exception
- The exception that was thrown while quietly releasing the resources of the PoolableObject
.PoolableObject.releaseResources()
public void acquiredObject(PoolableObject<?> object, int idleCount, int poolSize)
PoolableObject
is acquired from a Pool
.object
- The PoolableObject
.idleCount
- The number of idle PoolableObject
s after acquiring the PoolableObject
.poolSize
- The total pool size - the number of acquired and idle PoolableObject
s combined.public void returnedObject(PoolableObject<?> object, int idleCount, int poolSize)
PoolableObject
is returned to a Pool
.object
- The PoolableObject
.idleCount
- The number of idle PoolableObject
s after returning the PoolableObject
.poolSize
- The total pool size - the number of acquired and idle PoolableObject
s combined.public void objectInvalidated(PoolableObject<?> object, int idleCount, int poolSize)
PoolableObject
is no longer valid and has been removed from its Pool
.object
- The PoolableObject
.idleCount
- The number of idle PoolableObject
s after invalidating the PoolableObject
.poolSize
- The total pool size - the number of acquired and idle PoolableObject
s combined.PoolableObject.validate()
public void objectIdleTooLong(PoolableObject<?> object, int idleCount, int poolSize)
PoolableObject
has been idle for too long.object
- The PoolableObject
.idleCount
- The number of idle PoolableObject
s after invalidating the PoolableObject
.poolSize
- The total pool size - the number of acquired and idle PoolableObject
s combined.public void objectEvent(LogLevel level, PoolableObject<?> object, String message)
PoolableObject.logEvent(LogLevel, String)
is called.level
- The log level to use.object
- The PoolableObject
.message
- The event message.public void objectEvent(LogLevel level, PoolableObject<?> object, Supplier<String> messageSupplier)
PoolableObject.logEvent(LogLevel, Supplier)
is called.level
- The log level to use.object
- The PoolableObject
.messageSupplier
- A supplier for the event message.public boolean isEnabled(LogLevel level)
level
- The level to check.true
if logging at the given level is enabled, or false
otherwise.public static PoolLogger defaultLogger()
PoolLogger
object. This has the same configuration as an object returned by custom().build()
.PoolLogger
object.public static PoolLogger noopLogger()
PoolLogger
object that does not perform any actual logging.
This can be used as default value in case no logger should be used, instead of checking for null
.PoolLogger
object that does not perform any actual logging.public static PoolLogger.Builder custom()
PoolLogger
objects.PoolLogger
objects.Copyright © 2022. All rights reserved.