Search in sources :

Example 11 with ShardingJdbcException

use of io.shardingjdbc.core.exception.ShardingJdbcException in project sharding-jdbc by shardingjdbc.

the class PropertyUtil method v1.

private static Object v1(final Environment environment, final String prefix, final Class<?> targetClass) {
    try {
        Class<?> resolverClass = Class.forName("org.springframework.boot.bind.RelaxedPropertyResolver");
        Constructor<?> resolverConstructor = resolverClass.getDeclaredConstructor(PropertyResolver.class);
        Method getSubPropertiesMethod = resolverClass.getDeclaredMethod("getSubProperties", String.class);
        Object resolverObject = resolverConstructor.newInstance(environment);
        String prefixParam = prefix.endsWith(".") ? prefix : prefix + ".";
        return getSubPropertiesMethod.invoke(resolverObject, prefixParam);
    } catch (final ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
        throw new ShardingJdbcException(ex.getMessage(), ex);
    }
}
Also used : Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) ShardingJdbcException(io.shardingjdbc.core.exception.ShardingJdbcException)

Aggregations

ShardingJdbcException (io.shardingjdbc.core.exception.ShardingJdbcException)11 ActiveSpan (io.opentracing.ActiveSpan)2 Tracer (io.opentracing.Tracer)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 DataSource (javax.sql.DataSource)2 Optional (com.google.common.base.Optional)1 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)1 Subscribe (com.google.common.eventbus.Subscribe)1 Span (io.opentracing.Span)1 NamedDataSource (io.shardingjdbc.core.jdbc.core.datasource.NamedDataSource)1 IndexPlaceholder (io.shardingjdbc.core.rewrite.placeholder.IndexPlaceholder)1 SchemaPlaceholder (io.shardingjdbc.core.rewrite.placeholder.SchemaPlaceholder)1 ShardingPlaceholder (io.shardingjdbc.core.rewrite.placeholder.ShardingPlaceholder)1 TablePlaceholder (io.shardingjdbc.core.rewrite.placeholder.TablePlaceholder)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 ToString (lombok.ToString)1 DatabaseConfig (org.dbunit.database.DatabaseConfig)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1