Compare commits
35 Commits
gclc-2.1.0
...
gclc-2.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| ce4254941a | |||
| f459f78a75 | |||
| 8cd0b01490 | |||
| 698b3d0e5e | |||
| 9ad4a1e456 | |||
| e560fcb92d | |||
| 56f3d604a1 | |||
| 73317186df | |||
| 80bd7c0ac9 | |||
| dc71070dab | |||
| 78b5926af1 | |||
| a3d2c2c07e | |||
| 9df812273c | |||
| e953c2e659 | |||
| 0f4fd6109d | |||
| 69a8fd2533 | |||
| 0b772ddeb3 | |||
| 55f13ae004 | |||
| 295075ca37 | |||
| 75bbba9884 | |||
| 82daa84bdf | |||
| 10a0858d81 | |||
| dfd3645497 | |||
| bd2da741f2 | |||
| 314db5b82f | |||
| 981668d3a7 | |||
| 9c8866827d | |||
| 43c9faaee7 | |||
| 8436e8926c | |||
| 0cef23e17b | |||
| 6b2a25674d | |||
| eec660e089 | |||
| 901469792d | |||
| 79ee5394d4 | |||
| acf4484eb3 |
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<groupId>net.bigeon.gclc</groupId>
|
<groupId>net.bigeon.gclc</groupId>
|
||||||
<artifactId>process</artifactId>
|
<artifactId>process</artifactId>
|
||||||
<version>0.0.6-SNAPSHOT</version>
|
<version>0.0.7-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>process</name>
|
<name>process</name>
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon</groupId>
|
<groupId>net.bigeon</groupId>
|
||||||
<artifactId>gclc</artifactId>
|
<artifactId>gclc</artifactId>
|
||||||
<version>2.0.12</version>
|
<version>2.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon.test</groupId>
|
<groupId>net.bigeon.test</groupId>
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ package net.bigeon.gclc.process.io;
|
|||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import net.bigeon.gclc.manager.ConsoleInput;
|
import net.bigeon.gclc.manager.ConsoleInput;
|
||||||
@@ -102,6 +103,8 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
|||||||
* To read or modify it, you should be in a connectionLock synchronize block. */
|
* To read or modify it, you should be in a connectionLock synchronize block. */
|
||||||
private boolean disconnection = false;
|
private boolean disconnection = false;
|
||||||
|
|
||||||
|
private boolean interrupting = false;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see fr.bigeon.gclc.manager.ConsoleInput#close() */
|
* @see fr.bigeon.gclc.manager.ConsoleInput#close() */
|
||||||
@Override
|
@Override
|
||||||
@@ -149,6 +152,9 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
|||||||
public void interruptPrompt() {
|
public void interruptPrompt() {
|
||||||
synchronized (connectionLock) {
|
synchronized (connectionLock) {
|
||||||
synchronized (promptLock) {
|
synchronized (promptLock) {
|
||||||
|
if (prompting) {
|
||||||
|
interrupting = true;
|
||||||
|
}
|
||||||
connectionLock.notifyAll();
|
connectionLock.notifyAll();
|
||||||
if (connected != null) {
|
if (connected != null) {
|
||||||
connected.interruptPrompt();
|
connected.interruptPrompt();
|
||||||
@@ -187,32 +193,7 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
|||||||
synchronized (promptLock) {
|
synchronized (promptLock) {
|
||||||
prompting = true;
|
prompting = true;
|
||||||
}
|
}
|
||||||
while (true) {
|
return doPrompt(message, 0, 0);
|
||||||
synchronized (promptLock) {
|
|
||||||
if (!prompting) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getConnection(0);
|
|
||||||
boolean connect;
|
|
||||||
ConsoleInput actualConnected;
|
|
||||||
synchronized (connectionLock) {
|
|
||||||
connect = connected != null;
|
|
||||||
actualConnected = connected;
|
|
||||||
}
|
|
||||||
if (connect) {
|
|
||||||
final String res = actualConnected.prompt(message);
|
|
||||||
synchronized (promptLock) {
|
|
||||||
if (disconnection) {
|
|
||||||
disconnection = false;
|
|
||||||
} else if (prompting) {
|
|
||||||
return res;
|
|
||||||
} else {
|
|
||||||
// prompt interrupted, lose the result.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -222,42 +203,89 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
|||||||
if (timeout <= 0) {
|
if (timeout <= 0) {
|
||||||
return prompt(message);
|
return prompt(message);
|
||||||
}
|
}
|
||||||
final long end = System.currentTimeMillis() + timeout;
|
|
||||||
synchronized (promptLock) {
|
synchronized (promptLock) {
|
||||||
prompting = true;
|
prompting = true;
|
||||||
}
|
}
|
||||||
|
final long tic = System.currentTimeMillis();
|
||||||
|
return doPrompt(message, timeout, tic);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String doPrompt(final String message, final long timeout, final long tic)
|
||||||
|
throws IOException {
|
||||||
do {
|
do {
|
||||||
synchronized (promptLock) {
|
if (!checkPrompt()) {
|
||||||
if (!prompting) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
getConnection(getTimeoutLeft(tic, timeout));
|
||||||
getConnection(timeout);
|
|
||||||
boolean connect;
|
boolean connect;
|
||||||
ConsoleInput actualConnected;
|
ConsoleInput actualConnected;
|
||||||
synchronized (connectionLock) {
|
synchronized (connectionLock) {
|
||||||
connect = connected != null;
|
connect = connected != null;
|
||||||
actualConnected = connected;
|
actualConnected = connected;
|
||||||
}
|
}
|
||||||
if (connect) {
|
if (!connect) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final String res = actualPrompt(message, timeout, tic, actualConnected);
|
||||||
synchronized (promptLock) {
|
synchronized (promptLock) {
|
||||||
final String res = actualConnected.prompt(message,
|
if (prompting) {
|
||||||
end - System.currentTimeMillis());
|
prompting = false;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (final InterruptedIOException e) {
|
||||||
|
// The inner console was interrupted. This can mean we are
|
||||||
|
// disconnecting or actually interrupted.
|
||||||
if (disconnection) {
|
if (disconnection) {
|
||||||
disconnection = false;
|
disconnection = false;
|
||||||
} else if (prompting) {
|
|
||||||
return res;
|
|
||||||
} else {
|
} else {
|
||||||
// prompt interrupted, lose the result.
|
interrupting = false;
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (checkTimeout(tic, timeout));
|
||||||
} while (System.currentTimeMillis() < end);
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getConnection(final long timeout) {
|
private static String actualPrompt(final String message, final long timeout,
|
||||||
|
final long tic, final ConsoleInput actualConnected) throws IOException {
|
||||||
|
final long timeoutLeft = getTimeoutLeft(tic, timeout);
|
||||||
|
if (timeoutLeft == 0) {
|
||||||
|
return actualConnected.prompt(message);
|
||||||
|
}
|
||||||
|
return actualConnected.prompt(message, timeoutLeft);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkTimeout(final long tic, final long timeout) {
|
||||||
|
return timeout <= 0 || tic + timeout > System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long getTimeoutLeft(final long tic, final long timeout) {
|
||||||
|
if (timeout > 0) {
|
||||||
|
return Math.max(timeout + tic - System.currentTimeMillis(), 1);
|
||||||
|
}
|
||||||
|
if (timeout < 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test if we are in prompting state.
|
||||||
|
*
|
||||||
|
* @return if the process is currently in prompting state.
|
||||||
|
* @throws InterruptedIOException if the prompting state has been interrupted */
|
||||||
|
private boolean checkPrompt() throws InterruptedIOException {
|
||||||
|
synchronized (promptLock) {
|
||||||
|
if (!prompting && interrupting) {
|
||||||
|
interrupting = false;
|
||||||
|
throw new InterruptedIOException("Prompt was interrupted");
|
||||||
|
}
|
||||||
|
return prompting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getConnection(final long timeout) throws InterruptedIOException {
|
||||||
boolean connect;
|
boolean connect;
|
||||||
synchronized (connectionLock) {
|
synchronized (connectionLock) {
|
||||||
connect = connected != null;
|
connect = connected != null;
|
||||||
@@ -268,6 +296,10 @@ public final class ConnectingConsoleInput implements ConsoleInput {
|
|||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (interrupting) {
|
||||||
|
interrupting = false;
|
||||||
|
throw new InterruptedIOException("Prompt ws interrupted");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,18 @@ package net.bigeon.gclc.process;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.bigeon.gclc.exception.CommandRunException;
|
import net.bigeon.gclc.exception.CommandRunException;
|
||||||
import net.bigeon.gclc.exception.CommandRunExceptionType;
|
import net.bigeon.gclc.exception.CommandRunExceptionType;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class ForkTaskTest {
|
public class ForkTaskTest {
|
||||||
@@ -36,15 +39,11 @@ public class ForkTaskTest {
|
|||||||
throw new CommandRunException(CommandRunExceptionType.INTERACTION,
|
throw new CommandRunException(CommandRunExceptionType.INTERACTION,
|
||||||
"Unable to prompt user");
|
"Unable to prompt user");
|
||||||
}
|
}
|
||||||
if ("ok".equals(msg)) {
|
out.println(msg);
|
||||||
out.println("Message");
|
|
||||||
} else {
|
|
||||||
out.println("fail");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final Thread execThread = new Thread(task);
|
final Thread execThread = new Thread(task, "Task");
|
||||||
execThread.start();
|
execThread.start();
|
||||||
try {
|
try {
|
||||||
execThread.join(100);
|
execThread.join(100);
|
||||||
@@ -55,14 +54,103 @@ public class ForkTaskTest {
|
|||||||
|
|
||||||
try (PipedConsoleOutput pco = new PipedConsoleOutput();
|
try (PipedConsoleOutput pco = new PipedConsoleOutput();
|
||||||
PipedConsoleInput pci = new PipedConsoleInput(null)) {
|
PipedConsoleInput pci = new PipedConsoleInput(null)) {
|
||||||
pci.type("ok");
|
|
||||||
while (!pco.available()) {
|
while (!pco.available()) {
|
||||||
|
pci.type("ok");
|
||||||
task.join(pco, pci, 1000);
|
task.join(pco, pci, 1000);
|
||||||
}
|
}
|
||||||
assertEquals("Execution should work", "Message", pco.readNextLine());
|
assertEquals("Positive execution", "ok", pco.readNextLine());
|
||||||
}
|
}
|
||||||
assertFalse("Running state should be updated by task on its completion",
|
assertFalse("Running state should be updated by task on its completion",
|
||||||
task.isRunning());
|
task.isRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTaskInterruption() throws IOException, InterruptedException {
|
||||||
|
final ForkTask task = new ForkTask(5) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "name";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doRun() throws CommandRunException {
|
||||||
|
while (isRunning()) {
|
||||||
|
String msg;
|
||||||
|
try {
|
||||||
|
msg = in.prompt(1000);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new CommandRunException(CommandRunExceptionType.INTERACTION,
|
||||||
|
"Unable to prompt user");
|
||||||
|
}
|
||||||
|
if (msg != null) {
|
||||||
|
out.println(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Thread execThread = new Thread(task, "Task");
|
||||||
|
execThread.start();
|
||||||
|
execThread.join(100);
|
||||||
|
|
||||||
|
final AtomicBoolean interrupted = new AtomicBoolean(false);
|
||||||
|
final AtomicBoolean interrupted2 = new AtomicBoolean(false);
|
||||||
|
final InterruptionListener listener = new InterruptionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void interrupted() {
|
||||||
|
interrupted.set(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final InterruptionListener listener2 = new InterruptionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void interrupted() {
|
||||||
|
interrupted2.set(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
task.addInterruptionListener(listener);
|
||||||
|
task.addInterruptionListener(listener2);
|
||||||
|
task.rmInterruptionListener(listener2);
|
||||||
|
|
||||||
|
assertFalse("Interruption should not be notified before actual interruption",
|
||||||
|
interrupted.get());
|
||||||
|
assertTrue("Task should be started", task.isStarted());
|
||||||
|
task.setRunning(false);
|
||||||
|
try (PipedConsoleOutput pco = new PipedConsoleOutput();
|
||||||
|
PipedConsoleInput pci = new PipedConsoleInput(null)) {
|
||||||
|
task.join(pco, pci, 2000);
|
||||||
|
}
|
||||||
|
execThread.join();
|
||||||
|
assertTrue("Interruption should be notified to listeners", interrupted.get());
|
||||||
|
|
||||||
|
assertFalse("Running state should be updated by task on its completion",
|
||||||
|
task.isRunning());
|
||||||
|
assertFalse("Interruption should not be notified to removed listeners",
|
||||||
|
interrupted2.get());
|
||||||
|
|
||||||
|
task.rmInterruptionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFailingTask() throws InterruptedException {
|
||||||
|
final ForkTask task = new ForkTask(5) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "name";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doRun() throws CommandRunException {
|
||||||
|
throw new CommandRunException("Error");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Thread execThread = new Thread(task, "Task");
|
||||||
|
execThread.start();
|
||||||
|
execThread.join();
|
||||||
|
assertNotNull("Exception should be forwarded", task.getException());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import net.bigeon.gclc.exception.CommandRunException;
|
import net.bigeon.gclc.exception.CommandRunException;
|
||||||
import net.bigeon.gclc.exception.CommandRunExceptionType;
|
import net.bigeon.gclc.exception.CommandRunExceptionType;
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
import net.bigeon.gclc.process.mocks.TaskMock;
|
import net.bigeon.gclc.process.mocks.TaskMock;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class ProcessListTest {
|
public class ProcessListTest {
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
import java.io.PipedInputStream;
|
import java.io.PipedInputStream;
|
||||||
import java.io.PipedOutputStream;
|
import java.io.PipedOutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -13,9 +15,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
|
import net.bigeon.gclc.manager.StreamConsoleInput;
|
||||||
import net.bigeon.gclc.tools.ConstantString;
|
import net.bigeon.gclc.tools.ConstantString;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleInput;
|
|
||||||
import net.bigeon.gclc.utils.StreamConsoleInput;
|
|
||||||
import net.bigeon.test.junitmt.ATestRunnable;
|
import net.bigeon.test.junitmt.ATestRunnable;
|
||||||
import net.bigeon.test.junitmt.FunctionalTestRunnable;
|
import net.bigeon.test.junitmt.FunctionalTestRunnable;
|
||||||
import net.bigeon.test.junitmt.TestFunction;
|
import net.bigeon.test.junitmt.TestFunction;
|
||||||
@@ -81,10 +83,28 @@ public class ConnectingConsoleInputTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply() throws Exception {
|
public void apply() throws Exception {
|
||||||
assertNull("Interrupted should return null", in.prompt("m1", -1));
|
try {
|
||||||
assertNull("Interrupted should return null", in.prompt("m2", 5000));
|
final String res = in.prompt("m1", -1);
|
||||||
|
fail("interruption of infinite waiting prompt should cause error, but was "
|
||||||
|
+ res);
|
||||||
|
} catch (final InterruptedIOException e) {
|
||||||
|
// ok
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final String res = in.prompt("m2", 25000);
|
||||||
|
fail("interruption of finite waiting prompt should cause error, but was "
|
||||||
|
+ res);
|
||||||
|
} catch (final InterruptedIOException e) {
|
||||||
|
// ok
|
||||||
|
}
|
||||||
|
synchronized (ended) {
|
||||||
ended.set(true);
|
ended.set(true);
|
||||||
|
try {
|
||||||
assertNull("Overtime should return null", in.prompt("m3", 200));
|
assertNull("Overtime should return null", in.prompt("m3", 200));
|
||||||
|
} catch (final InterruptedIOException e) {
|
||||||
|
fail("Unexpected interruption error in overtime");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final ATestRunnable runnable = new FunctionalTestRunnable(one);
|
final ATestRunnable runnable = new FunctionalTestRunnable(one);
|
||||||
@@ -95,14 +115,18 @@ public class ConnectingConsoleInputTest {
|
|||||||
public void run() {
|
public void run() {
|
||||||
while (!ended.get()) {
|
while (!ended.get()) {
|
||||||
try {
|
try {
|
||||||
th.join(500);
|
th.join(100);
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
synchronized (ended) {
|
||||||
|
if (!ended.get()) {
|
||||||
in.interruptPrompt();
|
in.interruptPrompt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
th.start();
|
th.start();
|
||||||
inter.start();
|
inter.start();
|
||||||
@@ -112,7 +136,7 @@ public class ConnectingConsoleInputTest {
|
|||||||
|
|
||||||
final PipedOutputStream os = new PipedOutputStream();
|
final PipedOutputStream os = new PipedOutputStream();
|
||||||
final PipedInputStream pis = new PipedInputStream(os);
|
final PipedInputStream pis = new PipedInputStream(os);
|
||||||
in.connect(new StreamConsoleInput(System.out, pis, StandardCharsets.UTF_8));
|
in.connect(new StreamConsoleInput(null, pis, StandardCharsets.UTF_8));
|
||||||
final ATestRunnable runnable2 = new FunctionalTestRunnable(one);
|
final ATestRunnable runnable2 = new FunctionalTestRunnable(one);
|
||||||
final Thread th2 = new Thread(runnable2);
|
final Thread th2 = new Thread(runnable2);
|
||||||
final Thread inter2 = new Thread(new Runnable() {
|
final Thread inter2 = new Thread(new Runnable() {
|
||||||
@@ -121,14 +145,18 @@ public class ConnectingConsoleInputTest {
|
|||||||
public void run() {
|
public void run() {
|
||||||
while (!ended.get()) {
|
while (!ended.get()) {
|
||||||
try {
|
try {
|
||||||
th2.join(500);
|
th2.join(100);
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
synchronized (ended) {
|
||||||
|
if (!ended.get()) {
|
||||||
in.interruptPrompt();
|
in.interruptPrompt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
th2.start();
|
th2.start();
|
||||||
inter2.start();
|
inter2.start();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
public class ConnectingConsoleOutputTest {
|
public class ConnectingConsoleOutputTest {
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.bigeon.config</groupId>
|
<groupId>net.bigeon.config</groupId>
|
||||||
<artifactId>ebigeon-config</artifactId>
|
<artifactId>ebigeon-public-conf</artifactId>
|
||||||
<version>1.8.21</version>
|
<version>1.0.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>net.bigeon.gclc</groupId>
|
<groupId>net.bigeon.gclc</groupId>
|
||||||
<artifactId>socket</artifactId>
|
<artifactId>socket</artifactId>
|
||||||
<version>1.1.14-SNAPSHOT</version>
|
<version>1.1.19-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>GCLC Socket</name>
|
<name>GCLC Socket</name>
|
||||||
<description>Socket implementation of GCLC</description>
|
<description>Socket implementation of GCLC</description>
|
||||||
@@ -46,17 +46,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon</groupId>
|
<groupId>net.bigeon</groupId>
|
||||||
<artifactId>gclc</artifactId>
|
<artifactId>gclc</artifactId>
|
||||||
<version>2.0.12</version>
|
<version>2.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon</groupId>
|
<groupId>net.bigeon</groupId>
|
||||||
<artifactId>smu</artifactId>
|
<artifactId>smu</artifactId>
|
||||||
<version>1.0.6</version>
|
<version>1.0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon.test</groupId>
|
<groupId>net.bigeon.test</groupId>
|
||||||
<artifactId>junitmt</artifactId>
|
<artifactId>junitmt</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.bigeon.gclc.socket;
|
||||||
|
|
||||||
|
/** Interface for listener of brutal disconnection from a pluggable
|
||||||
|
* input/output.
|
||||||
|
*
|
||||||
|
* @author Emmanuel Bigeon */
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface DisconnexionListener {
|
||||||
|
/** Indicate a brutal disconnection */
|
||||||
|
void disconnected();
|
||||||
|
}
|
||||||
@@ -41,8 +41,11 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -87,6 +90,8 @@ public final class PluggableConsoleInput implements ConsoleInput {
|
|||||||
/** The output for hints. */
|
/** The output for hints. */
|
||||||
private PrintStream output;
|
private PrintStream output;
|
||||||
|
|
||||||
|
private final Set<DisconnexionListener> listeners = new HashSet<>();
|
||||||
|
|
||||||
// Locks
|
// Locks
|
||||||
/** The lock for connexion and disconnexion of actual streams. */
|
/** The lock for connexion and disconnexion of actual streams. */
|
||||||
private final Object connexionLock = new Object();
|
private final Object connexionLock = new Object();
|
||||||
@@ -119,6 +124,7 @@ public final class PluggableConsoleInput implements ConsoleInput {
|
|||||||
if (prompting) {
|
if (prompting) {
|
||||||
// print the hint, to indicate we are waiting for a user input.
|
// print the hint, to indicate we are waiting for a user input.
|
||||||
out.print(hint);
|
out.print(hint);
|
||||||
|
out.println();
|
||||||
out.flush();
|
out.flush();
|
||||||
}
|
}
|
||||||
final InputStreamReader streamReader = new InputStreamReader(stream,
|
final InputStreamReader streamReader = new InputStreamReader(stream,
|
||||||
@@ -279,10 +285,48 @@ public final class PluggableConsoleInput implements ConsoleInput {
|
|||||||
final long connexionTimeout) throws IOException, InterruptedException {
|
final long connexionTimeout) throws IOException, InterruptedException {
|
||||||
synchronized (connexionLock) {
|
synchronized (connexionLock) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
|
try {
|
||||||
return connexion.getNextMessage(messageTimeout);
|
return connexion.getNextMessage(messageTimeout);
|
||||||
|
} catch (final InterruptedIOException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (final IOException e) {
|
||||||
|
LOGGER.log(Level.INFO, "Communication was abrubptly interrupted", e);
|
||||||
|
brutalDisconnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
connexionLock.wait(connexionTimeout);
|
connexionLock.wait(connexionTimeout);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void brutalDisconnection() {
|
||||||
|
// clean up the disconnection
|
||||||
|
disconnect();
|
||||||
|
// notify listeners
|
||||||
|
for (final DisconnexionListener listener : listeners) {
|
||||||
|
listener.disconnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add a listener to the list of listeners.
|
||||||
|
*
|
||||||
|
* @param e the listener
|
||||||
|
* @return if the listener was added
|
||||||
|
* @see java.util.Set#add(java.lang.Object) */
|
||||||
|
public boolean add(final DisconnexionListener e) {
|
||||||
|
return listeners.add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove a listener from the list of listeners.
|
||||||
|
*
|
||||||
|
* @param o the listener
|
||||||
|
* @return if the listener was removed
|
||||||
|
* @see java.util.Set#remove(java.lang.Object) */
|
||||||
|
public boolean remove(final DisconnexionListener o) {
|
||||||
|
return listeners.remove(o);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,10 @@ import net.bigeon.gclc.manager.ConsoleOutput;
|
|||||||
/** A {@link Command} to disconnect elements from a {@link ConnexionManager}.
|
/** A {@link Command} to disconnect elements from a {@link ConnexionManager}.
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bigeon
|
* @author Emmanuel Bigeon
|
||||||
* @param <T> the type of connected object */
|
* @param <T> the type of connected object
|
||||||
|
* @deprecated since 1.1.17, this has been moved to
|
||||||
|
* {@link RemoteDisconnectCommand}. */
|
||||||
|
@Deprecated
|
||||||
public final class RemoteDisconnectCommand<T> extends Command {
|
public final class RemoteDisconnectCommand<T> extends Command {
|
||||||
|
|
||||||
/** The connexion manager. */
|
/** The connexion manager. */
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/**
|
||||||
|
* gclc-socket:net.bigeon.gclc.socket.RemoteDisconnectCommand.java
|
||||||
|
* Created on: Nov 18, 2017
|
||||||
|
*/
|
||||||
|
package net.bigeon.gclc.socket.cmd;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* GCLC Socket
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2016 - 2018 Bigeon
|
||||||
|
* %%
|
||||||
|
* This software is governed by the CeCILL license under French law and
|
||||||
|
* abiding by the rules of distribution of free software. You can use,
|
||||||
|
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
* "http://www.cecill.info".
|
||||||
|
*
|
||||||
|
* As a counterpart to the access to the source code and rights to copy,
|
||||||
|
* modify and redistribute granted by the license, users are provided only
|
||||||
|
* with a limited warranty and the software's author, the holder of the
|
||||||
|
* economic rights, and the successive licensors have only limited
|
||||||
|
* liability.
|
||||||
|
*
|
||||||
|
* In this respect, the user's attention is drawn to the risks associated
|
||||||
|
* with loading, using, modifying and/or developing or reproducing the
|
||||||
|
* software by the user in light of its specific status of free software,
|
||||||
|
* that may mean that it is complicated to manipulate, and that also
|
||||||
|
* therefore means that it is reserved for developers and experienced
|
||||||
|
* professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
* encouraged to load and test the software's suitability as regards their
|
||||||
|
* requirements in conditions enabling the security of their systems and/or
|
||||||
|
* data to be ensured and, more generally, to use and operate it in the
|
||||||
|
* same conditions as regards security.
|
||||||
|
*
|
||||||
|
* The fact that you are presently reading this means that you have had
|
||||||
|
* knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.command.Command;
|
||||||
|
import net.bigeon.gclc.exception.CommandRunException;
|
||||||
|
import net.bigeon.gclc.exception.CommandRunExceptionType;
|
||||||
|
import net.bigeon.gclc.manager.ConsoleInput;
|
||||||
|
import net.bigeon.gclc.manager.ConsoleOutput;
|
||||||
|
import net.bigeon.gclc.socket.ConnexionManager;
|
||||||
|
|
||||||
|
/** A {@link Command} to disconnect elements from a {@link ConnexionManager}.
|
||||||
|
*
|
||||||
|
* @author Emmanuel Bigeon
|
||||||
|
* @param <T> the type of connected object */
|
||||||
|
public final class ConnexionListCommand<T> extends Command {
|
||||||
|
|
||||||
|
/** The connexion manager. */
|
||||||
|
private final ConnexionManager<T> manager;
|
||||||
|
|
||||||
|
/** Create the connexion listing command.
|
||||||
|
*
|
||||||
|
* @param name the command name
|
||||||
|
* @param manager the manager */
|
||||||
|
public ConnexionListCommand(final String name, final ConnexionManager<T> manager) {
|
||||||
|
super(name);
|
||||||
|
this.manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.ICommand#execute(fr.bigeon.gclc.manager.
|
||||||
|
* ConsoleOutput, fr.bigeon.gclc.manager.ConsoleInput, java.lang.String[]) */
|
||||||
|
@Override
|
||||||
|
public void execute(final ConsoleOutput out, final ConsoleInput in,
|
||||||
|
final String... args) throws CommandRunException {
|
||||||
|
final Collection<String> coll = manager.getConnected();
|
||||||
|
try {
|
||||||
|
for (final String string : coll) {
|
||||||
|
out.println(string);
|
||||||
|
}
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new CommandRunException(CommandRunExceptionType.INTERACTION,
|
||||||
|
"User cannot be notified", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.ICommand#tip() */
|
||||||
|
@Override
|
||||||
|
public String tip() {
|
||||||
|
return "List current connexions."; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.Command#usageDetail() */
|
||||||
|
@Override
|
||||||
|
protected String usageDetail() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
/**
|
||||||
|
* gclc-socket:net.bigeon.gclc.socket.RemoteDisconnectCommand.java
|
||||||
|
* Created on: Nov 18, 2017
|
||||||
|
*/
|
||||||
|
package net.bigeon.gclc.socket.cmd;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* GCLC Socket
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2016 - 2018 Bigeon
|
||||||
|
* %%
|
||||||
|
* This software is governed by the CeCILL license under French law and
|
||||||
|
* abiding by the rules of distribution of free software. You can use,
|
||||||
|
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
* "http://www.cecill.info".
|
||||||
|
*
|
||||||
|
* As a counterpart to the access to the source code and rights to copy,
|
||||||
|
* modify and redistribute granted by the license, users are provided only
|
||||||
|
* with a limited warranty and the software's author, the holder of the
|
||||||
|
* economic rights, and the successive licensors have only limited
|
||||||
|
* liability.
|
||||||
|
*
|
||||||
|
* In this respect, the user's attention is drawn to the risks associated
|
||||||
|
* with loading, using, modifying and/or developing or reproducing the
|
||||||
|
* software by the user in light of its specific status of free software,
|
||||||
|
* that may mean that it is complicated to manipulate, and that also
|
||||||
|
* therefore means that it is reserved for developers and experienced
|
||||||
|
* professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
* encouraged to load and test the software's suitability as regards their
|
||||||
|
* requirements in conditions enabling the security of their systems and/or
|
||||||
|
* data to be ensured and, more generally, to use and operate it in the
|
||||||
|
* same conditions as regards security.
|
||||||
|
*
|
||||||
|
* The fact that you are presently reading this means that you have had
|
||||||
|
* knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.command.Command;
|
||||||
|
import net.bigeon.gclc.exception.CommandRunException;
|
||||||
|
import net.bigeon.gclc.exception.CommandRunExceptionType;
|
||||||
|
import net.bigeon.gclc.manager.ConsoleInput;
|
||||||
|
import net.bigeon.gclc.manager.ConsoleOutput;
|
||||||
|
import net.bigeon.gclc.socket.ConnexionManager;
|
||||||
|
|
||||||
|
/** A {@link Command} to disconnect elements from a {@link ConnexionManager}.
|
||||||
|
*
|
||||||
|
* @author Emmanuel Bigeon
|
||||||
|
* @param <T> the type of connected object */
|
||||||
|
public final class RemoteDisconnectCommand<T> extends Command {
|
||||||
|
|
||||||
|
/** The connexion manager. */
|
||||||
|
private final ConnexionManager<T> manager;
|
||||||
|
/** If all connexion should be disconnected when no argument have been
|
||||||
|
* specified. */
|
||||||
|
private final boolean all;
|
||||||
|
|
||||||
|
/** Create the disconnection command.
|
||||||
|
*
|
||||||
|
* @param name the command name
|
||||||
|
* @param manager the manager
|
||||||
|
* @param all if all elements should be disconnected when no argument is
|
||||||
|
* provided */
|
||||||
|
public RemoteDisconnectCommand(final String name, final ConnexionManager<T> manager,
|
||||||
|
final boolean all) {
|
||||||
|
super(name);
|
||||||
|
this.manager = manager;
|
||||||
|
this.all = all;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.ICommand#execute(fr.bigeon.gclc.manager.
|
||||||
|
* ConsoleOutput, fr.bigeon.gclc.manager.ConsoleInput, java.lang.String[]) */
|
||||||
|
@Override
|
||||||
|
public void execute(final ConsoleOutput out, final ConsoleInput in,
|
||||||
|
final String... args) throws CommandRunException {
|
||||||
|
if (args.length == 0 && all) {
|
||||||
|
final Collection<String> coll = manager.getConnected();
|
||||||
|
for (final String string : coll) {
|
||||||
|
manager.disconnect(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (final String string : args) {
|
||||||
|
if (manager.isConnected(string)) {
|
||||||
|
manager.disconnect(string);
|
||||||
|
} else {
|
||||||
|
print(out,
|
||||||
|
MessageFormat.format("[WARNING] {0} is not connected", string)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Print a message if the output is defined.
|
||||||
|
*
|
||||||
|
* @param out the output
|
||||||
|
* @param string the message
|
||||||
|
* @throws CommandRunException if the output exists but cannot be printed to */
|
||||||
|
private static void print(final ConsoleOutput out, final String string)
|
||||||
|
throws CommandRunException {
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.println(string);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
throw new CommandRunException(CommandRunExceptionType.INTERACTION,
|
||||||
|
"Unable to print to existing output", e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.ICommand#tip() */
|
||||||
|
@Override
|
||||||
|
public String tip() {
|
||||||
|
return "Close a connexion."; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.Command#usageDetail() */
|
||||||
|
@Override
|
||||||
|
protected String usageDetail() {
|
||||||
|
return MessageFormat.format(
|
||||||
|
" If arguments are provided the corresponding connexions are closed, otherwise\n{0} are.",
|
||||||
|
all ? "all connexions" : "none");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @author Emmanuel Bigeon
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.bigeon.gclc.socket.cmd;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
* gclc-socket:net.bigeon.gclc.socket.RemoteDisconnectCommandTest.java
|
* gclc-socket:net.bigeon.gclc.socket.RemoteDisconnectCommandTest.java
|
||||||
* Created on: Nov 18, 2017
|
* Created on: Nov 18, 2017
|
||||||
*/
|
*/
|
||||||
package net.bigeon.gclc.socket;
|
package net.bigeon.gclc.socket.cmd;
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* #%L
|
* #%L
|
||||||
@@ -46,7 +46,8 @@ import java.io.IOException;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.bigeon.gclc.exception.CommandRunException;
|
import net.bigeon.gclc.exception.CommandRunException;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
import net.bigeon.gclc.socket.DConnexionManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -56,7 +57,7 @@ import net.bigeon.gclc.utils.PipedConsoleOutput;
|
|||||||
public class RemoteDisconnectCommandTest {
|
public class RemoteDisconnectCommandTest {
|
||||||
|
|
||||||
/** Test method for
|
/** Test method for
|
||||||
* {@link net.bigeon.gclc.socket.RemoteDisconnectCommand#execute(net.bigeon.gclc.manager.ConsoleOutput, net.bigeon.gclc.manager.ConsoleInput, java.lang.String[])}.
|
* {@link net.bigeon.gclc.socket.cmd.RemoteDisconnectCommand#execute(net.bigeon.gclc.manager.ConsoleOutput, net.bigeon.gclc.manager.ConsoleInput, java.lang.String[])}.
|
||||||
*
|
*
|
||||||
* @throws CommandRunException if the command unexpectedly failed.
|
* @throws CommandRunException if the command unexpectedly failed.
|
||||||
* @throws IOException if the output could not be written to */
|
* @throws IOException if the output could not be written to */
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.bigeon.config</groupId>
|
<groupId>net.bigeon.config</groupId>
|
||||||
<artifactId>swt-config</artifactId>
|
<artifactId>swt-public-conf</artifactId>
|
||||||
<version>1.8.11</version>
|
<version>1.0.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>net.bigeon.gclc</groupId>
|
<groupId>net.bigeon.gclc</groupId>
|
||||||
<artifactId>swt</artifactId>
|
<artifactId>swt</artifactId>
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>GCLC swt</name>
|
<name>GCLC swt</name>
|
||||||
<description>A swt window for console applications</description>
|
<description>A swt window for console applications</description>
|
||||||
@@ -48,17 +48,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon</groupId>
|
<groupId>net.bigeon</groupId>
|
||||||
<artifactId>gclc</artifactId>
|
<artifactId>gclc</artifactId>
|
||||||
<version>2.0.12</version>
|
<version>2.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.bigeon</groupId>
|
<groupId>net.bigeon</groupId>
|
||||||
<artifactId>collections</artifactId>
|
<artifactId>collections</artifactId>
|
||||||
<version>1.1.6</version>
|
<version>1.2.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>2.23.0</version>
|
<version>2.27.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
import net.bigeon.gclc.utils.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
|
|
||||||
/** The object managing the console input.
|
/** The object managing the console input.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -38,103 +38,14 @@ package net.bigeon.gclc.swt;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.swt.widgets.Widget;
|
|
||||||
|
|
||||||
import net.bigeon.gclc.utils.AOutputForwardRunnable;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.swt.tools.ToSWTConsoleForwardRunnable;
|
||||||
|
|
||||||
/** The manager for console output to insert in a text.
|
/** The manager for console output to insert in a text.
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bigeon */
|
* @author Emmanuel Bigeon */
|
||||||
public final class ConsoleOutputManager implements ConsoleOutputDisplay {
|
public final class ConsoleOutputManager implements ConsoleOutputDisplay {
|
||||||
/** A runnable appending text to the content of a {@link Text} component.
|
|
||||||
*
|
|
||||||
* @author Emmanuel Bigeon */
|
|
||||||
private static class TextAppendingRunnable implements Runnable {
|
|
||||||
/** The text to append on a line (possibly new). */
|
|
||||||
private final String next;
|
|
||||||
/** The {@link Text} component. */
|
|
||||||
private final Text text;
|
|
||||||
|
|
||||||
/** Create the appending runnable.
|
|
||||||
*
|
|
||||||
* @param text the component to update
|
|
||||||
* @param next the text to append */
|
|
||||||
public TextAppendingRunnable(final Text text, final String next) {
|
|
||||||
this.text = text;
|
|
||||||
this.next = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Runnable#run() */
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
final String initialText = text.getText();
|
|
||||||
if (initialText != null && !initialText.isEmpty()) {
|
|
||||||
text.append(System.lineSeparator());
|
|
||||||
}
|
|
||||||
text.append(next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The local implementation of the forwarding runnable.
|
|
||||||
*
|
|
||||||
* @author Emmanuel Bigeon */
|
|
||||||
private static final class ToSWTConsoleForwardRunnable
|
|
||||||
extends AOutputForwardRunnable {
|
|
||||||
/** The running status. */
|
|
||||||
private boolean running = true;
|
|
||||||
/** The console output. */
|
|
||||||
private final PipedConsoleOutput out;
|
|
||||||
/** The console output display. */
|
|
||||||
private final ConsoleOutputDisplay display;
|
|
||||||
/** The actual SWT component. */
|
|
||||||
private final Widget element;
|
|
||||||
|
|
||||||
/** Create the forwarding runnable.
|
|
||||||
*
|
|
||||||
* @param manager the manager
|
|
||||||
* @param display the display
|
|
||||||
* @param element the composite */
|
|
||||||
public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager,
|
|
||||||
final ConsoleOutputDisplay display,
|
|
||||||
final Widget element) {
|
|
||||||
super(manager);
|
|
||||||
out = manager;
|
|
||||||
this.display = display;
|
|
||||||
this.element = element;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see
|
|
||||||
* net.bigeon.gclc.utils.AOutputForwardRunnable#forwardLine(java.lang.String) */
|
|
||||||
@Override
|
|
||||||
protected void forwardLine(final String m) {
|
|
||||||
display.appendLine(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see net.bigeon.gclc.utils.AOutputForwardRunnable#isRunning() */
|
|
||||||
@Override
|
|
||||||
protected boolean isRunning() {
|
|
||||||
return running && !element.isDisposed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the running status.
|
|
||||||
*
|
|
||||||
* @param running the running to set */
|
|
||||||
public void setRunning(final boolean running) {
|
|
||||||
this.running = running;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the output.
|
|
||||||
*
|
|
||||||
* @return the currently forwarded output */
|
|
||||||
public PipedConsoleOutput getOuput() {
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The SWT component displaying the output content. */
|
/** The SWT component displaying the output content. */
|
||||||
private final Text text;
|
private final Text text;
|
||||||
/** The forwarding runnable. */
|
/** The forwarding runnable. */
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ import java.io.BufferedReader;
|
|||||||
|
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.swt.tools.PromptReadingRunnable;
|
||||||
|
|
||||||
/** The manager for the console prompt updates.
|
/** The manager for the console prompt updates.
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bigeon */
|
* @author Emmanuel Bigeon */
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ import org.eclipse.swt.SWT;
|
|||||||
import org.eclipse.swt.events.KeyAdapter;
|
import org.eclipse.swt.events.KeyAdapter;
|
||||||
import org.eclipse.swt.events.KeyEvent;
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
|
||||||
import net.bigeon.collections.ArrayRibbon;
|
|
||||||
import net.bigeon.collections.Ribbon;
|
import net.bigeon.collections.Ribbon;
|
||||||
|
import net.bigeon.collections.ribbon.ArrayRibbon;
|
||||||
|
|
||||||
/** A key listener to validate commands and manage the history of commands.
|
/** A key listener to validate commands and manage the history of commands.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ import org.eclipse.swt.widgets.Composite;
|
|||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
import net.bigeon.gclc.utils.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
/** A shell containing a {@link SWTConsoleView}
|
/** A shell containing a {@link SWTConsoleView}
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ import org.eclipse.swt.widgets.Composite;
|
|||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
import net.bigeon.gclc.ConsoleApplication;
|
import net.bigeon.gclc.ConsoleApplication;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
/** A SWT component to connect to gclc {@link ConsoleApplication}.
|
/** A SWT component to connect to gclc {@link ConsoleApplication}.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.bigeon.gclc.swt;
|
||||||
|
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
/** A runnable appending text to the content of a {@link Text} component.
|
||||||
|
*
|
||||||
|
* @author Emmanuel Bigeon */
|
||||||
|
public class TextAppendingRunnable implements Runnable {
|
||||||
|
/** The text to append on a line (possibly new). */
|
||||||
|
private final String next;
|
||||||
|
/** The {@link Text} component. */
|
||||||
|
private final Text text;
|
||||||
|
|
||||||
|
/** Create the appending runnable.
|
||||||
|
*
|
||||||
|
* @param text the component to update
|
||||||
|
* @param next the text to append */
|
||||||
|
public TextAppendingRunnable(final Text text, final String next) {
|
||||||
|
this.text = text;
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Runnable#run() */
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final String initialText = text.getText();
|
||||||
|
if (initialText != null && !initialText.isEmpty()) {
|
||||||
|
text.append(System.lineSeparator());
|
||||||
|
}
|
||||||
|
text.append(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package net.bigeon.gclc.swt;
|
package net.bigeon.gclc.swt.tools;
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* #%L
|
* #%L
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package net.bigeon.gclc.swt.tools;
|
||||||
|
|
||||||
|
import org.eclipse.swt.widgets.Widget;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
import net.bigeon.gclc.manager.forwarding.AOutputForwardRunnable;
|
||||||
|
import net.bigeon.gclc.swt.ConsoleOutputDisplay;
|
||||||
|
|
||||||
|
/** The local implementation of the forwarding runnable.
|
||||||
|
*
|
||||||
|
* @author Emmanuel Bigeon */
|
||||||
|
public final class ToSWTConsoleForwardRunnable
|
||||||
|
extends AOutputForwardRunnable {
|
||||||
|
/** The running status. */
|
||||||
|
private boolean running = true;
|
||||||
|
/** The console output. */
|
||||||
|
private final PipedConsoleOutput out;
|
||||||
|
/** The console output display. */
|
||||||
|
private final ConsoleOutputDisplay display;
|
||||||
|
/** The actual SWT component. */
|
||||||
|
private final Widget element;
|
||||||
|
|
||||||
|
/** Create the forwarding runnable.
|
||||||
|
*
|
||||||
|
* @param manager the manager
|
||||||
|
* @param display the display
|
||||||
|
* @param element the composite */
|
||||||
|
public ToSWTConsoleForwardRunnable(final PipedConsoleOutput manager,
|
||||||
|
final ConsoleOutputDisplay display,
|
||||||
|
final Widget element) {
|
||||||
|
super(manager);
|
||||||
|
out = manager;
|
||||||
|
this.display = display;
|
||||||
|
this.element = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see
|
||||||
|
* net.bigeon.gclc.utils.AOutputForwardRunnable#forwardLine(java.lang.String) */
|
||||||
|
@Override
|
||||||
|
protected void forwardLine(final String m) {
|
||||||
|
display.appendLine(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see net.bigeon.gclc.utils.AOutputForwardRunnable#isRunning() */
|
||||||
|
@Override
|
||||||
|
protected boolean isRunning() {
|
||||||
|
return running && !element.isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the running status.
|
||||||
|
*
|
||||||
|
* @param running the running to set */
|
||||||
|
public void setRunning(final boolean running) {
|
||||||
|
this.running = running;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the output.
|
||||||
|
*
|
||||||
|
* @return the currently forwarded output */
|
||||||
|
public PipedConsoleOutput getOuput() {
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/** Tool classes for the library. External code should not rely on classes in
|
||||||
|
* there as they can be removed without notice.
|
||||||
|
*
|
||||||
|
* @author Emmanuel Bigeon */
|
||||||
|
package net.bigeon.gclc.swt.tools;
|
||||||
|
|
||||||
@@ -39,17 +39,14 @@ package net.bigeon.gclc.swt;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import net.bigeon.gclc.utils.PipedConsoleInput;
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class ConsoleInputManagerTest {
|
public class ConsoleInputManagerTest {
|
||||||
|
|||||||
@@ -38,10 +38,7 @@ package net.bigeon.gclc.swt;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -51,7 +48,7 @@ import org.junit.Test;
|
|||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
import net.bigeon.gclc.utils.PipedConsoleOutput;
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class ConsoleOutputManagerTest {
|
public class ConsoleOutputManagerTest {
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ import org.junit.Test;
|
|||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.swt.tools.PromptReadingRunnable;
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class PromptReadingRunnableTest {
|
public class PromptReadingRunnableTest {
|
||||||
private final Label view = mock(Label.class);
|
private final Label view = mock(Label.class);
|
||||||
@@ -72,7 +74,7 @@ public class PromptReadingRunnableTest {
|
|||||||
}).when(display).syncExec(any(Runnable.class));
|
}).when(display).syncExec(any(Runnable.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test method for {@link net.bigeon.gclc.swt.PromptReadingRunnable#run()}.
|
/** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}.
|
||||||
*
|
*
|
||||||
* @throws IOException if an error occurred */
|
* @throws IOException if an error occurred */
|
||||||
@Test
|
@Test
|
||||||
@@ -85,7 +87,7 @@ public class PromptReadingRunnableTest {
|
|||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test method for {@link net.bigeon.gclc.swt.PromptReadingRunnable#run()}.
|
/** Test method for {@link net.bigeon.gclc.swt.tools.PromptReadingRunnable#run()}.
|
||||||
*
|
*
|
||||||
* @throws IOException if an error occurred */
|
* @throws IOException if an error occurred */
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ import org.eclipse.swt.widgets.Composite;
|
|||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class SWTConsoleShellTest {
|
public class SWTConsoleShellTest {
|
||||||
|
|
||||||
@@ -61,7 +64,7 @@ public class SWTConsoleShellTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Test method for
|
/** Test method for
|
||||||
* {@link net.bigeon.gclc.swt.SWTConsole#connect(net.bigeon.gclc.utils.PipedConsoleInput, net.bigeon.gclc.utils.PipedConsoleOutput, java.io.BufferedReader)}. */
|
* {@link net.bigeon.gclc.swt.SWTConsole#connect(PipedConsoleInput, PipedConsoleOutput, java.io.BufferedReader)}. */
|
||||||
@Test
|
@Test
|
||||||
public void testConnect() {
|
public void testConnect() {
|
||||||
final SWTConsole console = new SWTConsole(new Shell(), SWT.NONE);
|
final SWTConsole console = new SWTConsole(new Shell(), SWT.NONE);
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ import org.eclipse.swt.SWT;
|
|||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleInput;
|
||||||
|
import net.bigeon.gclc.manager.PipedConsoleOutput;
|
||||||
|
|
||||||
/** @author Emmanuel Bigeon */
|
/** @author Emmanuel Bigeon */
|
||||||
public class SWTConsoleViewTest {
|
public class SWTConsoleViewTest {
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ public class SWTConsoleViewTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Test method for
|
/** Test method for
|
||||||
* {@link net.bigeon.gclc.swt.SWTConsoleView#setManager(net.bigeon.gclc.utils.PipedConsoleOutput, net.bigeon.gclc.utils.PipedConsoleInput)}. */
|
* {@link net.bigeon.gclc.swt.SWTConsoleView#setManager(PipedConsoleOutput, PipedConsoleInput)}. */
|
||||||
@Test
|
@Test
|
||||||
public void testSetManager() {
|
public void testSetManager() {
|
||||||
final SWTConsoleView view = new SWTConsoleView(new Shell(), SWT.NONE);
|
final SWTConsoleView view = new SWTConsoleView(new Shell(), SWT.NONE);
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.bigeon.config</groupId>
|
<groupId>net.bigeon.config</groupId>
|
||||||
<artifactId>ebigeon-config</artifactId>
|
<artifactId>ebigeon-public-conf</artifactId>
|
||||||
<version>1.8.21</version>
|
<version>1.0.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>net.bigeon</groupId>
|
<groupId>net.bigeon</groupId>
|
||||||
<artifactId>gclc</artifactId>
|
<artifactId>gclc</artifactId>
|
||||||
<version>2.1.0</version>
|
<version>2.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Generic Command Ligne console</name>
|
<name>Generic Command Ligne console</name>
|
||||||
<description>A generic framework for console applications, with customized command input and output streams.</description>
|
<description>A generic framework for console applications, with customized command input and output streams.</description>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</developers>
|
</developers>
|
||||||
<scm>
|
<scm>
|
||||||
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection>
|
<developerConnection>scm:git:gogs@git.code.bigeon.net:emmanuel/gclc.git</developerConnection>
|
||||||
<tag>gclc-2.1.0</tag>
|
<tag>gclc-2.1.1</tag>
|
||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public final class GCLCConstants {
|
|||||||
}
|
}
|
||||||
if (startIndex < cmd.length()) {
|
if (startIndex < cmd.length()) {
|
||||||
final String arg = cmd.substring(startIndex, cmd.length());
|
final String arg = cmd.substring(startIndex, cmd.length());
|
||||||
args.add(arg);
|
args.add(removeEscaped(arg));
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user