top.addProperty(name, ""); HashMap<String, Object> insDetails = new HashMap<String, Object>(); insDetails.put("name", name);
top.addProperty(name, ""); HashMap<String, Object> insDetails = new HashMap<String, Object>(); insDetails.put("name", name);
restartable = pwf.canRead(); top.addProperty("restartable", Boolean.toString(restartable));
String message = localStrings.getLocalString("component.status","Status of {0} is {1}.", appName, status); childPart.setMessage(message); childPart.addProperty(DeploymentProperties.STATE, status);
jpdaEnabled = javaEnabledOnCmd || Boolean.parseBoolean(javaConfig.getDebugEnabled()); int debugPort = parsePort(javaConfig.getDebugOptions()); top.addProperty("debug", Boolean.toString(jpdaEnabled)); top.addProperty("debugPort", Integer.toString(debugPort)); final OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); top.addProperty("os.arch", osBean.getArch()); top.addProperty("os.name", osBean.getName()); top.addProperty("os.version", osBean.getVersion()); top.addProperty("availableProcessorsCount", "" + osBean.getAvailableProcessors()); top.addProperty("totalPhysicalMemorySize", "" + jm.invoke(osBean)); top.addProperty("startTimeMillis", "" + rmxb.getStartTime()); top.addProperty("pid", "" + rmxb.getName()); checkDtrace(); setDasName(); top.addProperty("java.vm.name", System.getProperty("java.vm.name")); setRestartable(); reportMessage.append(Strings.get("runtime.info.debug", jpdaEnabled ? "enabled" : "not enabled"));
part.setMessage(hostAndPort.getHost() + ":" + hostAndPort.getPort()); part.addProperty("host", hostAndPort.getHost()); //property for REST Access part.addProperty("port", ""+hostAndPort.getPort()); //property for REST Access
private void addParamUsage( ActionReport report, CommandModel.ParamModel model) { Param param = model.getParam(); if (param != null) { // this is a param. String paramName = model.getName().toLowerCase(Locale.ENGLISH); // skip "hidden" options if (paramName.startsWith("_")) { return; } // do not want to display password in the usage if (param.password()) { return; } // do not want to display obsolete options if (param.obsolete()) { return; } if (param.primary()) { // if primary then it's an operand report.getTopMessagePart().addProperty(paramName + "_operand", model.getLocalizedDescription()); } else { report.getTopMessagePart().addProperty(paramName, model.getLocalizedDescription()); } } }
private void addParamUsage( ActionReport report, CommandModel.ParamModel model) { Param param = model.getParam(); if (param != null) { // this is a param. String paramName = model.getName().toLowerCase(Locale.ENGLISH); // skip "hidden" options if (paramName.startsWith("_")) { return; } // do not want to display password in the usage if (param.password()) { return; } // do not want to display obsolete options if (param.obsolete()) { return; } if (param.primary()) { // if primary then it's an operand report.getTopMessagePart().addProperty(paramName + "_operand", model.getLocalizedDescription()); } else { report.getTopMessagePart().addProperty(paramName, model.getLocalizedDescription()); } } }
public static void fillActionReport(final ActionReport ar, final JSONObject json) throws JSONException { ar.setActionExitCode(ActionReport.ExitCode.valueOf(json.getString("exit_code"))); ar.setActionDescription(json.optString("command")); String failure = json.optString("failure_cause"); if (failure != null && !failure.isEmpty()) { ar.setFailureCause(new Exception(failure)); } ar.setExtraProperties((Properties) extractMap(json.optJSONObject("extraProperties"), new Properties())); ar.getTopMessagePart().setMessage(json.optString("top_message", json.optString("message"))); Properties props = (Properties) extractMap(json.optJSONObject("properties"), new Properties()); for (Map.Entry entry : props.entrySet()) { ar.getTopMessagePart().addProperty(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } //Sub messages fillSubMessages(ar.getTopMessagePart(), json.optJSONArray("children")); //Sub action reports JSONArray subJsons = json.optJSONArray("subReports"); if (subJsons != null) { for (int i = 0; i < subJsons.length(); i++) { JSONObject subJson = subJsons.getJSONObject(i); fillActionReport(ar.addSubActionsReport(), subJson); } } }
/** * Entry point from the framework into the command execution * @param context context for the command. */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); ApplicationInfo appInfo = appRegistry.get(appname); if (appInfo != null) { Application app = appInfo.getMetaData(Application.class); if (app != null) { BundleDescriptor bundleDesc = app.getModuleByUri(modulename); if (bundleDesc != null && bundleDesc instanceof WebBundleDescriptor) { String contextRoot = ((WebBundleDescriptor)bundleDesc).getContextRoot(); part.addProperty(DeploymentProperties.CONTEXT_ROOT, contextRoot); part.setMessage(contextRoot); } } } } }
public void getHelp(AdminCommand command, ActionReport report) { CommandModel model = getModel(command); report.setActionDescription(model.getCommandName() + " help"); // XXX - this is a hack for now. if the request mapped to an // XMLContentActionReporter, that means we want the command metadata. if (report instanceof XMLContentActionReporter) { getMetadata(command, model, report); } else { report.setMessage(model.getCommandName() + " - " + model.getLocalizedDescription()); report.getTopMessagePart().addProperty("SYNOPSIS", encodeManPage(new BufferedReader(new StringReader( getUsageText(model))))); for (CommandModel.ParamModel param : model.getParameters()) { addParamUsage(report, param); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } }
public void getHelp(AdminCommand command, ActionReport report) { CommandModel model = getModel(command); report.setActionDescription(model.getCommandName() + " help"); // XXX - this is a hack for now. if the request mapped to an // XMLContentActionReporter, that means we want the command metadata. if (report instanceof XMLContentActionReporter) { getMetadata(command, model, report); } else { report.setMessage(model.getCommandName() + " - " + model.getLocalizedDescription()); report.getTopMessagePart().addProperty("SYNOPSIS", encodeManPage(new BufferedReader(new StringReader( getUsageText(model))))); for (CommandModel.ParamModel param : model.getParameters()) { addParamUsage(report, param); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } }
private static void fillSubMessages(final ActionReport.MessagePart mp, final JSONArray json) throws JSONException { if (json == null) { return; } for (int i = 0; i < json.length(); i++) { JSONObject subJson = json.getJSONObject(i); MessagePart child = mp.addChild(); child.setMessage(subJson.optString("message")); Properties props = (Properties) extractMap(subJson.optJSONObject("properties"), new Properties()); for (Map.Entry entry : props.entrySet()) { child.addProperty(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); } fillSubMessages(child, subJson.optJSONArray("children")); } }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); long totalTime_ms = getUptime(); String totalTime_mss = "" + totalTime_ms; Duration duration = new Duration(totalTime_ms); duration.setTerse(); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); String message; if (milliseconds) message = totalTime_mss; else message = localStrings.getLocalString("uptime.output.terse", "Uptime: {0}", duration); report.setMessage(message); report.getTopMessagePart().addProperty("milliseconds", totalTime_mss); } final private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(UptimeCommand.class);
private void copyMessagePart(MessagePart source, MessagePart dest) { if (source == null || dest == null) { return; } dest.setMessage(source.getMessage()); dest.setChildrenType(source.getChildrenType()); Properties props = source.getProps(); if (props != null) { for (Map.Entry<Object, Object> entry : props.entrySet()) { dest.addProperty((String) entry.getKey(), (String) entry.getValue()); } } for (MessagePart chmp : source.getChildren()) { copyMessagePart(chmp, dest.addChild()); } }
private void addToResultDDList(String moduleName, Map<String, String> snifferConfigs, ActionReport.MessagePart part) { for (String pathKey : snifferConfigs.keySet()) { ActionReport.MessagePart childPart = part.addChild(); childPart.addProperty(DeploymentProperties.MODULE_NAME, moduleName); childPart.addProperty(DeploymentProperties.DD_PATH, pathKey); childPart.addProperty(DeploymentProperties.DD_CONTENT, snifferConfigs.get(pathKey)); } } }
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); report.setMessage(env.getInstanceRoot().getAbsolutePath().replace('\\', '/')); MessagePart mp = report.getTopMessagePart(); mp.addProperty("Base-Root", StartupContextUtil.getInstallRoot(env.getStartupContext()).getAbsolutePath()); mp.addProperty("Domain-Root", env.getDomainRoot().getAbsolutePath()); mp.addProperty("Instance-Root", env.getInstanceRoot().getAbsolutePath()); mp.addProperty("Config-Dir", env.getConfigDirPath().getAbsolutePath()); mp.addProperty("Uptime", ""+getUptime()); mp.addProperty("Pid", ""+ProcessUtils.getPid()); mp.addProperty("Restart-Required", ""+ucl.serverRequiresRestart()); }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); Sniffer sniffer = snifferManager.getSniffer(sniffername); if (sniffer != null) { String isVisible = String.valueOf(sniffer.isUserVisible()); part.addProperty(DeploymentProperties.IS_SNIFFER_USER_VISIBLE, isVisible); part.setMessage(isVisible); } } }
private void setDasName() { try { String name = env.getInstanceRoot().getName(); top.addProperty("domain_name", name); } catch (Exception ex) { // ignore } }
private void checkDtrace() { try { Class.forName("com.sun.tracing.ProviderFactory"); top.addProperty("dtrace", "true"); } catch (Exception ex) { top.addProperty("dtrace", "false"); } }