use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class JdbcInterceptor method setProperties.
/**
* Called during the creation of an interceptor
* The properties can be set during the configuration of an interceptor
* Override this method to perform type casts between string values and object properties
* @param properties The properties
*/
public void setProperties(Map<String, InterceptorProperty> properties) {
this.properties = properties;
final String useEquals = "useEquals";
InterceptorProperty p = properties.get(useEquals);
if (p != null) {
setUseEquals(Boolean.parseBoolean(p.getValue()));
}
}
use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class QueryTimeoutInterceptor method setProperties.
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
super.setProperties(properties);
InterceptorProperty p = properties.get("queryTimeout");
if (p != null)
timeout = p.getValueAsInt(timeout);
}
use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class SlowQueryReportJmx method getObjectName.
public ObjectName getObjectName(Class<?> clazz, String poolName) throws MalformedObjectNameException {
ObjectName oname;
Map<String, InterceptorProperty> properties = getProperties();
if (properties != null && properties.containsKey(objectNameAttribute)) {
oname = new ObjectName(properties.get(objectNameAttribute).getValue());
} else {
oname = new ObjectName(ConnectionPool.POOL_JMX_TYPE_PREFIX + clazz.getName() + ",name=" + poolName);
}
return oname;
}
use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class SlowQueryReportJmx method setProperties.
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
super.setProperties(properties);
final String threshold = "notifyPool";
InterceptorProperty p1 = properties.get(threshold);
if (p1 != null) {
this.setNotifyPool(Boolean.parseBoolean(p1.getValue()));
}
}
use of org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty in project tomcat by apache.
the class TestJdbcInterceptorConfigParsing method testWhitespace.
@Test
public void testWhitespace() throws Exception {
String interceptorConfig = "FirstInterceptor ; \n" + "SecondInterceptor (parm1 = value1 , parm2= value2 ) ; \n\n" + "\t org.cyb.ThirdInterceptor(parm1=value1); \n" + "EmptyParmValInterceptor(parm1= )";
PoolProperties props = new PoolProperties();
props.setJdbcInterceptors(interceptorConfig);
InterceptorDefinition[] interceptorDefs = props.getJdbcInterceptorsAsArray();
assertNotNull(interceptorDefs);
// 5 items because parser automatically inserts TrapException interceptor to front of list
assertEquals(interceptorDefs.length, 5);
assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());
assertNotNull(interceptorDefs[1]);
assertEquals(interceptorDefs[1].getClassName(), "FirstInterceptor");
assertNotNull(interceptorDefs[2]);
assertEquals(interceptorDefs[2].getClassName(), "SecondInterceptor");
assertNotNull(interceptorDefs[3]);
assertEquals(interceptorDefs[3].getClassName(), "org.cyb.ThirdInterceptor");
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"));
// Bug 54395
assertEquals(secondProps.get("parm2").getValue(), "value2");
Map<String, InterceptorProperty> thirdProps = interceptorDefs[3].getProperties();
assertNotNull(thirdProps);
assertEquals(thirdProps.size(), 1);
assertNotNull(thirdProps.get("parm1"));
assertEquals(thirdProps.get("parm1").getValue(), "value1");
Map<String, InterceptorProperty> emptyParmValProps = interceptorDefs[4].getProperties();
assertNotNull(emptyParmValProps);
assertEquals(emptyParmValProps.size(), 1);
assertNotNull(emptyParmValProps.get("parm1"));
assertEquals(emptyParmValProps.get("parm1").getValue(), "");
}
Aggregations