Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-09-12 01:22:16 -0400
committerslewis2007-09-12 01:22:16 -0400
commit37e9d077ebd985a5cfd906f629b5c5823339a97b (patch)
tree27345128ae1b71ddaa58325bd744020db931dbd5
parent0ca5ace45aa7c76d6edabb231e5bd58d20d3d6a5 (diff)
downloadorg.eclipse.ecf-37e9d077ebd985a5cfd906f629b5c5823339a97b.tar.gz
org.eclipse.ecf-37e9d077ebd985a5cfd906f629b5c5823339a97b.tar.xz
org.eclipse.ecf-37e9d077ebd985a5cfd906f629b5c5823339a97b.zip
Changed name of AsynchResult to AsyncResult. Abstracted public API for AsyncResult to IAsyncResult. Added method to IRemoteService.callAsynch that returns IAsyncResult. Implemented new method in org.eclipse.ecf.provider.remoteservice. Added test case for testing new API.
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java39
1 files changed, 29 insertions, 10 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java
index d6a631aeb..24e25851c 100644
--- a/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.remoteservice/src/org/eclipse/ecf/provider/remoteservice/generic/RemoteServiceImpl.java
@@ -12,10 +12,14 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import org.eclipse.ecf.core.util.AsyncResult;
import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.core.util.IAsyncResult;
import org.eclipse.ecf.remoteservice.IRemoteCall;
import org.eclipse.ecf.remoteservice.IRemoteCallListener;
import org.eclipse.ecf.remoteservice.IRemoteService;
+import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent;
+import org.eclipse.ecf.remoteservice.events.IRemoteCallEvent;
public class RemoteServiceImpl implements IRemoteService, InvocationHandler {
@@ -25,8 +29,7 @@ public class RemoteServiceImpl implements IRemoteService, InvocationHandler {
protected RegistrySharedObject sharedObject = null;
- public RemoteServiceImpl(RegistrySharedObject sharedObject,
- RemoteServiceRegistrationImpl registration) {
+ public RemoteServiceImpl(RegistrySharedObject sharedObject, RemoteServiceRegistrationImpl registration) {
this.sharedObject = sharedObject;
this.registration = registration;
}
@@ -35,6 +38,26 @@ public class RemoteServiceImpl implements IRemoteService, InvocationHandler {
sharedObject.sendCallRequestWithListener(registration, call, listener);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.remoteservice.IRemoteService#callAsynch(org.eclipse.ecf.remoteservice.IRemoteCall)
+ */
+ public IAsyncResult callAsynch(IRemoteCall call) {
+ final AsyncResult result = new AsyncResult();
+ final IRemoteCallListener listener = new IRemoteCallListener() {
+ public void handleEvent(IRemoteCallEvent event) {
+ if (event instanceof IRemoteCallCompleteEvent) {
+ IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
+ if (cce.hadException())
+ result.setException(cce.getException());
+ else
+ result.set(cce.getResponse());
+ }
+ }
+ };
+ callAsynch(call, listener);
+ return result;
+ }
+
public Object callSynch(IRemoteCall call) throws ECFException {
return sharedObject.callSynch(registration, call);
}
@@ -47,21 +70,17 @@ public class RemoteServiceImpl implements IRemoteService, InvocationHandler {
Object proxy;
try {
// Get clazz from reference
- final RemoteServiceReferenceImpl reference = (RemoteServiceReferenceImpl) registration
- .getReference();
+ final RemoteServiceReferenceImpl reference = (RemoteServiceReferenceImpl) registration.getReference();
final String clazz = reference.getRemoteClass();
final Class loadedClass = Class.forName(clazz);
- proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(),
- new Class[] { loadedClass }, this);
+ proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {loadedClass}, this);
} catch (final Exception e) {
- throw new ECFException(
- "Exception creating proxy for remote service", e);
+ throw new ECFException("Exception creating proxy for remote service", e);
}
return proxy;
}
- public Object invoke(Object proxy, final Method method, final Object[] args)
- throws Throwable {
+ public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
return this.callSynch(new IRemoteCall() {
public String getMethod() {

Back to the top