Java Code Examples for org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty

The following examples show how to use org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Tomcat8-Source-Read   Source File: StatementCache.java    License: MIT License 6 votes vote down vote up
@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;
    }

}
 
Example 2
Source Project: Tomcat8-Source-Read   Source File: SlowQueryReport.java    License: MIT License 6 votes vote down vote up
@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()));
    }
}
 
Example 3
@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();
    Assert.assertNotNull(interceptorDefs);

    // 3 items because parser automatically inserts TrapException interceptor to front of list
    Assert.assertEquals(interceptorDefs.length, 3);
    Assert.assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());

    Assert.assertNotNull(interceptorDefs[1]);
    Assert.assertEquals(interceptorDefs[1].getClassName(), "FirstInterceptor");
    Assert.assertNotNull(interceptorDefs[2]);
    Assert.assertEquals(interceptorDefs[2].getClassName(), "SecondInterceptor");

    Map<String, InterceptorProperty> secondProps = interceptorDefs[2].getProperties();
    Assert.assertNotNull(secondProps);
    Assert.assertEquals(secondProps.size(), 2);
    Assert.assertNotNull(secondProps.get("parm1"));
    Assert.assertEquals(secondProps.get("parm1").getValue(), "value1");
    Assert.assertNotNull(secondProps.get("parm2"));
    Assert.assertEquals(secondProps.get("parm2").getValue(), "value2");
}
 
Example 4
Source Project: Tomcat7.0.67   Source File: StatementCache.java    License: Apache License 2.0 6 votes vote down vote up
@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;
    }

}
 
Example 5
Source Project: tomcatsrc   Source File: StatementCache.java    License: Apache License 2.0 6 votes vote down vote up
@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;
    }

}
 
Example 6
Source Project: Tomcat8-Source-Read   Source File: SlowQueryReportJmx.java    License: MIT License 5 votes vote down vote up
@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()));
    }
}
 
Example 7
Source Project: Tomcat8-Source-Read   Source File: JdbcInterceptor.java    License: MIT License 5 votes vote down vote up
/**
 * 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()));
    }
}
 
Example 8
Source Project: Tomcat7.0.67   Source File: SlowQueryReportJmx.java    License: Apache License 2.0 5 votes vote down vote up
@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()));
    }
}
 
Example 9
Source Project: Tomcat7.0.67   Source File: SlowQueryReport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    super.setProperties(properties);
    final String threshold = "threshold";
    final String maxqueries= "maxQueries";
    InterceptorProperty p1 = properties.get(threshold);
    InterceptorProperty p2 = properties.get(maxqueries);
    if (p1!=null) {
        setThreshold(Long.parseLong(p1.getValue()));
    }
    if (p2!=null) {
        setMaxQueries(Integer.parseInt(p2.getValue()));
    }
}
 
Example 10
Source Project: Tomcat7.0.67   Source File: JdbcInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
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()));
    }
}
 
Example 11
Source Project: tomcatsrc   Source File: SlowQueryReportJmx.java    License: Apache License 2.0 5 votes vote down vote up
@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()));
    }
}
 
Example 12
Source Project: tomcatsrc   Source File: SlowQueryReport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    super.setProperties(properties);
    final String threshold = "threshold";
    final String maxqueries= "maxQueries";
    InterceptorProperty p1 = properties.get(threshold);
    InterceptorProperty p2 = properties.get(maxqueries);
    if (p1!=null) {
        setThreshold(Long.parseLong(p1.getValue()));
    }
    if (p2!=null) {
        setMaxQueries(Integer.parseInt(p2.getValue()));
    }
}
 
Example 13
Source Project: tomcatsrc   Source File: JdbcInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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
 */
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()));
    }
}
 
Example 14
Source Project: Tomcat8-Source-Read   Source File: QueryTimeoutInterceptor.java    License: MIT License 4 votes vote down vote up
@Override
public void setProperties(Map<String,InterceptorProperty> properties) {
    super.setProperties(properties);
    InterceptorProperty p = properties.get("queryTimeout");
    if (p!=null) timeout = p.getValueAsInt(timeout);
}
 
Example 15
Source Project: Tomcat8-Source-Read   Source File: TestInterceptor.java    License: MIT License 4 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    instancecount.incrementAndGet();
    super.setProperties(properties);
}
 
Example 16
@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();
    Assert.assertNotNull(interceptorDefs);

    // 5 items because parser automatically inserts TrapException interceptor to front of list
    Assert.assertEquals(interceptorDefs.length, 5);
    Assert.assertEquals(interceptorDefs[0].getClassName(), TrapException.class.getName());

    Assert.assertNotNull(interceptorDefs[1]);
    Assert.assertEquals(interceptorDefs[1].getClassName(), "FirstInterceptor");
    Assert.assertNotNull(interceptorDefs[2]);
    Assert.assertEquals(interceptorDefs[2].getClassName(), "SecondInterceptor");
    Assert.assertNotNull(interceptorDefs[3]);
    Assert.assertEquals(interceptorDefs[3].getClassName(), "org.cyb.ThirdInterceptor");

    Map<String, InterceptorProperty> secondProps = interceptorDefs[2].getProperties();
    Assert.assertNotNull(secondProps);
    Assert.assertEquals(secondProps.size(), 2);
    Assert.assertNotNull(secondProps.get("parm1"));
    Assert.assertEquals(secondProps.get("parm1").getValue(), "value1");
    Assert.assertNotNull(secondProps.get("parm2"));
    Assert.assertEquals(secondProps.get("parm2").getValue(), "value2"); // Bug 54395

    Map<String, InterceptorProperty> thirdProps = interceptorDefs[3].getProperties();
    Assert.assertNotNull(thirdProps);
    Assert.assertEquals(thirdProps.size(), 1);
    Assert.assertNotNull(thirdProps.get("parm1"));
    Assert.assertEquals(thirdProps.get("parm1").getValue(), "value1");

    Map<String, InterceptorProperty> emptyParmValProps = interceptorDefs[4].getProperties();
    Assert.assertNotNull(emptyParmValProps);
    Assert.assertEquals(emptyParmValProps.size(), 1);
    Assert.assertNotNull(emptyParmValProps.get("parm1"));
    Assert.assertEquals(emptyParmValProps.get("parm1").getValue(), "");
}
 
Example 17
Source Project: Tomcat7.0.67   Source File: QueryTimeoutInterceptor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setProperties(Map<String,InterceptorProperty> properties) {
    super.setProperties(properties);
    InterceptorProperty p = properties.get("queryTimeout");
    if (p!=null) timeout = p.getValueAsInt(timeout);
}
 
Example 18
Source Project: Tomcat7.0.67   Source File: TestInterceptor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    instancecount.incrementAndGet();
    super.setProperties(properties);
}
 
Example 19
Source Project: tomcatsrc   Source File: QueryTimeoutInterceptor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setProperties(Map<String,InterceptorProperty> properties) {
    super.setProperties(properties);
    InterceptorProperty p = properties.get("queryTimeout");
    if (p!=null) timeout = p.getValueAsInt(timeout);
}
 
Example 20
Source Project: tomcatsrc   Source File: TestInterceptor.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    instancecount.incrementAndGet();
    super.setProperties(properties);
}
 
Example 21
Source Project: Tomcat8-Source-Read   Source File: JdbcInterceptor.java    License: MIT License 2 votes vote down vote up
/**
 * Returns the properties configured for this interceptor
 * @return the configured properties for this interceptor
 */
public Map<String,InterceptorProperty> getProperties() {
    return properties;
}
 
Example 22
Source Project: Tomcat7.0.67   Source File: JdbcInterceptor.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the properties configured for this interceptor
 * @return the configured properties for this interceptor
 */
public Map<String,InterceptorProperty> getProperties() {
    return properties;
}
 
Example 23
Source Project: tomcatsrc   Source File: JdbcInterceptor.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the properties configured for this interceptor
 * @return the configured properties for this interceptor
 */
public Map<String,InterceptorProperty> getProperties() {
    return properties;
}