System.out.println(System.getProperties().toString());
try {
startingLaunch(appName);
URL codebase = getActualCodebase();
AbstractApplicationLauncher launcher = new AgentLauncherApplicationLauncher(new File(Utils.getHomeDirectory(), cacheDirectory), codebase.getProtocol(), null, codebase //$NON-NLS-1$
.getHost().equals("") ? "localhost" : codebase.getHost(), //$NON-NLS-1$ //$NON-NLS-2$
codebase.getPort() == -1 ? (codebase.getProtocol()!=null && codebase.getProtocol().equalsIgnoreCase("http") ? 80 : 443) : codebase.getPort(), params, AgentLauncher.this);
launcher.setDebug(debug);
System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.settingLocalProxy"), new Object[] { localProxyURL } ) ); //$NON-NLS-1$
launcher.setLocalProxyURL(localProxyURL);
launcher.prepare();
System.out.println(Messages.getString("VPNLauncher.sysout.preparedLauncher")); //$NON-NLS-1$
/*
* Only start the synchronisation thread if this is
* an agent as it is the only type that sends a
* sync message
*/
if(isAgent) {
SynchronizationThread sync = new SynchronizationThread(launcher);
System.out.println(Messages.getString("VPNLauncher.sysout.startingSyncThread")); //$NON-NLS-1$
sync.start();
// Give the connection time to get established
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
launcher.start();
/*
* If this is not the agent then there is no
* synchronisation thread that will handle the
* redirect so we do it directly.
*/
if(!isAgent) {
String returnTo = getParameter("returnTo", ""); //$NON-NLS-1$ //$NON-NLS-2$
URL returnToUrl = returnTo.equals("") ? getDocumentBase() : new URL(getDocumentBase(), returnTo); //$NON-NLS-1$
returnToUrl = new URL(addRedirectParameter(returnToUrl.toExternalForm(), "vpnMessage", appName + " launched.")); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.redirecting"), new Object[] { returnToUrl.toExternalForm() })); //$NON-NLS-1$
setMessage(Messages.getString("VPNLauncher.complete")); //$NON-NLS-1$
getAppletContext().showDocument(returnToUrl);
}
else {
/*
* Monitor the process if required
*/
if (monitor) {
System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.monitoring"), new Object[] { appName })); //$NON-NLS-1$
processMonitor = launcher.getApplicationType().getProcessMonitor();
if (processMonitor != null) {
MonitorOutputStream out = new MonitorOutputStream();
finishedLaunch();
int exitcode = processMonitor.watch(out, out);
System.out.println(MessageFormat.format(Messages.getString("VPNLauncher.sysout.finished"), new Object[] { appName, new Integer(exitcode) })); //$NON-NLS-1$