Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-11-30 16:57:28 +0000
committerslewis2008-11-30 16:57:28 +0000
commite3c1ea111b10b37379b23b4d9d75445b78a4d1ec (patch)
tree133df1d4d2c27e61f2e980aee1f1cfb3c557bd15 /framework/bundles/org.eclipse.ecf.remoteservice
parenta1c95d787249093fe55a80c1ce99669f9a92622d (diff)
downloadorg.eclipse.ecf-e3c1ea111b10b37379b23b4d9d75445b78a4d1ec.tar.gz
org.eclipse.ecf-e3c1ea111b10b37379b23b4d9d75445b78a4d1ec.tar.xz
org.eclipse.ecf-e3c1ea111b10b37379b23b4d9d75445b78a4d1ec.zip
Added utility class AbstractRemoteCallListener
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.remoteservice')
-rw-r--r--framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteCallListener.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteCallListener.java b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteCallListener.java
new file mode 100644
index 000000000..48ccec856
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.remoteservice/src/org/eclipse/ecf/remoteservice/AbstractRemoteCallListener.java
@@ -0,0 +1,67 @@
+package org.eclipse.ecf.remoteservice;
+
+import org.eclipse.ecf.remoteservice.events.*;
+
+/**
+ * Abstract implementer of IRemoteCallListener. This utility class may be used
+ * to simplify the implementation of IRemoteCallListener.
+ *
+ * @since 3.0
+ */
+public abstract class AbstractRemoteCallListener implements IRemoteCallListener {
+
+ protected IRemoteCall remoteCall;
+ protected IRemoteServiceReference remoteReference;
+
+ public void handleServiceEvent(IRemoteServiceEvent event) {
+ if (event instanceof IRemoteCallStartEvent)
+ this.handleRemoteCallStartEvent((IRemoteCallStartEvent) event);
+ else if (event instanceof IRemoteCallCompleteEvent)
+ this.handleRemoteCallCompleteEvent((IRemoteCallCompleteEvent) event);
+ }
+
+ protected IRemoteCall getRemoteCall() {
+ return remoteCall;
+ }
+
+ protected IRemoteServiceReference getRemoteServiceReference() {
+ return remoteReference;
+ }
+
+ protected void handleRemoteCallCompleteEvent(IRemoteCallCompleteEvent event) {
+ if (event.hadException())
+ handleRemoteCallException(event.getException());
+ else
+ handleRemoteCallComplete(event.getResponse());
+ // In either case, null out references
+ remoteCall = null;
+ remoteReference = null;
+ }
+
+ /**
+ * Handle remote call complete. If the remote call completes successfully,
+ * this method will then be called with the given result of the call passed
+ * as the parameter. If the remote call throws an exception, then {@link #handleRemoteCallException(Throwable)}
+ * will be called instead.
+ *
+ * @param result the result of the remote call. May be <code>null</code>.
+ * @see #handleRemoteCallException(Throwable)
+ */
+ protected abstract void handleRemoteCallComplete(Object result);
+
+ /**
+ * Handle remote call exception. If the remote call does not complete successfully,
+ * this method will be called with the Throwable exception that occurred. If
+ * it did complete successfully, then
+ *
+ * @param exception the Throwable that occurred during execution of the remote call.
+ * Will not be <code>null</code>.
+ */
+ protected abstract void handleRemoteCallException(Throwable exception);
+
+ protected void handleRemoteCallStartEvent(IRemoteCallStartEvent event) {
+ remoteCall = event.getCall();
+ remoteReference = event.getReference();
+ }
+
+}

Back to the top