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

The following examples show how to use org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition. 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: 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 #2
Source File: DataSourceProxy.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */

@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
    return getPoolProperties().getJdbcInterceptorsAsArray();
}
 
Example #3
Source File: ConnectionPool.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
    return getPoolProperties().getJdbcInterceptorsAsArray();
}
 
Example #4
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 #5
Source File: DataSourceProxy.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */

@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
    return getPoolProperties().getJdbcInterceptorsAsArray();
}
 
Example #6
Source File: ConnectionPool.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
    return getPoolProperties().getJdbcInterceptorsAsArray();
}
 
Example #7
Source File: DataSourceProxy.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */

@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
    return getPoolProperties().getJdbcInterceptorsAsArray();
}
 
Example #8
Source File: ConnectionPool.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
    return getPoolProperties().getJdbcInterceptorsAsArray();
}
 
Example #9
Source File: PoolConfiguration.java    From Tomcat8-Source-Read with MIT License 2 votes vote down vote up
/**
 * Returns the {@link #getJdbcInterceptors()} as an array of objects with properties and the classes.
 * @return an array of interceptors that have been configured
 */
public InterceptorDefinition[] getJdbcInterceptorsAsArray();
 
Example #10
Source File: PoolConfiguration.java    From Tomcat7.0.67 with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the {@link #getJdbcInterceptors()} as an array of objects with properties and the classes.
 * @return an array of interceptors that have been configured
 */
public InterceptorDefinition[] getJdbcInterceptorsAsArray();
 
Example #11
Source File: PoolConfiguration.java    From tomcatsrc with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the {@link #getJdbcInterceptors()} as an array of objects with properties and the classes.
 * @return an array of interceptors that have been configured
 */
public InterceptorDefinition[] getJdbcInterceptorsAsArray();