/** * Checks if a CCOW context manager is active. * * @return True if CCOW context management is active. */ private boolean ccowIsActive() { return ccowContextManager != null && ccowContextManager.isActive(); }
/** * Joins the CCOW common context, if available. */ public void ccowJoin() { if (ccowIsActive()) { return; } if (ccowContextManager == null && ccowEnabled) { ccowContextManager = new CCOWContextManager(); ccowContextManager.subscribe(this); ccowContextManager.run("CareWebFramework#", "", true, "*"); } if (ccowContextManager != null) { if (!ccowContextManager.isActive()) { ccowContextManager.resume(); } init(response -> { if (response.rejected()) { ccowContextManager.suspend(); } updateCCOWStatus(); }); } }
/** * Returns true if actively participating in the CCOW context. * * @return True if actively participating. */ public boolean isActive() { return getState() == CCOWState.csParticipating; }
/** * Enables or disables CCOW support. * * @param ccowEnabled True enables CCOW support if it is available. */ public void setCCOWEnabled(boolean ccowEnabled) { this.ccowEnabled = ccowEnabled; if (!ccowEnabled && ccowContextManager != null) { ccowContextManager.suspend(); ccowContextManager = null; } updateCCOWStatus(); }
/** * Callback to handle a polling request from the CCOW context manager. */ @Override public void ccowPending(CCOWContextManager sender, ContextItems contextItems) { try { ccowTransaction = true; updateCCOWStatus(); String reason = setMarshaledContext(contextItems, false); if (!reason.isEmpty()) { sender.setSurveyResponse(reason.toString()); } } finally { ccowTransaction = false; updateCCOWStatus(); } }
/** * Initializes one or all managed contexts to their default state. * * @param item Managed context to initialize or, if null, initializes all managed contexts. * @param callback Callback to report subscriber responses. */ public void init(IManagedContext<?> item, ISurveyCallback callback) { contextItems.clear(); if (ccowIsActive()) { contextItems.addItems(ccowContextManager.getCCOWContext()); } if (item != null) { initItem(item, callback); } else { SurveyResponse response = new SurveyResponse(); initItem(managedContexts.iterator(), response, callback); } }
/** * Joins the CCOW common context, if available. * * @return True if the operation was successful. */ public boolean ccowJoin() { if (ccowIsActive()) { return true; } if (ccowContextManager == null && ccowEnabled) { ccowContextManager = new CCOWContextManager(); ccowContextManager.subscribe(this); ccowContextManager.run("CareWebFramework#", "", true, "*"); } if (ccowContextManager != null) { if (!ccowContextManager.isActive()) { ccowContextManager.resume(); } if (!init()) { ccowContextManager.suspend(); } } updateCCOWStatus(); return ccowIsActive(); }
/** * Returns true if actively participating in the CCOW context. * * @return True if actively participating. */ public boolean isActive() { return getState() == CCOWState.csParticipating; }
/** * Enables or disables CCOW support. * * @param ccowEnabled True enables CCOW support if it is available. */ public void setCCOWEnabled(boolean ccowEnabled) { this.ccowEnabled = ccowEnabled; if (!ccowEnabled && ccowContextManager != null) { ccowContextManager.suspend(); ccowContextManager = null; } updateCCOWStatus(); }
/** * Callback to handle a polling request from the CCOW context manager. */ @Override public void ccowPending(CCOWContextManager sender, ContextItems contextItems) { ccowTransaction = true; updateCCOWStatus(); setMarshaledContext(contextItems, false, response -> { if (response.rejected()) { sender.setSurveyResponse(response.toString()); } ccowTransaction = false; updateCCOWStatus(); }); }
/** * Initializes one or all managed contexts to their default state. * * @param item Managed context to initialize or, if null, initializes all managed contexts. * @return True if the operation was successful. */ public boolean init(IManagedContext item) { contextItems.clear(); boolean result = true; if (ccowIsActive()) { contextItems.addItems(ccowContextManager.getCCOWContext()); } if (item != null) { result = initItem(item); } else { for (IManagedContext managedContext : managedContexts) { result &= initItem(managedContext); } } return result; }
/** * Returns the current status of the CCOW common context. Return values correspond to possible * states of the standard CCOW status icon. * * @return Status of the CCOW common context. */ private CCOWStatus getCCOWStatus() { if (ccowContextManager == null) { return ccowEnabled ? CCOWStatus.NONE : CCOWStatus.DISABLED; } else if (ccowTransaction) { return CCOWStatus.CHANGING; } else { switch (ccowContextManager.getState()) { case csParticipating: return CCOWStatus.JOINED; case csSuspended: return CCOWStatus.BROKEN; default: return CCOWStatus.NONE; } } }
/** * Checks if a CCOW context manager is active. * * @return True if CCOW context management is active. */ private boolean ccowIsActive() { return ccowContextManager != null && ccowContextManager.isActive(); }
/** * Returns the current status of the CCOW common context. Return values correspond to possible * states of the standard CCOW status icon. * * @return Status of the CCOW common context. */ private CCOWStatus getCCOWStatus() { if (ccowContextManager == null) { return ccowEnabled ? CCOWStatus.none : CCOWStatus.disabled; } else if (ccowTransaction) { return CCOWStatus.changing; } else { switch (ccowContextManager.getState()) { case csParticipating: return CCOWStatus.joined; case csSuspended: return CCOWStatus.broken; default: return CCOWStatus.none; } } }