use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class ListDomainsCommand method executeCommand.
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
try {
File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
DomainsManager manager = new PEDomainsManager();
String[] domainsList = manager.listDomains(domainConfig);
// no prompting for passwords
programOpts.setInteractive(false);
if (domainsList.length > 0) {
if (longOpt) {
String[] headings = { "DOMAIN", "ADMIN_HOST", "ADMIN_PORT", "RUNNING", "RESTART_REQUIRED" };
ColumnFormatter cf = header ? new ColumnFormatter(headings) : new ColumnFormatter();
for (String dn : domainsList) {
DomainInfo di = getStatus(dn);
cf.addRow(new Object[] { dn, di.adminAddr.getHost(), di.adminAddr.getPort(), di.status, di.restartRequired });
}
logger.info(cf.toString());
} else {
for (String dn : domainsList) {
logger.info(getStatus(dn).statusMsg);
}
}
} else {
logger.fine(STRINGS.get("NoDomainsToList"));
}
} catch (Exception ex) {
throw new CommandException(ex.getLocalizedMessage());
}
return 0;
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class InstanceInfo method format.
// ///////////////////////////////////////////////////////////////////////
// ////// static formatting stuff below ///////////////////////////////
// ///////////////////////////////////////////////////////////////////////
public static String format(List<InstanceInfo> infos) {
String[] headings = { NAME, HOST, PORT, PID, CLUSTER, STATE };
ColumnFormatter cf = new ColumnFormatter(headings);
for (InstanceInfo info : infos) {
cf.addRow(new Object[] { info.getName(), info.getHost(), info.getPort(), formatPid(info), info.getDisplayCluster(), info.getDisplayState() });
}
return cf.toString();
}
use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.
the class BaseGetNotifierConfigurationCommand method listConfiguration.
/**
* @param configuration the configuration to print
* @return A column formatted string representing the configuration
* @see #getNotifierConfiguration(PayaraNotifierConfiguration)
*/
protected String listConfiguration(C configuration) {
Map<String, Object> configMap = getNotifierConfiguration(configuration);
Iterator<Entry<String, Object>> configIterator = configMap.entrySet().iterator();
List<String> headers = new ArrayList<>(2);
List<Object> values = new ArrayList<>(2);
while (configIterator.hasNext()) {
Entry<String, Object> entry = configIterator.next();
headers.add(entry.getKey());
values.add(entry.getValue());
}
ColumnFormatter columnFormatter = new ColumnFormatter(headers.toArray(new String[0]));
columnFormatter.addRow(values.toArray());
return columnFormatter.toString();
}
Aggregations