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

The following examples show how to use org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorProperty. 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 File: StatementCache.java    From Tomcat8-Source-Read with 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 File: SlowQueryReport.java    From Tomcat8-Source-Read with 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
Source File: StatementCache.java    From tomcatsrc with 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 #4
Source File: TestJdbcInterceptorConfigParsing.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@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 #5
Source File: StatementCache.java    From Tomcat7.0.67 with 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 File: SlowQueryReport.java    From Tomcat7.0.67 with 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 #7
Source File: JdbcInterceptor.java    From tomcatsrc with 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 #8
Source File: SlowQueryReport.java    From tomcatsrc with 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 #9
Source File: SlowQueryReportJmx.java    From tomcatsrc with 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 #10
Source File: JdbcInterceptor.java    From Tomcat7.0.67 with 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 File: SlowQueryReportJmx.java    From Tomcat8-Source-Read with 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 #12
Source File: SlowQueryReportJmx.java    From Tomcat7.0.67 with 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 #13
Source File: JdbcInterceptor.java    From Tomcat8-Source-Read with 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 #14
Source File: QueryTimeoutInterceptor.java    From Tomcat7.0.67 with 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 #15
Source File: TestJdbcInterceptorConfigParsing.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@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 #16
Source File: TestInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    instancecount.incrementAndGet();
    super.setProperties(properties);
}
 
Example #17
Source File: TestInterceptor.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void setProperties(Map<String, InterceptorProperty> properties) {
    instancecount.incrementAndGet();
    super.setProperties(properties);
}
 
Example #18
Source File: QueryTimeoutInterceptor.java    From tomcatsrc with 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 #19
Source File: QueryTimeoutInterceptor.java    From Tomcat8-Source-Read with 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 #20
Source File: TestInterceptor.java    From tomcatsrc with 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 File: JdbcInterceptor.java    From Tomcat7.0.67 with 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 #22
Source File: JdbcInterceptor.java    From Tomcat8-Source-Read with 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 #23
Source File: JdbcInterceptor.java    From tomcatsrc with 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;
}