Correction of message key test long run command
This commit is contained in:
parent
edc9c2070f
commit
3ac978bdc1
@ -144,9 +144,6 @@ public class SocketConsoleApplicationShell implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try (ServerSocket actualServerSocket = new ServerSocket(port)) {
|
try (ServerSocket actualServerSocket = new ServerSocket(port)) {
|
||||||
this.serverSocket = actualServerSocket;
|
this.serverSocket = actualServerSocket;
|
||||||
final ConsoleRunnable runnable = new ConsoleRunnable(app,
|
|
||||||
promptingLock);
|
|
||||||
final Thread appTh = new Thread(runnable);
|
|
||||||
running = true;
|
running = true;
|
||||||
try (PipedOutputStream outStream = new PipedOutputStream();
|
try (PipedOutputStream outStream = new PipedOutputStream();
|
||||||
BufferedWriter writer = new BufferedWriter(
|
BufferedWriter writer = new BufferedWriter(
|
||||||
@ -156,13 +153,15 @@ public class SocketConsoleApplicationShell implements Runnable {
|
|||||||
consoleInput);
|
consoleInput);
|
||||||
BufferedReader inBuf = new BufferedReader(isr);) {
|
BufferedReader inBuf = new BufferedReader(isr);) {
|
||||||
consoleManager.setInput(inBuf);
|
consoleManager.setInput(inBuf);
|
||||||
runSokectServer(appTh, writer);
|
runSokectServer(writer);
|
||||||
// Close the application
|
// Close the application
|
||||||
// Pass command to application
|
// Pass command to application
|
||||||
|
if (app.isRunning()) {
|
||||||
writer.write(applicationShutdown + EOL);
|
writer.write(applicationShutdown + EOL);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
LOGGER.log(Level.SEVERE,
|
LOGGER.log(Level.SEVERE,
|
||||||
"Communication error between client and server", e); //$NON-NLS-1$
|
"Communication error between client and server", e); //$NON-NLS-1$
|
||||||
@ -172,20 +171,27 @@ public class SocketConsoleApplicationShell implements Runnable {
|
|||||||
/** @param appTh the application thread
|
/** @param appTh the application thread
|
||||||
* @param writer the writer to the application
|
* @param writer the writer to the application
|
||||||
* @throws IOException if the communication with the client failed */
|
* @throws IOException if the communication with the client failed */
|
||||||
private void runSokectServer(Thread appTh,
|
private void runSokectServer(BufferedWriter writer) throws IOException {
|
||||||
BufferedWriter writer) throws IOException {
|
final ConsoleRunnable runnable = new ConsoleRunnable(app,
|
||||||
|
promptingLock);
|
||||||
|
Thread appThOld = null;
|
||||||
|
Thread appThNext = new Thread(runnable);
|
||||||
while (running) {
|
while (running) {
|
||||||
try (Socket clientSocket = serverSocket.accept();
|
try (Socket clientSocket = serverSocket.accept();
|
||||||
PrintWriter out = new PrintWriter(
|
PrintWriter out = new PrintWriter(
|
||||||
clientSocket.getOutputStream(), true);
|
clientSocket.getOutputStream(), true);
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(
|
InputStreamReader isr = new InputStreamReader(
|
||||||
clientSocket.getInputStream()));) {
|
clientSocket.getInputStream());
|
||||||
|
BufferedReader in = new BufferedReader(isr);) {
|
||||||
// this is not threaded to avoid several clients at the same
|
// this is not threaded to avoid several clients at the same
|
||||||
// time
|
// time
|
||||||
consoleManager.setOutput(out);
|
consoleManager.setOutput(out);
|
||||||
// Initiate application
|
// Initiate application
|
||||||
if (!appTh.isAlive()) {
|
if (appThOld == null || !appThOld.isAlive()) {
|
||||||
appTh.start();
|
appThNext.start();
|
||||||
|
// Prepare next start
|
||||||
|
appThOld = appThNext;
|
||||||
|
appThNext = new Thread(runnable);
|
||||||
} else {
|
} else {
|
||||||
out.println("Reconnected"); //$NON-NLS-1$
|
out.println("Reconnected"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
@ -249,7 +255,7 @@ public class SocketConsoleApplicationShell implements Runnable {
|
|||||||
private void communicateLoop(BufferedReader in,
|
private void communicateLoop(BufferedReader in,
|
||||||
BufferedWriter writer) throws IOException {
|
BufferedWriter writer) throws IOException {
|
||||||
String ln;
|
String ln;
|
||||||
while (running && (ln = in.readLine()) != null) {
|
while (app.isRunning() && (ln = in.readLine()) != null) {
|
||||||
if (ln.equals(close)) {
|
if (ln.equals(close)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,23 @@ public class ConsoleTestApplication extends ConsoleApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
add(new Command("long") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String tip() {
|
||||||
|
return "A long run test command";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String... args) throws CommandRunException {
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
manager.println("Test command ran fine");
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
throw new CommandRunException("manager closed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (final InvalidCommandName e) {
|
} catch (final InvalidCommandName e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,10 @@
|
|||||||
<!-- The fact that you are presently reading this means that you have had -->
|
<!-- The fact that you are presently reading this means that you have had -->
|
||||||
<!-- knowledge of the CeCILL license and that you accept its terms. -->
|
<!-- knowledge of the CeCILL license and that you accept its terms. -->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
|
|
||||||
>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>gclc-swt</artifactId>
|
<artifactId>gclc-swt</artifactId>
|
||||||
<version>1.0.2-SNAPSHOT</version>
|
<version>1.0.3-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<url>http://www.bigeon.fr/emmanuel</url>
|
<url>http://www.bigeon.fr/emmanuel</url>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -83,7 +83,7 @@ public class CommandProvider implements ICommandProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new CommandRunException(
|
throw new CommandRunException(
|
||||||
Messages.getString("CommandProvider.unrecognized0", cmd)); //$NON-NLS-1$
|
Messages.getString("CommandProvider.unrecognized", cmd)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
Loading…
Reference in New Issue
Block a user