00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.body.ibis;
00032
00033 import org.objectweb.proactive.core.ProActiveException;
00034 import org.objectweb.proactive.core.body.BodyAdapterImpl;
00035 import org.objectweb.proactive.core.body.UniversalBody;
00036 import org.objectweb.proactive.core.util.UrlBuilder;
00037
00038
00047 public class IbisBodyAdapter extends BodyAdapterImpl {
00048
00049
00050
00051 public IbisBodyAdapter() {
00052 }
00053
00054 public IbisBodyAdapter(IbisRemoteBody remoteBody) throws ProActiveException {
00055 construct(remoteBody);
00056 }
00057
00058 public IbisBodyAdapter(UniversalBody body) throws ProActiveException {
00059 try {
00060 IbisRemoteBody remoteBody = new IbisRemoteBodyImpl(body);
00061 construct(remoteBody);
00062 } catch (ibis.rmi.RemoteException e) {
00063 throw new ProActiveException(e);
00064 }
00065 }
00066
00067
00068
00069
00070
00078 public void register(String url) throws java.io.IOException {
00079 ibis.rmi.Naming.rebind(url, (IbisRemoteBody) proxiedRemoteBody);
00080 }
00081
00087 public void unregister(String url) throws java.io.IOException {
00088 try {
00089 ibis.rmi.Naming.unbind(url);
00090 } catch (ibis.rmi.NotBoundException e) {
00091 throw new java.io.IOException(
00092 "No object is bound to the given url : " + url);
00093 }
00094 }
00095
00105 public UniversalBody lookup(String url) throws java.io.IOException {
00106 Object o = null;
00107
00108
00109 try {
00110 o = ibis.rmi.Naming.lookup(UrlBuilder.removeProtocol(url, "ibis:"));
00111 } catch (ibis.rmi.NotBoundException e) {
00112 throw new java.io.IOException("The url " + url +
00113 " is not bound to any known object");
00114 }
00115
00116 if (o instanceof IbisRemoteBody) {
00117 try {
00118 construct((IbisRemoteBody) o);
00119 } catch (ProActiveException e1) {
00120 throw new java.io.IOException(
00121 "The remote object at " + url + " is not accessible ");
00122 }
00123
00124 return this;
00125 } else {
00126 throw new java.io.IOException(
00127 "The given url does exist but doesn't point to a remote body url=" +
00128 url + " class found is " + o.getClass().getName());
00129 }
00130 }
00131 }