Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-10-07 00:29:00 -0400
committerslewis2009-10-07 00:29:00 -0400
commitd9bc70473afcb051fbdd1b22fdb4aa57c22b837e (patch)
tree34a175bc72f8d53940d0b81c02225b9a00b707f8
parent52c0b738e2858204ac2f5c63193ada0f058b2341 (diff)
downloadorg.eclipse.ecf-d9bc70473afcb051fbdd1b22fdb4aa57c22b837e.tar.gz
org.eclipse.ecf-d9bc70473afcb051fbdd1b22fdb4aa57c22b837e.tar.xz
org.eclipse.ecf-d9bc70473afcb051fbdd1b22fdb4aa57c22b837e.zip
Added proxy throwing of ServiceException as defined by OSGi remote service spec.
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java65
1 files changed, 35 insertions, 30 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java
index ca972885a..0c9407598 100644
--- a/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java
+++ b/providers/bundles/org.eclipse.ecf.provider.r_osgi/src/org/eclipse/ecf/internal/provider/r_osgi/RemoteServiceImpl.java
@@ -21,6 +21,7 @@ import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent;
import org.eclipse.ecf.remoteservice.events.IRemoteCallStartEvent;
import org.eclipse.equinox.concurrent.future.*;
import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.ServiceException;
/**
* The R-OSGi adapter implementation of the IRemoteService interface.
@@ -172,40 +173,44 @@ final class RemoteServiceImpl implements IRemoteService, InvocationHandler {
}
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
- // methods declared by Object
-
- if (method.getName().equals("toString")) { //$NON-NLS-1$
- final String[] clazzes = refImpl.getR_OSGiServiceReference().getServiceInterfaces();
- String proxyClass = (clazzes.length == 1) ? clazzes[0] : Arrays.asList(clazzes).toString();
- return proxyClass + ".proxy@" + refImpl.getID(); //$NON-NLS-1$
- } else if (method.getName().equals("hashCode")) { //$NON-NLS-1$
- return new Integer(hashCode());
- } else if (method.getName().equals("equals")) { //$NON-NLS-1$
- if (args == null || args.length == 0)
- return Boolean.FALSE;
- try {
- return new Boolean(Proxy.getInvocationHandler(args[0]).equals(this));
- } catch (IllegalArgumentException e) {
- return Boolean.FALSE;
+ try {
+ // methods declared by Object
+ if (method.getName().equals("toString")) { //$NON-NLS-1$
+ final String[] clazzes = refImpl.getR_OSGiServiceReference().getServiceInterfaces();
+ String proxyClass = (clazzes.length == 1) ? clazzes[0] : Arrays.asList(clazzes).toString();
+ return proxyClass + ".proxy@" + refImpl.getID(); //$NON-NLS-1$
+ } else if (method.getName().equals("hashCode")) { //$NON-NLS-1$
+ return new Integer(hashCode());
+ } else if (method.getName().equals("equals")) { //$NON-NLS-1$
+ if (args == null || args.length == 0)
+ return Boolean.FALSE;
+ try {
+ return new Boolean(Proxy.getInvocationHandler(args[0]).equals(this));
+ } catch (IllegalArgumentException e) {
+ return Boolean.FALSE;
+ }
+ // This handles the use of IRemoteServiceProxy.getRemoteService method
+ } else if (method.getName().equals("getRemoteService")) { //$NON-NLS-1$
+ return this;
}
- // This handles the use of IRemoteServiceProxy.getRemoteService method
- } else if (method.getName().equals("getRemoteService")) { //$NON-NLS-1$
- return this;
- }
- return this.callSync(new IRemoteCall() {
+ return this.callSync(new IRemoteCall() {
- public String getMethod() {
- return method.getName();
- }
+ public String getMethod() {
+ return method.getName();
+ }
- public Object[] getParameters() {
- return args;
- }
+ public Object[] getParameters() {
+ return args;
+ }
- public long getTimeout() {
- return DEFAULT_TIMEOUT;
- }
- });
+ public long getTimeout() {
+ return DEFAULT_TIMEOUT;
+ }
+ });
+ } catch (Throwable t) {
+ // rethrow as service exception
+ throw new ServiceException("Service exception on remote service proxy rsid=" + refImpl.getID(), ServiceException.REMOTE, t); //$NON-NLS-1$
+ }
}
/**

Back to the top