// claim agent so no new build can start
claim();
}
}
final BasicService basicService;
try {
basicService = (BasicService) ServiceManager.lookup(BasicService.class.getName());
} catch (UnavailableServiceException e) {
final String errMsg = "Couldn't find webstart Basic Service. Is Agent running outside of webstart?";
LOG.error(errMsg, e);
throw new RuntimeException(errMsg, e);
}
final URL codeBaseURL = basicService.getCodeBase();
LOG.info("basicService.getCodeBase()=" + codeBaseURL.toString());
// relaunch via new browser session
// @todo How to close the browser after jnlp is relaunched?
final URL relaunchURL;
try {
relaunchURL = new URL(codeBaseURL, "agent.jnlp");
} catch (MalformedURLException e) {
final String errMsg = "Error building webstart relaunch URL from " + codeBaseURL.toString();
LOG.error(errMsg, e);
throw new RuntimeException(errMsg, e);
}
if (basicService.showDocument(relaunchURL)) {
LOG.info("Relaunched agent via URL: " + relaunchURL.toString() + ". Will kill current agent now.");
doKill(); // don't wait for build finish, since we've already relaunched at this point.
} else {
final String errMsg = "Failed to relaunch agent via URL: " + relaunchURL.toString();
LOG.error(errMsg);