Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.Execution


  }
  public boolean unsubscribe(EventListener listener) {
    if (listener == null)
      throw new IllegalArgumentException();

    final Execution exec = Executions.getCurrent();
    if (exec == null)
      throw new IllegalStateException("execution required");

    final Desktop desktop = exec.getDesktop();
    synchronized (_dts) {
      final DesktopThread dtthd = (DesktopThread)_dts.get(desktop);
      if (dtthd != null && dtthd.unsubscribe(listener)) {
        if (dtthd.isIdle()) {
          dtthd.cease();
View Full Code Here


      Threads.setDaemon(this, true);
      _desktop = desktop;
    }
    private void publish(Event event) {
      if (!_ceased) {
        final Execution exec = Executions.getCurrent();
        if (exec != null && exec.getDesktop() == _desktop) {
          //same desktop no need of working thread
          List evts = new LinkedList();
          synchronized (_mutex) {
            evts.addAll(_evts);
            _evts.clear();
View Full Code Here

      _spEnabled = true;
      _desktop.enableServerPush(true);
    }
    private void disableServerPush() {
      if (_spEnabled) {
        final Execution exec = Executions.getCurrent();
        if (exec != null && exec.getDesktop() == _desktop) {
          _spEnabled = false;

          if (_desktop.isAlive())
            try {
              _desktop.enableServerPush(false);
View Full Code Here

  /** The attribute used to store the map of event queues.
   */
  protected static final String ATTR_EVENT_QUEUES = "org.zkoss.zk.ui.event.eventQueues";

  public EventQueue lookup(String name, String scope, boolean autoCreate) {
    final Execution exec = Executions.getCurrent();
    if (exec == null)
      throw new IllegalStateException("Not in an execution");

    final boolean bAppScope = EventQueues.APPLICATION.equals(scope);
    if (bAppScope || EventQueues.SESSION.equals(scope)) {
      return lookup0(name, bAppScope ?
        (Scope)exec.getDesktop().getWebApp(): exec.getSession(), autoCreate);
    } else  if (EventQueues.DESKTOP.equals(scope)) {
      final Desktop desktop = exec.getDesktop();
      Map eqs = (Map)desktop.getAttribute(ATTR_EVENT_QUEUES);
      if (eqs == null)
        desktop.setAttribute(ATTR_EVENT_QUEUES, eqs = new HashMap(4));

      EventQueue eq = (EventQueue)eqs.get(name);
View Full Code Here

        eqs.put(name, eq = new ServerPushEventQueue());
    }
    return eq;
  }
  public boolean remove(String name, String scope) {
    final Execution exec = Executions.getCurrent();
    if (exec == null)
      throw new IllegalStateException("Not in an execution");

    if (EventQueues.DESKTOP.equals(scope))
      return remove0(name, exec.getDesktop());
    if (EventQueues.APPLICATION.equals(scope))
      return remove0(name, exec.getDesktop().getWebApp());
    if (EventQueues.SESSION.equals(scope))
      return remove0(name, exec.getSession());
    return false;
  }
View Full Code Here

        return rootNode;
    }

    private void getClientInfo() {
        Execution exec = getDesktop().getExecution();
        String clientIP = exec.getRemoteAddr();
        Sessions.getCurrent().setAttribute("clientIp", clientIP);
        System.out.println("----------->>>" + clientIP);
    }
View Full Code Here

*/
public class DesktopScope implements Scope {
  private static final String DESKTOP_SCOPE = "ZK_SPRING_DESKTOP_SCOPE";

  public Object get(String name, ObjectFactory<?> objectFactory) {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      final Desktop desktop = exec.getDesktop();
      Map desktopScope = (Map) desktop.getAttribute(DESKTOP_SCOPE);
      if (desktopScope == null) {
        desktop.setAttribute(DESKTOP_SCOPE, desktopScope = new HashMap());
      }
      Object scopedObject = desktopScope.get(name);
View Full Code Here

    }
    throw new IllegalStateException("Unable to get desktop scope bean: "+name+". Do you access it in ZK event listener?");
  }

  public String getConversationId() {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      final Desktop desktop = exec.getDesktop();
      if (desktop != null) {
        return desktop.getId();
      }
    }
    return null;
View Full Code Here

  public void registerDestructionCallback(String name, Runnable callback) {
    // do nothing
  }

  public Object remove(String name) {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      final Desktop desktop = exec.getDesktop();
      final Map desktopScope = (Map) desktop.getAttribute(DESKTOP_SCOPE);
      return (desktopScope != null) ? desktopScope.remove(name) : null;
    }
    throw new IllegalStateException("Unable to get desktop scope bean: "+name+". Do you access it in ZK event listener?");
  }
View Full Code Here

*/
public class ExecutionScope implements Scope {
  private static final String EXEC_SCOPE = "ZK_SPRING_EXEC_SCOPE";
 
  public Object get(String name, ObjectFactory<?> objectFactory) {
    final Execution exec = Executions.getCurrent();
    if (exec != null) {
      Map execScope = (Map) exec.getAttribute(EXEC_SCOPE);
      if (execScope == null) {
        ZKProxy.getProxy().setAttribute(exec, EXEC_SCOPE, execScope = new HashMap());
      }
      Object scopedObject = execScope.get(name);
      if (scopedObject == null) {
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.Execution

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.