| 1 | package com.reallifedeveloper.common.infrastructure.jmx; | |
| 2 | ||
| 3 | import org.apache.tomcat.jdbc.pool.DataSource; | |
| 4 | import org.springframework.jmx.export.annotation.ManagedAttribute; | |
| 5 | import org.springframework.jmx.export.annotation.ManagedOperation; | |
| 6 | import org.springframework.jmx.export.annotation.ManagedResource; | |
| 7 | ||
| 8 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | |
| 9 | ||
| 10 | import com.reallifedeveloper.common.domain.ErrorHandling; | |
| 11 | ||
| 12 | /** | |
| 13 | * An implementation of the JMX {@link ConnectionPoolConfiguratorMXBean} interface that delegates to an | |
| 14 | * {@code org.apache.tomcat.jdbc.pool.DataSource} object. | |
| 15 | * | |
| 16 | * @author RealLifeDeveloper | |
| 17 | */ | |
| 18 | @ManagedResource(description = "Connection Pool Configuration") | |
| 19 | public final class TomcatConnectionPoolConfigurator implements ConnectionPoolConfiguratorMXBean { | |
| 20 | ||
| 21 | private final DataSource ds; | |
| 22 | ||
| 23 | /** | |
| 24 | * Creates a new {@code TomcatConnectionPoolConfigurator} that delegates to the given data source. | |
| 25 | * | |
| 26 | * @param ds the data source to delegate to | |
| 27 | */ | |
| 28 | @SuppressFBWarnings("EI_EXPOSE_REP2") | |
| 29 | public TomcatConnectionPoolConfigurator(DataSource ds) { | |
| 30 |
1
1. <init> : removed call to com/reallifedeveloper/common/domain/ErrorHandling::checkNull → KILLED |
ErrorHandling.checkNull("ds must not be null", ds); |
| 31 | this.ds = ds; | |
| 32 | } | |
| 33 | ||
| 34 | @Override | |
| 35 | @ManagedAttribute(description = "The URL used to connect to the database") | |
| 36 | public String getUrl() { | |
| 37 |
1
1. getUrl : replaced return value with "" for com/reallifedeveloper/common/infrastructure/jmx/TomcatConnectionPoolConfigurator::getUrl → KILLED |
return ds.getUrl(); |
| 38 | } | |
| 39 | ||
| 40 | @Override | |
| 41 | @ManagedAttribute(description = "The fully qualified JDBC driver name") | |
| 42 | public String getDriverClassName() { | |
| 43 |
1
1. getDriverClassName : replaced return value with "" for com/reallifedeveloper/common/infrastructure/jmx/TomcatConnectionPoolConfigurator::getDriverClassName → KILLED |
return ds.getDriverClassName(); |
| 44 | } | |
| 45 | ||
| 46 | @Override | |
| 47 | @ManagedAttribute(description = "The current size of the pool") | |
| 48 | public int getSize() { | |
| 49 |
1
1. getSize : replaced int return with 0 for com/reallifedeveloper/common/infrastructure/jmx/TomcatConnectionPoolConfigurator::getSize → KILLED |
return ds.getSize(); |
| 50 | } | |
| 51 | ||
| 52 | @Override | |
| 53 | @ManagedAttribute(description = "The number of established but idle connections") | |
| 54 | public int getIdle() { | |
| 55 |
1
1. getIdle : replaced int return with 0 for com/reallifedeveloper/common/infrastructure/jmx/TomcatConnectionPoolConfigurator::getIdle → KILLED |
return ds.getIdle(); |
| 56 | } | |
| 57 | ||
| 58 | @Override | |
| 59 | @ManagedAttribute(description = "The number of connections in use by the application") | |
| 60 | public int getActive() { | |
| 61 |
1
1. getActive : replaced int return with 0 for com/reallifedeveloper/common/infrastructure/jmx/TomcatConnectionPoolConfigurator::getActive → SURVIVED |
return ds.getActive(); |
| 62 | } | |
| 63 | ||
| 64 | @Override | |
| 65 | @ManagedAttribute(description = "The number of threads waiting for a connection") | |
| 66 | public int getWaitCount() { | |
| 67 |
1
1. getWaitCount : replaced int return with 0 for com/reallifedeveloper/common/infrastructure/jmx/TomcatConnectionPoolConfigurator::getWaitCount → SURVIVED |
return ds.getWaitCount(); |
| 68 | } | |
| 69 | ||
| 70 | @Override | |
| 71 | @ManagedOperation(description = "Forces a check for resizing of the idle connections") | |
| 72 | public void checkIdle() { | |
| 73 |
1
1. checkIdle : removed call to org/apache/tomcat/jdbc/pool/DataSource::checkIdle → SURVIVED |
ds.checkIdle(); |
| 74 | } | |
| 75 | ||
| 76 | @Override | |
| 77 | @ManagedOperation(description = "Forces an abandon check on the connection pool") | |
| 78 | public void checkAbandoned() { | |
| 79 |
1
1. checkAbandoned : removed call to org/apache/tomcat/jdbc/pool/DataSource::checkAbandoned → SURVIVED |
ds.checkAbandoned(); |
| 80 | } | |
| 81 | ||
| 82 | @Override | |
| 83 | @ManagedOperation(description = "Performs a validation on idle connections") | |
| 84 | public void testIdle() { | |
| 85 |
1
1. testIdle : removed call to org/apache/tomcat/jdbc/pool/DataSource::testIdle → SURVIVED |
ds.testIdle(); |
| 86 | } | |
| 87 | ||
| 88 | @Override | |
| 89 | @ManagedOperation(description = "Purges all connections in the pool") | |
| 90 | public void purge() { | |
| 91 |
1
1. purge : removed call to org/apache/tomcat/jdbc/pool/DataSource::purge → KILLED |
ds.purge(); |
| 92 | } | |
| 93 | ||
| 94 | @Override | |
| 95 | @ManagedOperation(description = "Purges connections when they are returned from the pool") | |
| 96 | public void purgeOnReturn() { | |
| 97 |
1
1. purgeOnReturn : removed call to org/apache/tomcat/jdbc/pool/DataSource::purgeOnReturn → SURVIVED |
ds.purgeOnReturn(); |
| 98 | } | |
| 99 | ||
| 100 | } | |
Mutations | ||
| 30 |
1.1 |
|
| 37 |
1.1 |
|
| 43 |
1.1 |
|
| 49 |
1.1 |
|
| 55 |
1.1 |
|
| 61 |
1.1 |
|
| 67 |
1.1 |
|
| 73 |
1.1 |
|
| 79 |
1.1 |
|
| 85 |
1.1 |
|
| 91 |
1.1 |
|
| 97 |
1.1 |