Examples of WaitLock


Examples of org.jitterbit.ui.wait.WaitLock

     */
    static DetachedEditorUi createAndShow(final Editor editor,
                                          final ApplicationWindow appWin,
                                          final Attacher attacher,
                                          final FocusListener focusListener) {
        final WaitLock waitLock = appWin.startWait();
        final DetachedEditorUi detachedEditor = new DetachedEditorUi(appWin, editor, attacher, focusListener);
        if (EventQueue.isDispatchThread()) {
            detachedEditor.createAndShowDialog(waitLock);
        } else {
            createDialogAndWait(waitLock, detachedEditor);
View Full Code Here

Examples of org.jitterbit.ui.wait.WaitLock

        dialog.setVisible(true);
        return dialog;
    }

    private void startDuplication(EnumSet<EntityType> destinationTypes) {
        WaitLock waitLock = startWait();
        Worker worker = new Worker(destinationTypes, waitLock);
        worker.execute();
    }
View Full Code Here

Examples of org.jitterbit.ui.wait.WaitLock

        @Override
        public void valueChanged(Preference<EditorServiceUiMode> pref,
                                 EditorServiceUiMode oldValue,
                                 EditorServiceUiMode newValue) {
            WaitLock wait = window.startWait();
            switchUi(wait);
        }
View Full Code Here

Examples of org.jitterbit.ui.wait.WaitLock

        String name = StringUtils.join(nameParts, " ");
        ProjectDirectory projectsRoot = view.getProjectManager().getProjectDirectory();
        File dir = new File(projectsRoot.getLocation(), name);
        String projectName = getNewProjectName(dir);
        ProjectLocation projectLoc = new ProjectLocation(projectName, dir);
        WaitLock waitLock = view.getWindow().startWait();
        NewProjectCreator creator = new NewProjectCreator(view.getProjectManager(), view.getWindow(), projectLoc, waitLock);
        Application.getWorker().submitForParallel(creator);
    }
View Full Code Here

Examples of org.jitterbit.ui.wait.WaitLock

        this.view = view;
    }

    @Override
    public void execute(ActionEvent e) {
        final WaitLock waitLock = view.getWindow().startWait();
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                startExport(waitLock);
View Full Code Here

Examples of org.jitterbit.ui.wait.WaitLock

    }

    private void loadNewProject(ApplicationWindow appWin, NewProjectDialog dialog) {
        boolean ok = dialog.open();
        if (ok) {
            WaitLock waitLock = appWin.startWait();
            Application.getWorker().submitForParallel(
                            new NewProjectCreator(projectManager, appWin, dialog.getProjectLocation(), waitLock));
        }
    }
View Full Code Here

Examples of org.zkoss.util.WaitLock

  }
  /** Returns an instance of richlet of the specified name, or null
   * if not found.
   */
  public Richlet getRichlet(String name) {
    WaitLock lock = null;
    final Object[] info;
    for (;;) {
      synchronized (_richlets) {
        Object o = _richlets.get(name);
        if (o == null || (o instanceof Richlet)) { //not found or loaded
          return (Richlet)o;
        } else if (o instanceof WaitLock) { //loading by another thread
          lock = (WaitLock)o;
        } else {
          info = (Object[])o;

          //going to load in this thread
          _richlets.put(name, lock = new WaitLock());
          break; //then, load it
        }
      } //sync(_richlets)

      if (!lock.waitUntilUnlock(300*1000)) { //5 minute
        final PotentialDeadLockException ex =
          new PotentialDeadLockException(
          "Unable to load richlet "+name+"\nCause: conflict too long.");
        log.warningBriefly(ex); //very rare, possibly a bug
        throw ex;
      }
    } //for (;;)

    //load it
    try {
      if (info[0] instanceof String) {
        try {
          info[0] = Classes.forNameByThread((String)info[0]);
        } catch (Throwable ex) {
          throw new UiException("Failed to load "+info[0]);
        }
      }

      final Object o = ((Class)info[0]).newInstance();
      if (!(o instanceof Richlet))
        throw new UiException(Richlet.class+" must be implemented by "+info[0]);

      final Richlet richlet = (Richlet)o;
      richlet.init(new RichletConfigImpl(_wapp, (Map)info[1]));

      synchronized (_richlets) {
        _richlets.put(name, richlet);
      }
      return richlet;
    } catch (Throwable ex) {
      synchronized (_richlets) {
        _richlets.put(name, info); //remove lock and restore info
      }
      throw UiException.Aide.wrap(ex, "Unable to instantiate "+info[0]);
    } finally {
      lock.unlock();
    }
  }
View Full Code Here

Examples of org.zkoss.util.WaitLock

  }

  //-- private utilities --//
  /** Returns Map(String key, String label) of the specified locale. */
  private final Map getLabels(Locale locale) {
    WaitLock lock = null;
    for (;;) {
      final Object o;
      synchronized (_labels) { 
        o = _labels.get(locale);
        if (o == null)
          _labels.put(locale, lock = new WaitLock()); //lock it
      }

      if (o instanceof Map)
        return (Map)o;
      if (o == null)
        break; //go to load the page

      //wait because some one is creating the servlet
      if (!((WaitLock)o).waitUntilUnlock(5*60*1000))
        log.warning("Take too long to wait loading labels: "+locale
          +"\nTry to load again automatically...");
    } //for(;;)

    if (_jarcharset == null)
      _jarcharset = Library.getProperty("org.zkoss.util.label.classpath.charset", "UTF-8");
    if (_warcharset == null) {
      _warcharset = Library.getProperty("org.zkoss.util.label.web.charset", null);
      if (_warcharset == null)
        _warcharset = Library.getProperty("org.zkoss.util.label.WEB-INF.charset", "UTF-8"); //backward compatible
    }

    try {
      //get the class name
      log.info("Loading labels for "+locale);
      final Map labels = new HashMap(512);

      //1. load from modules
      final ClassLocator locator = new ClassLocator();
      for (Enumeration en = locator.getResources(
        locale == null ? "metainfo/i3-label.properties":
        "metainfo/i3-label_" + locale + ".properties");
      en.hasMoreElements();) {
        final URL url = (URL)en.nextElement();
        load(labels, url, _jarcharset);
      }

      //2. load from extra resource
      for (Iterator it = _locators.iterator(); it.hasNext();) {
        final URL url = ((LabelLocator)it.next()).locate(locale);
        if (url != null)
          load(labels, url, _warcharset);
      }

      //add to map
      synchronized (_labels) {
        _labels.put(locale, labels);
      }

      return labels;
    } catch (Throwable ex) {
      synchronized (_labels) {
        _labels.remove(locale);
      }
      throw SystemException.Aide.wrap(ex);
    } finally {
      lock.unlock(); //unlock (always unlock to avoid deadlock)
    }
  }
View Full Code Here

Examples of org.zkoss.util.WaitLock

 
  //-- Map --//
  /** Returns the resource, or null if not found.
   */
  public Object get(Object src) {
    WaitLock lock = null;
    for (;;) {
      Info ri = null;
      synchronized (this) {
        Object o = super.get(src);
        if (o instanceof Info) { //was loaded
          ri = (Info)o;
        } else if (o instanceof WaitLock) {
          lock = (WaitLock)o;
        } else {
          super.put(src, lock = new WaitLock());
          break; //then, load it
        }
      } //sync(this)

      //check whether cached is valid
      if (ri != null) {
        synchronized (ri) {
          if (ri.isValid())
            return ri.getResource(); //reuse cached
        }
        //invalid, so remove it (if not updated by others)
        synchronized (this) {
          if (super.get(src) == ri) super.remove(src);
        }
      } else if (!lock.waitUntilUnlock(300*1000)) { //5 minute
        final PotentialDeadLockException ex =
          new PotentialDeadLockException(
          "Unable to load from "+src+"\nCause: conflict too long.");
        log.warningBriefly(ex); //very rare, possibly a bug
        throw ex;
      }
    } //for (;;)

    //load it
    try {
      boolean cache;
      final Info ri = new Info(src);
      Object resource = ri.getResource();

      if (resource instanceof Loader.Resource) {
        final Loader.Resource lr = (Loader.Resource)resource;
        resource = lr.resource;
        cache = lr.cacheable;
      } else
        cache = resource != null;

      synchronized (this) {
        if (cache) {
          super.put(src, ri);
        } else {
          super.remove(src); //remove lock
        }
      }

      return resource;
    } catch (Throwable ex) {
      synchronized (this) {
        super.remove(src); //remove lock
      }
      throw SystemException.Aide.wrap(ex);
    } finally {
      lock.unlock();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.