public static Debugger getDebugger(InetAddress host,
int port,
String password) throws IOException {
try
{
Socket s = new Socket(host, port);
try
{
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
int protocolVersion = in.readInt();
if(protocolVersion > 220)
{
throw new IOException(
"Incompatible protocol version " + protocolVersion +
". At most 220 was expected.");
}
byte[] challenge = (byte[])in.readObject();
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(password.getBytes("UTF-8"));
md.update(challenge);
out.writeObject(md.digest());
return new LocalDebuggerProxy((Debugger)in.readObject());
//return (Debugger)in.readObject();
}
finally
{
s.close();
}
}
catch(IOException e)
{
throw e;
}
catch(Exception e)
{
throw new UndeclaredThrowableException(e);
}
}
Connects to the FreeMarker debugger service running on a specific host
and port. The Java VM to which the connection is made must have defined
the system property freemarker.debug.password in order to enable
the debugger service. Additionally, the freemarker.debug.port
system property can be set to specify the port where the debugger service
is listening. When not specified, it defaults to
Debugger#DEFAULT_PORT . |