/** * Returns the desktop from the given websocket session. * * @param wsession websocket session * @return a desktop, null if desktop not found */ public static Desktop getDesktop(Session wsession) { org.zkoss.zk.ui.Session session = (org.zkoss.zk.ui.Session) wsession.getUserProperties() .get(ZKWebSocket.class.getName()); if (session == null) throw new IllegalStateException("ZK Session cannot be null!"); List<String> dtids = wsession.getRequestParameterMap().get("dtid"); if (dtids.isEmpty()) throw new IllegalStateException("the value of the key with 'dtid' cannot be null!"); DesktopCache desktopCache = ((SessionCtrl) session).getDesktopCache(); return desktopCache != null ? desktopCache.getDesktopIfAny(dtids.get(0)) : null; } }
public void setId(String id) { if (!((ExecutionCtrl) _exec).isRecovering()) throw new IllegalStateException("Callable only in recovring"); if (id == null || id.length() <= 1 || id.charAt(0) != 'g') throw new IllegalArgumentException( "Invalid desktop ID. You have to recover to the original value, not creating a new value: " + id); //_sess and dc are null if in a working thread final DesktopCache dc = _sess != null ? ((WebAppCtrl) _wapp).getDesktopCache(_sess) : null; if (dc != null) dc.removeDesktop(this); _id = id; updateUuidPrefix(); if (dc != null) dc.addDesktop(this); }
private static String nextDesktopId(DesktopCache dc) { if (dc != null) return ComponentsCtrl.encodeId(new StringBuffer(12).append(DESKTOP_ID_PREFIX), dc.getNextKey()).toString(); final int v; synchronized (DesktopImpl.class) { v = _keyWithoutDC++; } return ComponentsCtrl.encodeId(new StringBuffer(12).append("_g"), v).toString(); }
/** Returns the desktop of the given desktop ID, or null if not found. * @param dtid the desktop's ID. */ public static Desktop getDesktop(ServletContext svlctx, HttpServletRequest request, String dtid) { return ((WebAppCtrl) WebManager.getWebApp(svlctx)).getDesktopCache(WebManager.getSession(svlctx, request)) .getDesktop(dtid); }
/** Invokes {@link #getDesktopCache}'s {@link DesktopCache#sessionDidActivate}. */ public void sessionDidActivate(Session sess) { DesktopCache dc = (DesktopCache) sess.getAttribute(ATTR_CACHE); if (dc != null) dc.sessionDidActivate(sess); }
/** Invokes {@link #getDesktopCache}'s {@link DesktopCache#sessionWillPassivate}. */ public void sessionWillPassivate(Session sess) { final DesktopCache dc = ((SessionCtrl) sess).getDesktopCache(); if (dc != null) dc.sessionWillPassivate(sess); }
public void stop(WebApp wapp) { DesktopCache dc = (DesktopCache) wapp.getAttribute(ATTR_CACHE); if (dc != null) { wapp.removeAttribute(ATTR_CACHE); dc.stop(); } } }
public void recoverDidFail(Throwable ex) { ((WebAppCtrl) _wapp).getDesktopCache(_sess).removeDesktop(this); }
dc.addDesktop(this); //add to cache after invokeDesktopInits
alert = "dtid is required!"; } else { desktop = ((WebAppCtrl) sess.getWebApp()).getDesktopCache(sess).getDesktop(dtid); final Map<String, Object> params = parseRequest(request, desktop, ""); nextURI = (String) params.get("nextURI");
/** Invokes {@link #getDesktopCache}'s {@link DesktopCache#sessionDidActivate}. */ public void sessionDidActivate(Session sess) { final DesktopCache dc = ((SessionCtrl) sess).getDesktopCache(); if (dc != null) dc.sessionDidActivate(sess); }
/** Invokes {@link #getDesktopCache}'s {@link DesktopCache#sessionWillPassivate}. */ public void sessionWillPassivate(Session sess) { DesktopCache dc = (DesktopCache) sess.getAttribute(ATTR_CACHE); if (dc != null) dc.sessionWillPassivate(sess); }
public void sessionDestroyed(Session sess) { final SessionCtrl sessCtrl = (SessionCtrl) sess; final DesktopCache dc = sessCtrl.getDesktopCache(); if (dc != null) { sessCtrl.setDesktopCache(null); dc.stop(); } }
/** Called to remove the desktop. * If {@link DesktopRecycle} is configured, {@link DesktopRecycle#beforeRemove} * will be called first to see if it shall be recycled. * @return whether the desktop is removed. Returns false if the desktop * is recycled. */ public static boolean removeDesktop(Execution exec) { final Desktop dt = exec.getDesktop(); final WebApp wapp = dt.getWebApp(); final DesktopRecycle dtrc = wapp.getConfiguration().getDesktopRecycle(); if (dtrc != null) { try { if (dtrc.beforeRemove(exec, dt, 0)) { ((DesktopCtrl) dt).recycle(); return false; //recycled } } catch (Throwable ex) { log.error("", ex); } } ((WebAppCtrl) wapp).getDesktopCache(dt.getSession()).removeDesktop(dt); return true; } }
sid = escapeParam(request.getParameter("sid")); desktop = ((WebAppCtrl) sess.getWebApp()).getDesktopCache(sess) .getDesktop(XMLs.encodeText(request.getParameter("dtid"))); alert = "dtid is required!"; } else { desktop = ((WebAppCtrl) sess.getWebApp()).getDesktopCache(sess).getDesktop(dtid); final Map<String, Object> params = parseRequest(request, desktop, uuid + '_' + sid); nextURI = (String) params.get("nextURI");
/** Returns the desktop of the specified ID, or null if not found. * If null is returned, {@link #recoverDesktop} will be invoked. * @param sess the session (never null) * @param dtid the desktop ID to look for * @since 5.0.3 */ protected Desktop getDesktop(Session sess, String dtid) { return ((WebAppCtrl) sess.getWebApp()).getDesktopCache(sess).getDesktopIfAny(dtid); }
final WebAppCtrl wappc = (WebAppCtrl) wapp; final UiEngine uieng = wappc.getUiEngine(); final Desktop desktop = wappc.getDesktopCache(sess).getDesktop(dtid); final DesktopCtrl desktopCtrl = (DesktopCtrl) desktop;
.getDesktopCache(sess).getDesktopIfAny(dtid); if (desktop == null) { response.setHeader("ZK-Comet-Error", "Desktop not found, "+dtid);