Search in sources :

Example 6 with InterceptorProperty

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");
}
Also used : InterceptorDefinition(org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition) InterceptorProperty(org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty) TrapException(org.apache.tomcat.jdbc.pool.TrapException) PoolProperties(org.apache.tomcat.jdbc.pool.PoolProperties) Test(org.junit.Test)

Example 7 with InterceptorProperty

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()));
    }
}
Also used : InterceptorProperty(org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty)

Example 8 with InterceptorProperty

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;
    }
}
Also used : InterceptorProperty(org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty)

Aggregations

InterceptorProperty (org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty)8 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)2 InterceptorDefinition (org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition)2 TrapException (org.apache.tomcat.jdbc.pool.TrapException)2 Test (org.junit.Test)2 ObjectName (javax.management.ObjectName)1