changeset 26:56444e17df1a

Remove file committed accidentally.
author Mario Torre <neugens.limasoftware@gmail.com>
date Sat, 09 Apr 2011 22:38:20 +0200
parents d9c6a700d4be
children 17afcf8034a6
files main/java/org/icedrobot/ika/runtime/RuntimeCommand.java
diffstat 1 files changed, 0 insertions(+), 144 deletions(-) [+]
line wrap: on
line diff
--- a/main/java/org/icedrobot/ika/runtime/RuntimeCommand.java	Sat Apr 09 22:29:16 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-/*
- * IKA - IcedRobot Kiosk Application
- * Copyright (C) 2011  IcedRobot team
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.icedrobot.ika.runtime;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.icedrobot.ika.output.DefaultWorkerStatus;
-import org.icedrobot.ika.output.StatusKeeper;
-import org.icedrobot.ika.output.WorkerStatus;
-
-
-/**
- * Executable command that will report its status to the StatusKeeper.
- */
-public class RuntimeCommand {
-
-    private final String[] typeSample = new String[0];
-
-
-    private Process proc;
-    protected final String taskName;
-    protected List<String> commandLine;
-
-
-    /**
-     * Initializes a RuntimeCommand
-     * @param name          Command name. No other active commands must exist.
-     * @param commandLine   Command line used to execute the command.
-     */
-    public RuntimeCommand(String name, String... commandLine) {
-        taskName = name;
-        this.commandLine = new LinkedList<String>( Arrays.asList(commandLine) );
-
-        StatusKeeper.getInstance().registerWorker(taskName );
-    }
-
-
-    /**
-     * Processes a line of output provided by the external process.
-     * @param output    Output of the external process
-     * @return          WorkerStatus expressing the same information as output.
-     */
-    protected WorkerStatus process(String output) {
-        return new DefaultWorkerStatus(0f, output);
-    }
-
-    /**
-     * Starts the external process
-     * @param path      Working directory
-     * @return          Newly started process.
-     */
-    protected Process runCommand(File path) {
-        return IkaRuntime.exec( path, commandLine.toArray(typeSample) );
-    }
-
-    /**
-     * Starts the external process
-     * @param path      Working directory
-     */
-    public void execute(File path) {
-        proc = runCommand(path);
-
-        BufferedReader input = new BufferedReader(
-                                    new InputStreamReader(
-                                        proc.getInputStream() ));
-
-        String line;
-        WorkerStatus status;
-
-        try {
-
-            while ((line = input.readLine()) != null) {
-                status = process(line);
-                StatusKeeper.getInstance().reportStatus(taskName, status);
-            }
-
-        } catch (IOException ex) {
-            Logger.getLogger( RuntimeCommand.class.getName() ).log(
-                   Level.SEVERE, taskName + ": error on the input stream", ex );
-        }
-
-        do {
-            try {
-
-                /*
-                 * If the process terminates abnormally, leave its status there
-                 * so that it can be clearly seen.
-                 */
-                if (proc.waitFor() == 0) {
-                    StatusKeeper.getInstance().deregisterWorker(taskName);
-                }
-
-                proc = null;
-
-            } catch (InterruptedException ex) {
-                Logger.getLogger( RuntimeCommand.class.getName() )
-                                    .log( Level.INFO,
-                                        "Thread was interrupted while waiting "
-                                            + "for process termination", ex);
-            }
-
-        } while (proc != null);
-
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder bdr = new StringBuilder(getClass().getSimpleName());
-
-        bdr.append('(');
-
-        for (String s : commandLine) {
-            bdr.append(s);
-            bdr.append(' ');
-        }
-
-        bdr.setCharAt(bdr.length() - 1, ')');
-
-        return bdr.toString();
-    }
-}