List of usage examples for org.apache.commons.dbcp2 BasicDataSource getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.everit.osgi.jdbc.commons.dbcp.internal.Util.java
private static final <T> void setPropertyIfNotNull(final BasicDataSource dataSource, final Map<String, Object> properties, String propKey, Class<T> paramType) { Object propValueObject = properties.get(propKey); propValueObject = convertConfigurationValueIfNecessary(paramType, propValueObject); if (propValueObject == null) { return;/*from ww w . j a v a 2 s. com*/ } Class<?> propType = convertToConfigValueType(paramType); if (!propType.isAssignableFrom(propValueObject.getClass())) { throw new RuntimeException("Expected type of property '" + propKey + "' is '" + propType + "' while the component property has the type '" + propValueObject.getClass() + "'"); } String methodName = convertPropNameToMethodName(propKey); try { Method method = dataSource.getClass().getMethod(methodName, paramType); method.invoke(dataSource, propValueObject); } catch (NoSuchMethodException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (SecurityException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (IllegalAccessException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (IllegalArgumentException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (InvocationTargetException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } }
From source file:org.everit.persistence.jdbc.commons.dbcp.ecm.internal.Util.java
private static <T> void setPropertyIfNotNull(final BasicDataSource dataSource, final Map<String, Object> properties, final String propKey, final Class<T> paramType) { Object propValueObject = properties.get(propKey); propValueObject = Util.convertConfigurationValueIfNecessary(paramType, propValueObject); if (propValueObject == null) { return;//from w w w . j av a 2s . c om } Class<?> propType = Util.convertToConfigValueType(paramType); if (!propType.isAssignableFrom(propValueObject.getClass())) { throw new RuntimeException("Expected type of property '" + propKey + "' is '" + propType + "' while the component property has the type '" + propValueObject.getClass() + "'"); } String methodName = Util.convertPropNameToMethodName(propKey); try { Method method = dataSource.getClass().getMethod(methodName, paramType); method.invoke(dataSource, propValueObject); } catch (NoSuchMethodException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (SecurityException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (IllegalAccessException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (IllegalArgumentException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } catch (InvocationTargetException e) { throw new RuntimeException("Error during setting property '" + propKey + "' of datasource", e); } }