/** * Updates the task definition with the datasource properties. * @param taskDefinition the {@link TaskDefinition} to be updated. * @param dataSourceProperties the dataSource properties used by SCDF. * @return the updated {@link TaskDefinition} */ public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, DataSourceProperties dataSourceProperties) { Assert.notNull(taskDefinition, "taskDefinition must not be null"); Assert.notNull(dataSourceProperties, "dataSourceProperties must not be null"); TaskDefinition.TaskDefinitionBuilder builder = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition); builder.setProperty("spring.datasource.url", dataSourceProperties.getUrl()); builder.setProperty("spring.datasource.username", dataSourceProperties.getUsername()); // password may be empty if (StringUtils.hasText(dataSourceProperties.getPassword())) { builder.setProperty("spring.datasource.password", dataSourceProperties.getPassword()); } builder.setProperty("spring.datasource.driverClassName", dataSourceProperties.getDriverClassName()); return builder.build(); }
/** * Updates the task definition with the datasource properties. * @param taskDefinition the {@link TaskDefinition} to be updated. * @param dataSourceProperties the dataSource properties used by SCDF. * @return the updated {@link TaskDefinition} */ public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, DataSourceProperties dataSourceProperties) { Assert.notNull(taskDefinition, "taskDefinition must not be null"); Assert.notNull(dataSourceProperties, "dataSourceProperties must not be null"); TaskDefinition.TaskDefinitionBuilder builder = TaskDefinition.TaskDefinitionBuilder.from(taskDefinition); builder.setProperty("spring.datasource.url", dataSourceProperties.getUrl()); builder.setProperty("spring.datasource.username", dataSourceProperties.getUsername()); // password may be empty if (StringUtils.hasText(dataSourceProperties.getPassword())) { builder.setProperty("spring.datasource.password", dataSourceProperties.getPassword()); } builder.setProperty("spring.datasource.driverClassName", dataSourceProperties.getDriverClassName()); return builder.build(); }