Search in sources :

Example 1 with ResultCache

use of edu.stanford.bmir.protege.web.client.dispatch.cache.ResultCache in project webprotege by protegeproject.

the class DispatchServiceManager method getResultCache.

private ResultCache getResultCache(ProjectId projectId, EventBus eventBus) {
    ResultCache resultCache = resultCacheMap.get(projectId);
    if (resultCache == null) {
        resultCache = new ResultCache(projectId, eventBus);
        resultCacheMap.put(projectId, resultCache);
    }
    return resultCache;
}
Also used : ResultCache(edu.stanford.bmir.protege.web.client.dispatch.cache.ResultCache)

Example 2 with ResultCache

use of edu.stanford.bmir.protege.web.client.dispatch.cache.ResultCache in project webprotege by protegeproject.

the class DispatchServiceManager method execute.

@SuppressWarnings("unchecked")
public <A extends Action<R>, R extends Result> void execute(A action, final DispatchServiceCallback<R> callback) {
    callback.handleSubmittedForExecution();
    if (action instanceof HasProjectId) {
        ProjectId projectId = ((HasProjectId) action).getProjectId();
        ResultCache resultCache = getResultCache(projectId, eventBus);
        Optional<R> result = resultCache.getCachedResult(action);
        if (result.isPresent()) {
            callback.onSuccess(result.get());
            return;
        }
    }
    requestCount++;
    GWT.log("[Dispatch] Executing action " + requestCount + "    " + action.getClass().getSimpleName());
    async.executeAction(action, new AsyncCallbackProxy(action, callback));
}
Also used : HasProjectId(edu.stanford.bmir.protege.web.shared.project.HasProjectId) ResultCache(edu.stanford.bmir.protege.web.client.dispatch.cache.ResultCache) HasProjectId(edu.stanford.bmir.protege.web.shared.project.HasProjectId) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId)

Aggregations

ResultCache (edu.stanford.bmir.protege.web.client.dispatch.cache.ResultCache)2 HasProjectId (edu.stanford.bmir.protege.web.shared.project.HasProjectId)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1