/** * Sets the committed state of all context objects based on the marshaled context. * * @param marshaledContext The marshaled context to process. * @param callback Callback to report subscriber responses. */ public void setMarshaledContext(ContextItems marshaledContext, ISurveyCallback callback) { setMarshaledContext(marshaledContext, true, callback); }
/** * Sets the committed state of all context objects based on the marshaled context. * * @param marshaledContext The marshaled context to process. * @return Reason if context change rejected. */ public String setMarshaledContext(ContextItems marshaledContext) { return setMarshaledContext(marshaledContext, true); }
/** * 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(); } }
private void setMarshaledContext(ContextItems marshaledContext, Iterator<IManagedContext<?>> iter, ISurveyResponse response, ISurveyCallback callback) { if (iter.hasNext()) { IManagedContext<?> managedContext = iter.next(); try { if (managedContext.setContextItems(marshaledContext)) { localChangeBegin(managedContext); localChangeEnd(managedContext, true, true, aresponse -> { response.merge(aresponse); setMarshaledContext(marshaledContext, iter, response, callback); }); } } catch (Exception e) { log.error("Error processing marshaled context change.", e); response.reject(e.toString()); setMarshaledContext(marshaledContext, iter, response, callback); } } else { execCallback(callback, response); } }
/** * Updates managed contexts based on the marshaledContext. * * @param marshaledContext The marshaled context to process. * @param commit If true the pending contexts are committed. * @param callback Callback to report subscriber responses. */ /*package*/void setMarshaledContext(ContextItems marshaledContext, boolean commit, ISurveyCallback callback) { ISurveyResponse response = new SurveyResponse(); Iterator<IManagedContext<?>> iter = managedContexts.iterator(); setMarshaledContext(marshaledContext, iter, response, __ -> { if (commit) { commitContexts(!response.rejected(), false); } }); }
/** * 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(); }); }