Package org.zkoss.zk.ui.util

Examples of org.zkoss.zk.ui.util.Configuration


      throw new InternalError("Called without processing event?");
    if (_suspmutex == null)
      throw new InternalError("Resume non-suspended thread?");

    //Copy first since event thread clean up them, when completed
    final Configuration config =
      _proc.getDesktop().getWebApp().getConfiguration();
    final Component comp = getComponent();
    final Event event = getEvent();
    try {
      _evtThdResumes = config.newEventThreadResumes(comp, event);

      //Spec: locking mutex is optional for app developers
      //so we have to lock it first
      synchronized (_suspmutex) {
        _suspended = false;
View Full Code Here


    _timeZone = TimeZones.getCurrent();
    _ex = null;

    final EventProcessor proc = new EventProcessor(desktop, comp, event);
      //it also check the correctness of desktop/comp/event
    final Configuration config = desktop.getWebApp().getConfiguration();
    _evtThdInits = config.newEventThreadInits(comp, event);
    try {
      int evtTimeWarn = config.getEventTimeWarning();
      long begt = 0;
      if (evtTimeWarn > 0) {
        begt = System.currentTimeMillis();
        evtTimeWarn *= 1000;
      }
      for (;;) {
        synchronized (_evtmutex) {
          _proc = proc; //Bug 1577842: don't let event thread start (and end) too early

          _evtmutex.notify(); //ask the event thread to handle it
          if (_ceased == null) {
            if (evtTimeWarn > 0)
              _evtmutex.wait(evtTimeWarn);
            else
              _evtmutex.wait();
              //wait until the event thread to complete or suspended

            if (_suspended) {
              config.invokeEventThreadSuspends(_evtThdSuspends, comp, event);
              _evtThdSuspends = null;
              break;
            }
            if (_proc == null || _ceased != null)
              break;
View Full Code Here

  public void run() {
    ++_nThd;
    try {
      while (_ceased == null) {
        if (!isIdle()) {
          final Configuration config =
            _proc.getDesktop().getWebApp().getConfiguration();
          boolean cleaned = false;
          ++_nBusyThd;
          Execution exec = null;
          try {
//            if (log.finerable()) log.finer("Processing event: "+_proc);

            Locales.setThreadLocal(_locale);
            TimeZones.setThreadLocal(_timeZone);

            setup();
            exec = getExecution();
            if (exec != null) {
              ((ExecutionCtrl)exec).onActivate();
              _acted = true;
            }

            final boolean b = config.invokeEventThreadInits(
              _evtThdInits, getComponent(), getEvent());
            _evtThdInits = null;

            if (b) process0();
          } catch (Throwable ex) {
View Full Code Here

  /** @deprecated */
  public void setDelay(int min, int max, int factor) {
  }

  public void onPiggyback() {
    final Configuration config = _desktop.getWebApp().getConfiguration();
    long tmexpired = 0;
    for (int cnt = 0; !_pending.isEmpty();) {
      //Don't hold the client too long.
      //In addition, an ill-written code might activate again
      //before onPiggyback returns. It causes dead-loop in this case.
      if (tmexpired == 0) { //first time
        tmexpired = System.currentTimeMillis()
          + (config.getMaxProcessTime() >> 1);
        cnt = _pending.size() + 3;
      } else if (--cnt < 0 || System.currentTimeMillis() > tmexpired) {
        break;
      }

View Full Code Here

      }
    }

    init();

    final Configuration config = getWebApp().getConfiguration();
    config.invokeSessionInits(this, request); //it might throw exception

    final Monitor monitor = config.getMonitor();
    if (monitor != null) {
      try {
        monitor.sessionCreated(this);
      } catch (Throwable ex) {
        log.error(ex);
View Full Code Here

  public void onDestroyed() {
    SessionsCtrl.updateCount(false);

    _invalidated = _invalid = true;

    final Configuration config = getWebApp().getConfiguration();
    config.invokeSessionCleanups(this);

    cleanSessAttrs();

    final Monitor monitor = config.getMonitor();
    if (monitor != null) {
      try {
        monitor.sessionDestroyed(this);
      } catch (Throwable ex) {
        log.error(ex);
View Full Code Here

  }
  private static void desktopDestroyed(Desktop desktop) {
    final Session sess = desktop.getSession();
    final WebApp wapp = desktop.getWebApp();
    ((DesktopCtrl)desktop).invokeDesktopCleanups();
    final Configuration config = wapp.getConfiguration();
    config.invokeDesktopCleanups(desktop);
      //Feature 1767347: call DesktopCleanup before desktopDestroyed
      //such that app dev has a chance to manipulate the desktop
    ((WebAppCtrl)wapp).getUiEngine().desktopDestroyed(desktop);

    final Monitor monitor = desktop.getWebApp().getConfiguration().getMonitor();
    if (monitor != null) {
      try {
        monitor.desktopDestroyed(desktop);
      } catch (Throwable ex) {
        log.error(ex);
      }
    }

    final DesktopRecycle dtrc = config.getDesktopRecycle();
    if (dtrc != null) {
      try {
        dtrc.afterRemove(sess, desktop);
      } catch (Throwable ex) {
        log.error(ex);
View Full Code Here

  HttpServletRequest request, HttpServletResponse response, String path,
  boolean bRichlet)
  throws ServletException, IOException {
    final WebApp wapp = sess.getWebApp();
    final WebAppCtrl wappc = (WebAppCtrl)wapp;
    final Configuration config = wapp.getConfiguration();

    final boolean bInclude = Servlets.isIncluded(request);
    final boolean compress = _compress && !bInclude;
    final Writer out = compress ? (Writer)new StringWriter(): response.getWriter();
    final DesktopRecycle dtrc = bInclude ? null: config.getDesktopRecycle();
    Desktop desktop = dtrc != null ?
      Utils.beforeService(dtrc, _ctx, sess, request, response, path): null;

    try {
      if (desktop != null) { //recycle
        final Page page = Utils.getMainPage(desktop);
        if (page != null) {
          final Execution exec = new ExecutionImpl(
            _ctx, request, response, desktop, page);
          _webman.setDesktop(request, desktop);
          wappc.getUiEngine().recycleDesktop(exec, page, out);
        } else
          desktop = null; //something wrong (not possible; just in case)
      }
      if (desktop == null) {
        desktop = _webman.getDesktop(sess, request, response, path, true);
        if (desktop == null) //forward or redirect
          return true;

        final RequestInfo ri = new RequestInfoImpl(
          wapp, sess, desktop, request,
          PageDefinitions.getLocator(wapp, path));
        sess.setAttribute(Attributes.GAE_FIX, new Integer(0));
        ((SessionCtrl)sess).notifyClientRequest(true);

        final UiFactory uf = wappc.getUiFactory();
        if (uf.isRichlet(ri, bRichlet)) {
          final Richlet richlet = uf.getRichlet(ri, path);
          if (richlet == null)
            return false; //not found

          final Page page = WebManager.newPage(uf, ri, richlet, response, path);
          final Execution exec = new ExecutionImpl(
            _ctx, request, response, desktop, page);
          wappc.getUiEngine().execNewPage(exec, richlet, page, out);
            //no need to set device type here, since UiEngine will do it later
        } else {
          final PageDefinition pagedef = uf.getPageDefinition(ri, path);
          if (pagedef == null)
            return false; //not found

          final Page page = WebManager.newPage(uf, ri, pagedef, response, path);
          final Execution exec = new ExecutionImpl(
            _ctx, request, response, desktop, page);
          wappc.getUiEngine().execNewPage(exec, pagedef, page, out);
        }
      }

      if (compress) {
        final String result = ((StringWriter)out).toString();

        try {
          final OutputStream os = response.getOutputStream();
            //Call it first to ensure getWrite() is not called yet

          byte[] data = result.getBytes(config.getResponseCharset());
          if (data.length > 200) {
            byte[] bs = Https.gzip(request, response, null, data);
            if (bs != null) data = bs; //yes, browser support compress
          }
View Full Code Here

  public static final
  List getStyleSheets(Execution exec, WebApp wapp, String deviceType) {
    if (wapp == null) wapp = exec.getDesktop().getWebApp();
    if (deviceType == null) deviceType = exec.getDesktop().getDeviceType();

    final Configuration config = wapp.getConfiguration();
    final Set disabled = config.getDisabledThemeURIs();
    final List sses = new LinkedList(); //a list of StyleSheet
    for (Iterator it = LanguageDefinition.getByDeviceType(deviceType).iterator();
    it.hasNext();) {
      final LanguageDefinition langdef = (LanguageDefinition)it.next();
      for (Iterator e = langdef.getStyleSheets().iterator(); e.hasNext();) {
        final StyleSheet ss = (StyleSheet)e.next();
        if (!disabled.contains(ss.getHref()))
          sses.add(ss);
      }
    }

    //Process configuration
    final ThemeProvider themeProvider = config.getThemeProvider();
    if (themeProvider != null) {
      final List orgss = new LinkedList();
      for (Iterator it =  sses.iterator(); it.hasNext();) {
        final StyleSheet ss = (StyleSheet)it.next();
        final String href = ss.getHref();
        if (href != null && href.length() > 0)
          orgss.add(ss.getMedia() != null ? ss: (Object)href); //we don't support getContent
      }

      final String[] hrefs = config.getThemeURIs();
      for (int j = 0; j < hrefs.length; ++j)
        orgss.add(hrefs[j]);

      sses.clear();
      final Collection res = themeProvider.getThemeURIs(exec, orgss);
      if (res != null) {
        for (Iterator it = res.iterator(); it.hasNext();) {
          final Object re = it.next();
          sses.add(re instanceof StyleSheet ? (StyleSheet)re:
            new StyleSheet((String)re, "text/css"));
        }
      }
    } else {
      final String[] hrefs = config.getThemeURIs();
      for (int j = 0; j < hrefs.length; ++j)
        sses.add(new StyleSheet(hrefs[j], "text/css"));
    }
    return sses;
  }
View Full Code Here

    if (WebApps.getFeature("ee"))
      sb.append("ed:'e',");
    else if (WebApps.getFeature("pe"))
      sb.append("ed:'p',");

    final Configuration config = wapp.getConfiguration();
    int v = config.getProcessingPromptDelay();
    if (v != 900) sb.append("pd:").append(v).append(',');
    v = config.getTooltipDelay();
    if (v != 800) sb.append("td:").append(v).append(',');
    v = config.getResendDelay();
    if (v > 0) sb.append("rd:").append(v).append(',');
    v = config.getClickFilterDelay();
    if (v >= 0) sb.append("cd:").append(v).append(',');
    if (config.isTimerKeepAlive())
      sb.append("ta:1,");
    if (config.isDebugJS()) sb.append("dj:1,");
    if (config.isKeepDesktopAcrossVisits())
      sb.append("kd:1,");
    if (config.getPerformanceMeter() != null)
      sb.append("pf:1,");

    Object[][] infs = config.getClientErrorReloads("ajax", null);
    if (infs != null) {
      sb.append("eu:{");
      outErrReloads(config, sb, infs);
      sb.append("},");
    }
    infs = config.getClientErrorReloads("ajax", "server-push");
    if (infs != null) {
      sb.append("eup:{");
      outErrReloads(config, sb, infs);
      sb.append("},");
    }
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.util.Configuration

Copyright © 2018 www.massapicom. 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.