if (DefaultAgentManager.getInstance().hasActiveAgent(session)) {
try {
Request agentRequest = ((ApplicationService) DefaultAgentManager.getInstance().getService(ApplicationService.class)).launchApplication(launchSession);
AgentTunnel agent = DefaultAgentManager.getInstance().getAgentBySession(launchSession.getSession());
if (!agent.sendRequest(agentRequest, true, 60000)) {
throw new ExtensionException(ExtensionException.AGENT_REFUSED_LAUNCH);
}
ByteArrayReader baw = new ByteArrayReader(agentRequest.getRequestData());
try {
while(true) {
String name = baw.readString();
String hostname = baw.readString();
long port = baw.readInt();
if(tunnels.length() > 0) {
tunnels.append(",");
}
tunnels.append(name);
tunnels.append(":");
tunnels.append(hostname);
tunnels.append(":");
tunnels.append(port);
log.info("Got temporary tunnel '" + name + "' = " + port + " (" + hostname + ")");
}
}
catch(EOFException eofe) {
}
} catch (ExtensionException ee) {
throw ee;
} catch (Exception e) {
throw new ExtensionException(ExtensionException.INTERNAL_ERROR, e);
}
}
else {
throw new ExtensionException(ExtensionException.NO_AGENT);
}
script = "myRef = window.open('" + "/getHTMLApplication.do?"
+ LaunchSession.LAUNCH_ID + "=" + launchSession.getId()
+ "&tunnels=" + Util.urlEncode(tunnels.toString())