@Override public ServiceMethod createServiceMethod(ServiceDescription serviceDescription) { return new GenericExecServiceMethod(this, serviceDescription); }
static String defaultShell() { if (isWindows()) { return "cmd"; } else { return "/bin/bash"; } }
@Override public Map<String, Object> syncExecImpl(final Map<String, Object> parameters) throws Exception{ String shell = defaultShell(); String shellArg = defaultShellArg(); String command = ((VString) parameters.get("command")).getValue(); return syncExecuteCommand(parameters, shell, shellArg, command); }
@Override public Map<String, Object> syncExecImpl(final Map<String, Object> parameters) throws Exception { String expandedCommand = command; for (Map.Entry<String, Object> entry : parameters.entrySet()) { String name = entry.getKey(); Object object = entry.getValue(); String value = null; if (object instanceof VString) { value = ((VString) object).getValue(); } else if (object == null) { value = ""; } else { throw new IllegalArgumentException("Can't map parameter '" + name + "': was " + object); } expandedCommand = expandedCommand.replaceAll("#" + name + "#", value); } return GenericExecServiceMethod.syncExecuteCommand(parameters, shell, shellArg, expandedCommand); } }
static String defaultShellArg() { if (isWindows()) { return "/c"; } else { return "-c"; } }