Added aborting of the client registration process, if it fails during the registration process. Wrapped logger.debug/trace into checks first. Tweaked caller of RmiBridge

This commit is contained in:
nathan 2014-08-22 13:51:02 +02:00
parent 68997f29ad
commit 02dbf82711
2 changed files with 36 additions and 12 deletions

View File

@ -126,7 +126,10 @@ public class FileUtil {
parentOut.mkdirs(); parentOut.mkdirs();
} }
logger.trace("Copying file: {} --> {}", in, out); Logger logger2 = logger;
if (logger2.isTraceEnabled()) {
logger2.trace("Copying file: {} --> {}", in, out);
}
FileChannel sourceChannel = null; FileChannel sourceChannel = null;
FileChannel destinationChannel = null; FileChannel destinationChannel = null;
@ -221,7 +224,10 @@ public class FileUtil {
// if directory not exists, create it // if directory not exists, create it
if (!dest.exists()) { if (!dest.exists()) {
dest.mkdir(); dest.mkdir();
logger.trace("Directory copied from {} --> {}", src, dest); Logger logger2 = logger;
if (logger2.isTraceEnabled()) {
logger2.trace("Directory copied from {} --> {}", src, dest);
}
} }
// list all the directory contents // list all the directory contents
@ -266,7 +272,10 @@ public class FileUtil {
// if directory not exists, create it // if directory not exists, create it
if (!dest.exists()) { if (!dest.exists()) {
dest.mkdir(); dest.mkdir();
logger.trace("Directory copied from {} --> {}", src, dest); Logger logger2 = logger;
if (logger2.isTraceEnabled()) {
logger2.trace("Directory copied from {} --> {}", src, dest);
}
} }
// list all the directory contents // list all the directory contents
@ -301,18 +310,23 @@ public class FileUtil {
* Deletes a file or directory and all files and sub-directories under it. * Deletes a file or directory and all files and sub-directories under it.
*/ */
public static boolean delete(File file) { public static boolean delete(File file) {
Logger logger2 = logger;
if (file.exists() && file.isDirectory()) { if (file.exists() && file.isDirectory()) {
File[] files = file.listFiles(); File[] files = file.listFiles();
for (int i = 0, n = files.length; i < n; i++) { for (int i = 0, n = files.length; i < n; i++) {
if (files[i].isDirectory()) { if (files[i].isDirectory()) {
delete(files[i].getAbsolutePath()); delete(files[i].getAbsolutePath());
} else { } else {
logger.trace("Deleting file: {}", files[i]); if (logger2.isTraceEnabled()) {
logger2.trace("Deleting file: {}", files[i]);
}
files[i].delete(); files[i].delete();
} }
} }
} }
logger.trace("Deleting file: {}", file); if (logger2.isTraceEnabled()) {
logger2.trace("Deleting file: {}", file);
}
return file.delete(); return file.delete();
} }
@ -328,7 +342,10 @@ public class FileUtil {
String path = location.getAbsolutePath(); String path = location.getAbsolutePath();
if (location.mkdirs()) { if (location.mkdirs()) {
logger.trace("Created directory: {}", path); Logger logger2 = logger;
if (logger2.isTraceEnabled()) {
logger2.trace("Created directory: {}", path);
}
} }
return path; return path;

View File

@ -12,6 +12,7 @@ import jline.console.ConsoleReader;
import org.fusesource.jansi.Ansi; import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.AnsiConsole; import org.fusesource.jansi.AnsiConsole;
import org.slf4j.Logger;
public class InputConsole { public class InputConsole {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(InputConsole.class); private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(InputConsole.class);
@ -96,10 +97,13 @@ public class InputConsole {
terminal.setEchoEnabled(true); terminal.setEchoEnabled(true);
this.isIDE = terminal instanceof IDE_Terminal; this.isIDE = terminal instanceof IDE_Terminal;
if (this.isIDE) { Logger logger2 = logger;
logger.debug("Terminal is in IDE (best guess). Unable to support single key input. Only line input available."); if (logger2.isDebugEnabled()) {
} else { if (this.isIDE) {
logger.debug("Terminal Type: {}", terminal.getClass().getSimpleName()); logger2.debug("Terminal is in IDE (best guess). Unable to support single key input. Only line input available.");
} else {
logger2.debug("Terminal Type: {}", terminal.getClass().getSimpleName());
}
} }
} catch (UnsupportedEncodingException ignored) { } catch (UnsupportedEncodingException ignored) {
} catch (IOException ignored) { } catch (IOException ignored) {
@ -225,8 +229,9 @@ public class InputConsole {
} }
private final void run() { private final void run() {
Logger logger2 = logger;
if (this.jlineReader == null) { if (this.jlineReader == null) {
logger.error("Unable to start Console Reader"); logger2.error("Unable to start Console Reader");
return; return;
} }
@ -264,7 +269,9 @@ public class InputConsole {
while ((typedChar = this.jlineReader.readCharacter()) != -1) { while ((typedChar = this.jlineReader.readCharacter()) != -1) {
char asChar = (char) typedChar; char asChar = (char) typedChar;
logger.trace("READ: {} ({})", asChar, typedChar); if (logger2.isTraceEnabled()) {
logger2.trace("READ: {} ({})", asChar, typedChar);
}
// notify everyone waiting for a character. // notify everyone waiting for a character.
synchronized (this.inputLockSingle) { synchronized (this.inputLockSingle) {