diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java index 28f504be1ab..5bff4d2d26b 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java @@ -48,16 +48,16 @@ abstract public class Done extends DsfRunnable { /** * Convenience method which checks for error in done, and propagates it - * to caller's client done. + * to caller's client done. * @return Returns true if there was an error that was propagated and * the caller can stop processing result. */ - protected boolean propagateErrorToClient(DsfExecutor executor, Done clientDone, int code, String message) { + protected boolean propagateErrorToClient(DsfExecutor executor, Done clientDone, String message) { if (clientDone.getStatus().getSeverity() == IStatus.CANCEL) { return true; } if (!getStatus().isOK()) { - clientDone.setErrorStatus(DsfPlugin.PLUGIN_ID, code, message, getStatus()); + clientDone.setErrorStatus(DsfPlugin.PLUGIN_ID, getStatus().getCode(), message, getStatus()); executor.execute(clientDone); return true; } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfQuery.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfQuery.java index bf26e3f77d4..b944df7bb09 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfQuery.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfQuery.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.dd.dsf.DsfPlugin; +import org.eclipse.dd.dsf.service.IDsfService; /** * A convenience class that allows a client to retrieve data from services @@ -83,7 +84,7 @@ abstract public class DsfQuery { wait(); } } catch (InterruptedException e) { - fStatus = new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, + fStatus = new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "Interrupted exception while waiting for result.", e); fValid = true; } @@ -153,7 +154,7 @@ abstract public class DsfQuery { public synchronized void doneException(Throwable t) { if (fValid) return; - doneError(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, + doneError(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "Exception while computing result.", t)); } } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDoneWithClientDone.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDoneWithClientDone.java deleted file mode 100644 index a05877f1168..00000000000 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/GetDataDoneWithClientDone.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ -package org.eclipse.dd.dsf.concurrent; - -import org.eclipse.core.runtime.IStatus; - -/** - * Convenience extension to GetDataDone, which handles posting of the client's - * Done upon the completion of this GetDataDone. - * @param Class type of data. - * @deprecated This class has been replaced with the - * {@link Done#propagateErrorToClient(DsfExecutor, Done, int, String)} - * method. - */ -public abstract class GetDataDoneWithClientDone extends GetDataDone { - private DsfExecutor fExecutor; - private Done fClientDone; - - /** - * Constructor requires the Done to be posted as well as the executor to - * post it with. - */ - public GetDataDoneWithClientDone(DsfExecutor executor, Done clientDone) { - fExecutor = executor; - fClientDone = clientDone; - } - - /** - * The run method checks the client done for cancellation, and this done - * for errors. It calls doRun() for the sub-class execution, and posts - * the client done when finished. - */ - public final void run() { - if (fClientDone.getStatus().getSeverity() == IStatus.CANCEL) return; - if (!getStatus().isOK()) { - fClientDone.setStatus(getStatus()); - } else { - doRun(); - } - fExecutor.execute(fClientDone); - } - - /** - * Method to perform the actual work. It should not post the client done - * because it will be posted by this class in run(). - */ - protected abstract void doRun(); -} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java index 7f5b867504d..fc20317d3fb 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java @@ -261,9 +261,10 @@ public class DsfSession * @param serviceProperties properties of the service requesting the event to be dispatched */ public void dispatchEvent(final Object event, final Dictionary serviceProperties) { - getExecutor().submit(new DsfRunnable() { public void run() { - doDispatchEvent(event, serviceProperties); - }}); + getExecutor().submit(new DsfRunnable() { + public void run() { doDispatchEvent(event, serviceProperties);} + public String toString() { return "Event: " + event + ", from service " + serviceProperties; } + }); } /** diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java index b7f06f75db7..3b62dea946a 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java @@ -40,7 +40,38 @@ public interface IDsfService { * Property name for the session-id of this service. This property should be set by * all DSF services when they are registered with OSGI service framework. */ - static String PROP_SESSION_ID = "org.eclipse.dd.dsf.service.IService.session_id"; + final static String PROP_SESSION_ID = "org.eclipse.dd.dsf.service.IService.session_id"; + + /** + * Error code indicating that the service is in a state which does not allow the + * request to be processed. For example if the client requested target information + * after target was disconnected. + */ + final static int INVALID_STATE = 10001; + + /** + * Error code indicating that client supplied an invalid handle to the service. + * A handle could become invalid after an object it represents is removed from + * the system. + */ + final static int INVALID_HANDLE = 10002; + + /** + * Error code indicating that the client request is not supported/implemented. + */ + final static int NOT_SUPPORTED = 10003; + + /** + * Error code indicating that the request to a sub-service or an external process + * failed. + */ + final static int REQUEST_FAILED = 10004; + + /** + * Error code indicating an unexpected condition in the service, i.e. programming error. + */ + final static int INTERNAL_ERROR = 10005; + /** * Returns the executor that should be used to call methods of this service.