Search in sources :

Example 1 with DataSourceInterceptor

use of com.google.gerrit.extensions.persistence.DataSourceInterceptor in project gerrit by GerritCodeReview.

the class DataSourceProvider method intercept.

private DataSource intercept(String interceptor, DataSource ds) {
    if (interceptor == null) {
        return ds;
    }
    try {
        Constructor<?> c = Class.forName(interceptor).getConstructor();
        DataSourceInterceptor datasourceInterceptor = (DataSourceInterceptor) c.newInstance();
        return datasourceInterceptor.intercept("reviewDb", ds);
    } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalArgumentException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
        throw new ProvisionException("Cannot intercept datasource", e);
    }
}
Also used : ProvisionException(com.google.inject.ProvisionException) DataSourceInterceptor(com.google.gerrit.extensions.persistence.DataSourceInterceptor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

DataSourceInterceptor (com.google.gerrit.extensions.persistence.DataSourceInterceptor)1 ProvisionException (com.google.inject.ProvisionException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1