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 FlatRecordFieldFactory assemble(ConfigurationContext context) { if (fieldName.isEmpty()) { String message = MessageFormatter.getInstance() .getMessage( ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED, context.getElement().getTagName(), "name"); throw new ServingXmlException(message); } if (digitCount <= 0) { String message = MessageFormatter.getInstance() .getMessage( ServingXmlMessages.COMPONENT_ATTRIBUTE_REQUIRED, context.getElement().getTagName(), "digitCount"); throw new ServingXmlException(message); } if (width <= 0) { width = PackedDecimal.calculatePackedSize(digitCount); } FlatFileOptionsFactory flatFileOptionsFactory = assembleFlatFileOptions(context); if (label == null) { if (fieldLabel != null) { SubstitutionExpr subExpr = SubstitutionExpr.parseString(context.getQnameContext(), fieldLabel); ValueEvaluator valueEvaluator = new SubstitutionExprValueEvaluator(subExpr); label = new Label(valueEvaluator); } else { label = new Label(fieldName.getLocalName()); } } FlatRecordFieldFactory fieldTypeFactory = new PackedDecimalFieldFactory( fieldName, label, start, width, digitCount, decimalPlaces, defaultValue, flatFileOptionsFactory); return fieldTypeFactory; }