/** 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);