private synchronized Object setInternalResult(Object result, boolean isAsync, IApplication tokenApp) { if (setResult) throw new IllegalStateException("The result of the application is already set."); //$NON-NLS-1$ if (isAsync) { if (!setAsyncResult) throw new IllegalStateException("The application must return IApplicationContext.EXIT_ASYNC_RESULT to set asynchronous results."); //$NON-NLS-1$ if (application != tokenApp) throw new IllegalArgumentException("The application is not the correct instance for this application context."); //$NON-NLS-1$ } else { if (result == IApplicationContext.EXIT_ASYNC_RESULT) { setAsyncResult = true; return NULL_RESULT; // the result well be set with setResult } } this.result = result; setResult = true; application = null; notifyAll(); // The application exited itself; notify the app context setAppStatus(EclipseAppHandle.FLAG_STOPPING); // must ensure the STOPPING event is fired setAppStatus(EclipseAppHandle.FLAG_STOPPED); // only set the exit code property if this is the default application // (bug 321386) only set the exit code if the result != null; when result == null we assume an exception was thrown if (isDefault() && result != null) { int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0; // Use the EnvironmentInfo Service to set properties Activator.setProperty(PROP_ECLIPSE_EXITCODE, Integer.toString(exitCode)); } return result; }
private synchronized Object setInternalResult(Object result, boolean isAsync, IApplication tokenApp) { if (setResult) throw new IllegalStateException("The result of the application is already set."); //$NON-NLS-1$ if (isAsync) { if (!setAsyncResult) throw new IllegalStateException("The application must return IApplicationContext.EXIT_ASYNC_RESULT to set asynchronous results."); //$NON-NLS-1$ if (application != tokenApp) throw new IllegalArgumentException("The application is not the correct instance for this application context."); //$NON-NLS-1$ } else { if (result == IApplicationContext.EXIT_ASYNC_RESULT) { setAsyncResult = true; return NULL_RESULT; // the result well be set with setResult } } this.result = result; setResult = true; application = null; notifyAll(); // The application exited itself; notify the app context setAppStatus(EclipseAppHandle.FLAG_STOPPING); // must ensure the STOPPING event is fired setAppStatus(EclipseAppHandle.FLAG_STOPPED); // only set the exit code property if this is the default application // (bug 321386) only set the exit code if the result != null; when result == null we assume an exception was thrown if (isDefault() && result != null) { int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0; // Use the EnvironmentInfo Service to set properties Activator.setProperty(PROP_ECLIPSE_EXITCODE, Integer.toString(exitCode)); } return result; }
private synchronized Object setInternalResult(Object result, boolean isAsync, IApplication tokenApp) { if (setResult) throw new IllegalStateException("The result of the application is already set."); //$NON-NLS-1$ if (isAsync) { if (!setAsyncResult) throw new IllegalStateException("The application must return IApplicationContext.EXIT_ASYNC_RESULT to set asynchronous results."); //$NON-NLS-1$ if (application != tokenApp) throw new IllegalArgumentException("The application is not the correct instance for this application context."); //$NON-NLS-1$ } else { if (result == IApplicationContext.EXIT_ASYNC_RESULT) { setAsyncResult = true; return NULL_RESULT; // the result well be set with setResult } } this.result = result; setResult = true; application = null; notifyAll(); // The application exited itself; notify the app context setAppStatus(EclipseAppHandle.FLAG_STOPPING); // must ensure the STOPPING event is fired setAppStatus(EclipseAppHandle.FLAG_STOPPED); // only set the exit code property if this is the default application // (bug 321386) only set the exit code if the result != null; when result == null we assume an exception was thrown if (isDefault() && result != null) { int exitCode = result instanceof Integer ? ((Integer) result).intValue() : 0; // Use the EnvironmentInfo Service to set properties Activator.setProperty(PROP_ECLIPSE_EXITCODE, Integer.toString(exitCode)); } return result; }