make code more snappy
This commit is contained in:
parent
30a07f9c60
commit
ebc8c5dbde
|
@ -4,7 +4,12 @@ import com.janetfilter.core.utils.DateUtils;
|
||||||
import com.janetfilter.core.utils.ProcessUtils;
|
import com.janetfilter.core.utils.ProcessUtils;
|
||||||
import com.janetfilter.core.utils.WhereIsUtils;
|
import com.janetfilter.core.utils.WhereIsUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -62,46 +67,28 @@ public class VMSelector {
|
||||||
System.out.println(" =========================== " + DateUtils.formatDateTime() + " ============================");
|
System.out.println(" =========================== " + DateUtils.formatDateTime() + " ============================");
|
||||||
select();
|
select();
|
||||||
return;
|
return;
|
||||||
case "":
|
|
||||||
processSelect();
|
|
||||||
return;
|
|
||||||
default:
|
default:
|
||||||
int index;
|
VMDescriptor targetVmDescriptor;
|
||||||
try {
|
try {
|
||||||
index = Integer.parseInt(input);
|
int seq = Integer.parseInt(input);
|
||||||
} catch (NumberFormatException e) {
|
targetVmDescriptor = descriptors.get(seq - 1);
|
||||||
invalidInput(input);
|
} catch (NumberFormatException | IndexOutOfBoundsException e) {
|
||||||
return;
|
System.err.println("> Invalid input: " + input);
|
||||||
}
|
processSelect();
|
||||||
|
|
||||||
if (index < 1) {
|
|
||||||
invalidInput(input);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index > descriptors.size()) {
|
|
||||||
invalidInput(input);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.print(" Agent args: ");
|
System.out.print(" Agent args: ");
|
||||||
input = getInput();
|
input = getInput();
|
||||||
try {
|
try {
|
||||||
VMLauncher.launch(thisJar, descriptors.get(index - 1), input);
|
VMLauncher.launch(thisJar, targetVmDescriptor, input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("> Attach to: " + index + " failed.");
|
System.err.println("> Attach failed.");
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidInput(String input) throws Exception {
|
|
||||||
System.err.println("> Invalid input: " + input);
|
|
||||||
processSelect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void select() throws Exception {
|
public void select() throws Exception {
|
||||||
boolean first = null == descriptors;
|
boolean first = null == descriptors;
|
||||||
List<VMDescriptor> temp = getVMList();
|
List<VMDescriptor> temp = getVMList();
|
||||||
|
|
Loading…
Reference in New Issue