use of org.talend.designer.esb.runcontainer.ui.console.RuntimeClient in project tesb-studio-se by Talend.
the class RuntimeConsoleUtil method loadConsole.
public static void loadConsole() {
clearConsole();
RuntimeClient client = new RuntimeClient();
PipedInputStream pis = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream();
try {
pos.connect(pis);
} catch (IOException e) {
ExceptionHandler.process(e);
}
client.setInputStream(pis);
Thread consoleThread = new Thread("Runtime Console Input") {
@Override
public void run() {
InputStream is = findConsole().getInputStream();
int count = 0;
byte[] bs = new byte[1024];
try {
while ((count = is.read(bs)) > 0) {
// remore duplicate \r\n for Windows
if (count > 1 && bs[count - 1] == 10 && bs[count - 2] == 13) {
count--;
}
pos.write(Arrays.copyOf(bs, count));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
pos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
};
consoleThread.start();
Thread connectThread = new Thread("Runtime Console Connector") {
@Override
public void run() {
IPreferenceStore store = ESBRunContainerPlugin.getDefault().getPreferenceStore();
String etcLocation = store.getString(RunContainerPreferenceInitializer.P_ESB_RUNTIME_LOCATION);
String host = store.getString(RunContainerPreferenceInitializer.P_ESB_RUNTIME_HOST);
System.setProperty("karaf.etc", etcLocation + "/etc");
String[] karafArgs = new String[] { "-h", host };
try {
client.connect(karafArgs);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
};
connectThread.start();
}
Aggregations