public StreamSink createStreamSink(ServiceContext context, Flow flow) { List<String> commandList = new ArrayList<String>(); String cmd = command.evaluateString(context, flow); commandList.add(cmd); for (int i = 0; i < commandArgs.length; ++i) { String arg = commandArgs[i].evaluateString(context, flow); commandList.add(arg); } ProcessBuilder processBuilder = new ProcessBuilder(commandList); Map<String, String> environment = processBuilder.environment(); for (int i = 0; i < envVariableFactories.length; ++i) { EnvVariable envVariable = envVariableFactories[i].createEnvVariable(context, flow); environment.put(envVariable.getName(), envVariable.getValue()); } String directory = dirResolver.evaluateAsString(flow.getParameters(), flow.getRecord()); if (directory.length() > 0) { File file = new File(directory); processBuilder.directory(file); } StreamSink streamSink = new CommandSink(processBuilder, charset); return streamSink; }
public void setContentHandler(ContentHandler handler) { // System.out.println(getClass().getName()+".setContentHandler " + // handler.getClass().getName()); SaxSink saxSink = new SimpleSaxSink(handler); flow = flow.replaceDefaultSaxSink(context, saxSink); super.setContentHandler(handler); }
public void execute(ServiceContext context, Flow flow) { try { task.execute(context, flow); } catch (ServingXmlException e) { StreamSink errOutput = flow.getDefaultStreamSink(); catchError.catchError(context, flow, e, errOutput); } }
public void addToAttributes(ServiceContext context, Flow flow, AttributesImpl attributes) { Name name = createName(flow.getRecord()); String qname = name.toQname(nameContext); // System.out.println(getClass().getName()+".addToAttributes"); try { String value = getValue(context, flow); attributes.addAttribute(name.getNamespaceUri(), name.getLocalName(), qname, "CDATA", value); } catch (ServingXmlException e) { if (qname != null) { e = e.contextualizeMessage("@" + qname); } throw e; } }