use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class TestJdbcInterceptorConfigParsing method testBasic.
@Test
public void testBasic() throws Exception {
String interceptorConfig = "FirstInterceptor;SecondInterceptor(parm1=value1,parm2=value2)";
PoolProperties props = new PoolProperties();
props.setJdbcInterceptors(interceptorConfig);
InterceptorDefinition[] interceptorDefs = props.getJdbcInterceptorsAsArray();
assertNotNull(interceptorDefs);
// 3 items because parser automatically inserts TrapException interceptor to front of list
assertEquals(interceptorDefs.length, 3);
assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());
assertNotNull(interceptorDefs[1]);
assertEquals(interceptorDefs[1].getClassName(), "FirstInterceptor");
assertNotNull(interceptorDefs[2]);
assertEquals(interceptorDefs[2].getClassName(), "SecondInterceptor");
Map<String, InterceptorProperty> secondProps = interceptorDefs[2].getProperties();
assertNotNull(secondProps);
assertEquals(secondProps.size(), 2);
assertNotNull(secondProps.get("parm1"));
assertEquals(secondProps.get("parm1").getValue(), "value1");
assertNotNull(secondProps.get("parm2"));
assertEquals(secondProps.get("parm2").getValue(), "value2");
}
use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class SlowQueryReport method setProperties.
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
super.setProperties(properties);
final String threshold = "threshold";
final String maxqueries = "maxQueries";
final String logslow = "logSlow";
final String logfailed = "logFailed";
InterceptorProperty p1 = properties.get(threshold);
InterceptorProperty p2 = properties.get(maxqueries);
InterceptorProperty p3 = properties.get(logslow);
InterceptorProperty p4 = properties.get(logfailed);
if (p1 != null) {
setThreshold(Long.parseLong(p1.getValue()));
}
if (p2 != null) {
setMaxQueries(Integer.parseInt(p2.getValue()));
}
if (p3 != null) {
setLogSlow(Boolean.parseBoolean(p3.getValue()));
}
if (p4 != null) {
setLogFailed(Boolean.parseBoolean(p4.getValue()));
}
}
use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class StatementCache method setProperties.
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
super.setProperties(properties);
InterceptorProperty p = properties.get("prepared");
if (p != null)
cachePrepared = p.getValueAsBoolean(cachePrepared);
p = properties.get("callable");
if (p != null)
cacheCallable = p.getValueAsBoolean(cacheCallable);
p = properties.get("max");
if (p != null)
maxCacheSize = p.getValueAsInt(maxCacheSize);
if (cachePrepared && cacheCallable) {
this.types = ALL_TYPES;
} else if (cachePrepared) {
this.types = PREPARED_TYPE;
} else if (cacheCallable) {
this.types = CALLABLE_TYPE;
} else {
this.types = NO_TYPE;
}
}
Aggregations