Author: andre Date: 2010-03-22 15:35:36 +0100 (Mon, 22 Mar 2010) New Revision: 41559
Modified: mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/AbstractTranscoder.java mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/CommandTranscoder.java Log: support for more parameters on transcoder commoands MMB-1942 Modified: mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/AbstractTranscoder.java =================================================================== --- mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/AbstractTranscoder.java 2010-03-22 14:34:18 UTC (rev 41558) +++ mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/AbstractTranscoder.java 2010-03-22 14:35:36 UTC (rev 41559) @@ -125,7 +125,7 @@ * * The implementation depends on {...@link Settings} annotations to be set on the classes. */ - public final String getKey() { + public String getKey() { StringBuilder buf = new StringBuilder(); { String cn = getClass().getName(); Modified: mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/CommandTranscoder.java =================================================================== --- mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/CommandTranscoder.java 2010-03-22 14:34:18 UTC (rev 41558) +++ mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/CommandTranscoder.java 2010-03-22 14:35:36 UTC (rev 41559) @@ -79,6 +79,28 @@ return new LoggerWriter(log, Level.ERROR); } + /** + * Overrides the generation of a key in {...@link AbstractTranscoder} to add extra transcoding + * parameters that were not set by {...@link Settings} annotations on the transcoders. + */ + public final String getKey() { + StringBuilder key = new StringBuilder( super.getKey() ); + boolean appendedSetting = false; + if (key.indexOf(", ") > 0) { + appendedSetting = true; + } + + for (Map.Entry<String, String> e : moreOptions.entrySet()) { + if (appendedSetting) { + key.append(", "); + } + key.append(e.getKey()).append("=").append(e.getValue()); + appendedSetting = true; + } + + return key.toString(); + } + protected void transcode(final Logger log) throws Exception { OutputStream outStream = new WriterOutputStream(getOutputWriter(log), System.getProperty("file.encoding")); OutputStream errStream = new WriterOutputStream(getErrorWriter(log), System.getProperty("file.encoding")); @@ -91,23 +113,29 @@ p += File.separator; } + List<String> args = new ArrayList<String>( Arrays.asList(getArguments()) ); + List<String> extra = new ArrayList<String>(); + for (Map.Entry<String, String> e : moreOptions.entrySet()) { + extra.add(e.getKey()); + extra.add(e.getValue()); + } + int pos = args.size() - 2; // last argument is outfile + if (pos > -1) { + if (!extra.isEmpty()) args.addAll(pos, extra); + } else { + LOG.error("Not enough arguments, need at least in- and outfile."); + } if (LOG.isServiceEnabled()) { - LOG.service("Calling (" + method + ") " + p + getCommand() + " " + Arrays.asList(getArguments())); + LOG.service("Calling (" + method + ") " + p + getCommand() + " " + args); } - - // TODO Add support for 'moreOptions' - // Here, but also in getKey. - - CommandExecutor.execute(outStream, errStream, method, p + getCommand(), getArguments()); + CommandExecutor.execute(outStream, errStream, method, p + getCommand(), args.toArray(new String[args.size()])); outStream.close(); errStream.close(); } - - + public CommandTranscoder clone() { return (CommandTranscoder) super.clone(); } - } _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs