34public class StartRemoteVMProcessor
extends AbstractProcessor {
36 public static final String ID =
"VM";
38 public static final boolean IMPLEMENTED =
true;
40 private int remoteDebugPort = 0;
41 private boolean remoteDebugSuspendAtStart =
false;
42 private boolean stopVMonDisconnect =
true;
44 private List<String> vmArgs =
new ArrayList<String>();
45 private List<String> launcherArgs =
new ArrayList<String>();
47 public StartRemoteVMProcessor() {
51 public int getRemoteDebugPort() {
52 return remoteDebugPort;
55 public void setRemoteDebugPort(
int remoteDebugPort) {
56 this.remoteDebugPort = remoteDebugPort;
59 public boolean isRemoteDebugSuspendAtStart() {
60 return remoteDebugSuspendAtStart;
63 public void setRemoteDebugSuspendAtStart(
boolean remoteDebugSuspendAtStart) {
64 this.remoteDebugSuspendAtStart = remoteDebugSuspendAtStart;
67 public List<String> getVmArgs() {
71 public List<String> getLauncherArgs() {
75 public boolean isStopVMonDisconnect() {
76 return stopVMonDisconnect;
79 public void setStopVMonDisconnect(
boolean stopVMonDisconnect) {
80 this.stopVMonDisconnect = stopVMonDisconnect;
83 public void receive(DataInputStream dis)
throws IOException{
86 remoteDebugPort = dis.readInt();
87 remoteDebugSuspendAtStart = dis.readBoolean();
88 stopVMonDisconnect = dis.readBoolean();
90 int argsLen = dis.readShort();
91 for (
int i = 0; i < argsLen; i++) {
92 vmArgs.add(dis.readUTF());
94 argsLen = dis.readShort();
95 for (
int i = 0; i < argsLen; i++) {
96 launcherArgs.add(dis.readUTF());
102 public void startVM()
throws IOException {
105 public void send(DataOutputStream dos)
throws IOException {
106 dos.writeUTF(getId());
107 dos.writeInt(remoteDebugPort);
108 dos.writeBoolean(remoteDebugSuspendAtStart);
109 dos.writeBoolean(stopVMonDisconnect);
111 ByteArrayOutputStream cache =
new ByteArrayOutputStream();
112 DataOutputStream dosCache =
new DataOutputStream(cache);
113 dosCache.writeShort(vmArgs.size());
114 for (String arg : vmArgs) {
115 dosCache.writeUTF(arg);
117 dosCache.writeShort(launcherArgs.size());
118 for (String arg : launcherArgs) {
119 dosCache.writeUTF(arg);
123 byte[] cacheBytes = cache.toByteArray();
124 if (cacheBytes.length > 32767) {
125 throw new RuntimeException(
"StartRemoteVM arguments longer than 32767 (" + cacheBytes.length +
")");
127 dos.writeShort(cacheBytes.length);
128 dos.write(cacheBytes);