Пример #1
0
  private void registerShutdownHook() {
    ShutDownTracker
        .getInstance(); // Necessary to avoid creating an instance while already shutting down.

    ShutDownTracker.getInstance()
        .registerShutdownTask(
            new Runnable() {
              public void run() {
                if (isDisposed() || isDisposeInProgress()) {
                  return;
                }
                try {
                  SwingUtilities.invokeAndWait(
                      new Runnable() {
                        public void run() {
                          ApplicationManagerEx.setApplication(ApplicationImpl.this);
                          try {
                            saveAll();
                          } finally {
                            disposeSelf();
                          }
                        }
                      });
                } catch (InterruptedException e) {
                  LOG.error(e);
                } catch (InvocationTargetException e) {
                  LOG.error(e);
                }
              }
            });
  }
  private void registerShutdownHook() {
    ShutDownTracker
        .getInstance(); // Necessary to avoid creating an instance while already shutting down.

    ShutDownTracker.getInstance()
        .registerShutdownTask(
            new Runnable() {
              public void run() {
                if (isDisposed() || isDisposeInProgress()) {
                  return;
                }
                ShutDownTracker.invokeAndWait(
                    isUnitTestMode(),
                    new Runnable() {
                      public void run() {
                        if (ApplicationManager.getApplication() != ApplicationImpl.this) return;
                        try {
                          myDisposeInProgress = true;
                          saveAll();
                        } finally {
                          disposeSelf();
                        }
                      }
                    });
              }
            });
  }
  public void dispose() {
    fireApplicationExiting();

    ShutDownTracker.getInstance().ensureStopperThreadsFinished();

    disposeComponents();

    ourThreadExecutorsService.shutdownNow();
    myComponentStore = null;
    super.dispose();
    Disposer.dispose(myLastDisposable); // dispose it last
  }
Пример #4
0
  private static void assertIsDispatchThread(String message) {
    if (ShutDownTracker.isShutdownHookRunning()) return;
    final Thread currentThread = Thread.currentThread();
    if (ourDispatchThread == currentThread) return;

    if (EventQueue.isDispatchThread()) {
      ourDispatchThread = currentThread;
    }
    if (ourDispatchThread == currentThread) return;

    Integer safeCounter = ourEdtSafe.get();
    if (safeCounter != null && safeCounter > 0) return;

    LOG.error(
        message,
        "Current thread: " + describe(Thread.currentThread()),
        "Our dispatch thread:" + describe(ourDispatchThread),
        "SystemEventQueueThread: " + describe(getEventQueueThread()));
  }
Пример #5
0
 public void assertTimeConsuming() {
   if (myTestModeFlag || myHeadlessMode || ShutDownTracker.isShutdownHookRunning()) return;
   LOG.assertTrue(
       !isDispatchThread(), "This operation is time consuming and must not be called on EDT");
 }