use of fish.payara.nucleus.microprofile.config.spi.JDBCConfigSourceConfiguration in project Payara by payara.
the class SetJDBCConfigSourceConfiguration method execute.
@Override
public void execute(AdminCommandContext acc) {
final ActionReport actionReport = acc.getActionReport();
final Config targetConfig = targetUtil.getConfig(target);
if (targetConfig == null) {
actionReport.setMessage("No such config named: " + target);
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
JDBCConfigSourceConfiguration jdbcConfigSourceConfiguration = targetConfig.getExtensionByType(JDBCConfigSourceConfiguration.class);
try {
ConfigSupport.apply(configProxy -> {
if (jndiName != null) {
configProxy.setJndiName(jndiName);
}
if (tableName != null) {
configProxy.setTableName(tableName);
}
if (keyColumnName != null) {
configProxy.setKeyColumnName(keyColumnName);
}
if (valueColumnName != null) {
configProxy.setValueColumnName(valueColumnName);
}
actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
return configProxy;
}, jdbcConfigSourceConfiguration);
} catch (TransactionFailure ex) {
actionReport.failure(LOGGER, "Failed to update JDBC Config Source configuration", ex);
}
}
use of fish.payara.nucleus.microprofile.config.spi.JDBCConfigSourceConfiguration in project Payara by payara.
the class GetJDBCConfigSourceConfiguration method execute.
@Override
public void execute(AdminCommandContext acc) {
final ActionReport actionReport = acc.getActionReport();
final Config targetConfig = targetUtil.getConfig(target);
if (targetConfig == null) {
actionReport.setMessage("No such config named: " + target);
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
JDBCConfigSourceConfiguration jdbcConfigSourceConfiguration = targetConfig.getExtensionByType(JDBCConfigSourceConfiguration.class);
ColumnFormatter columnFormatter = new ColumnFormatter(OUTPUT_HEADERS);
Object[] outputValues = { jdbcConfigSourceConfiguration.getJndiName(), jdbcConfigSourceConfiguration.getTableName(), jdbcConfigSourceConfiguration.getKeyColumnName(), jdbcConfigSourceConfiguration.getValueColumnName() };
columnFormatter.addRow(outputValues);
actionReport.appendMessage(columnFormatter.toString());
Map<String, Object> extraPropertiesMap = new HashMap<>();
extraPropertiesMap.put("jndiName", jdbcConfigSourceConfiguration.getJndiName());
extraPropertiesMap.put("tableName", jdbcConfigSourceConfiguration.getTableName());
extraPropertiesMap.put("keyColumnName", jdbcConfigSourceConfiguration.getKeyColumnName());
extraPropertiesMap.put("valueColumnName", jdbcConfigSourceConfiguration.getValueColumnName());
Properties extraProperties = new Properties();
extraProperties.put("jdbcConfigSourceConfiguration", extraPropertiesMap);
actionReport.setExtraProperties(extraProperties);
}
Aggregations