use of org.springframework.beans.BeanWrapper in project spring-cloud-connectors by spring-cloud.
the class RedisJedisClientConfigurer method configurePool.
private void configurePool(JedisClientConfigurationBuilder clientConfiguration, PooledServiceConnectorConfig config) {
if (config.getPoolConfig() != null) {
JedisPoolConfig poolConfig = new JedisPoolConfig();
BeanWrapper target = new BeanWrapperImpl(poolConfig);
BeanWrapper source = new BeanWrapperImpl(config.getPoolConfig());
Util.setCorrespondingProperties(target, source);
clientConfiguration.usePooling().poolConfig(poolConfig);
}
}
use of org.springframework.beans.BeanWrapper in project spring-cloud-connectors by spring-cloud.
the class HikariCpPooledDataSourceCreator method setBasicDataSourceProperties.
protected void setBasicDataSourceProperties(DataSource basicDataSource, RelationalServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig, String driverClassName, String validationQuery) {
BeanWrapper target = new BeanWrapperImpl(basicDataSource);
target.setPropertyValue("driverClassName", driverClassName);
target.setPropertyValue("jdbcUrl", serviceInfo.getJdbcUrl());
if (validationQuery != null) {
target.setPropertyValue("connectionTestQuery", validationQuery);
}
configurer.configure(basicDataSource, (DataSourceConfig) serviceConnectorConfig);
}
use of org.springframework.beans.BeanWrapper in project spring-cloud-connectors by spring-cloud.
the class DataSourceConfigurer method configureConnection.
private void configureConnection(DataSource dataSource, DataSourceConfig config) {
if (config.getConnectionConfiguration() != null) {
BeanWrapper target = new BeanWrapperImpl(dataSource);
BeanWrapper connectionSource = new BeanWrapperImpl(config.getConnectionConfiguration());
setCorrespondingProperties(target, connectionSource);
}
}
use of org.springframework.beans.BeanWrapper in project midpoint by Evolveum.
the class ConnectorFactoryBuiltinImpl method generateConnectorConfigurationSchema.
private PrismSchema generateConnectorConfigurationSchema(ConnectorStruct struct) {
Class<? extends ConnectorInstance> connectorClass = struct.connectorClass;
PropertyDescriptor connectorConfigurationProp = UcfUtil.findAnnotatedProperty(connectorClass, ManagedConnectorConfiguration.class);
MutablePrismSchema connectorSchema = prismContext.schemaFactory().createPrismSchema(struct.connectorObject.getNamespace());
// Create configuration type - the type used by the "configuration" element
MutablePrismContainerDefinition<?> configurationContainerDef = connectorSchema.createContainerDefinition(ResourceType.F_CONNECTOR_CONFIGURATION.getLocalPart(), SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_TYPE_LOCAL_NAME);
Class<?> configurationClass = connectorConfigurationProp.getPropertyType();
BeanWrapper configurationClassBean = new BeanWrapperImpl(configurationClass);
for (PropertyDescriptor prop : configurationClassBean.getPropertyDescriptors()) {
if (UcfUtil.hasAnnotation(prop, ConfigurationItem.class)) {
ItemDefinition<?> itemDef = createConfigurationItemDefinition(configurationContainerDef, prop);
LOGGER.trace("Configuration item definition for {}: {}", prop.getName(), itemDef);
}
}
return connectorSchema;
}
use of org.springframework.beans.BeanWrapper in project midpoint by Evolveum.
the class AbstractManagedConnectorInstance method applyConfigurationToConfigurationClass.
private void applyConfigurationToConfigurationClass(PrismContainerValue<?> configurationContainer) throws ConfigurationException {
BeanWrapper connectorBean = new BeanWrapperImpl(this);
PropertyDescriptor connectorConfigurationProp = UcfUtil.findAnnotatedProperty(connectorBean, ManagedConnectorConfiguration.class);
if (connectorConfigurationProp == null) {
return;
}
Class<?> configurationClass = connectorConfigurationProp.getPropertyType();
Object configurationObject;
try {
configurationObject = configurationClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new ConfigurationException("Cannot instantiate configuration " + configurationClass);
}
BeanWrapper configurationClassBean = new BeanWrapperImpl(configurationObject);
for (Item<?, ?> configurationItem : configurationContainer.getItems()) {
ItemDefinition<?> configurationItemDefinition = configurationItem.getDefinition();
String itemLocalName = configurationItem.getElementName().getLocalPart();
if (configurationItemDefinition != null && configurationItemDefinition.isMultiValue()) {
Object[] realValuesArray = configurationItem.getRealValuesArray(Object.class);
configurationClassBean.setPropertyValue(itemLocalName, realValuesArray);
} else {
Object realValue = configurationItem.getRealValue();
configurationClassBean.setPropertyValue(itemLocalName, realValue);
}
}
connectorBean.setPropertyValue(connectorConfigurationProp.getName(), configurationObject);
}
Aggregations