Search in sources :

Example 1 with InterceptorProperty

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

Example 2 with InterceptorProperty

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

Example 3 with InterceptorProperty

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

Example 4 with InterceptorProperty

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

Example 5 with InterceptorProperty

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(), "");
}
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)

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