blob: 62d51aa92ce711407044827445e4a02caa7f54bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ote.core;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.util.logging.Level;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.ote.core.environment.console.ConsoleCommand;
import org.eclipse.osee.ote.core.environment.console.ConsoleShell;
import org.eclipse.osee.ote.core.environment.console.ICommandManager;
/**
* @author Ken J. Aguilar
*/
public class StandardShell extends ConsoleShell {
private final Thread thread;
private volatile boolean run = true;
public StandardShell(ICommandManager manager) {
super(manager);
thread = new Thread(new Runnable() {
@Override
public void run() {
InputStreamReader stdin = new InputStreamReader(System.in);
BufferedReader consoleIn = new BufferedReader(stdin);
while (run) {
try {
final String line = consoleIn.readLine();
if (line == null) {
OseeLog.log(StandardShell.class, Level.INFO, "INput stream closed, standard shell closing...");
run = false;
break;
}
if (line.equals("")) {
continue;
}
parseAndExecuteCmd(line);
} catch (InterruptedIOException ioe) {
if (run) {
println("Command console interrupted abnormally");
}
} catch (Throwable t) {
printStackTrace(t);
}
}
}
}, "LBA Test Server Console");
{
}
;
}
@Override
public void println(String string) {
System.out.println(string);
}
@Override
public void print(String string) {
System.out.print(string);
}
@Override
public void println() {
System.out.println();
}
public void onCommandComplete(ConsoleCommand cmd) {
System.out.flush();
}
public void start() {
thread.start();
OseeLog.log(StandardShell.class, Level.INFO, "The Standard Command Console has been started");
}
public void shutdown() {
run = false;
thread.interrupt();
}
}
|