1 5 package SOFA.SOFAnode.InOut.Connector; 6 7 import java.io.IOException ; 8 import java.rmi.RemoteException ; 9 import java.rmi.server.UnicastRemoteObject ; 10 11 import SOFA.Connector.ConnectorTransportException; 12 import SOFA.Connector.Linkable; 13 import SOFA.SOFAnode.InOut.InOutException; 14 import SOFA.SOFAnode.TR.Impl.BundleImpl; 15 16 19 public class InOut2ClientRMISkel extends UnicastRemoteObject implements CNInOut2ClientRemote, Linkable { 20 CNInOut2Client target; 21 22 public InOut2ClientRMISkel (String url) throws RemoteException , java.net.MalformedURLException , java.rmi.NotBoundException { 23 super(); 24 String rmihost = System.getProperty("sofa.rmihost", "localhost"); 25 String rmiport = System.getProperty("sofa.rmiport", "1099"); 26 SOFA.SOFAnode.Run.DeplDockRegistry.RgRMIDock rg = (SOFA.SOFAnode.Run.DeplDockRegistry.RgRMIDock) java.rmi.Naming.lookup("//" + rmihost + ":" + rmiport + "/RgRMIDock"); 30 rg.rebind(url, this); 31 } 32 33 public void link (Object target) { 34 this.target = (CNInOut2Client) target; 35 } 36 37 47 public void obtain (String [] offers, String [] components, String sofaNode) throws RemoteException , InOutException { 48 target.obtain(offers, components, sofaNode); 49 } 50 51 public void distribute (String [] offers, String [] components, String [] sofaNodes) throws RemoteException , InOutException { 52 target.distribute(offers, components, sofaNodes); 53 } 54 55 public void obtainOffers (String [] offers, String sofaNode) throws RemoteException , InOutException { 56 target.obtainOffers(offers, sofaNode); 57 } 58 59 public void distributeOffers (String [] offers, String [] sofaNodes) throws RemoteException , InOutException { 60 target.distributeOffers(offers, sofaNodes); 61 } 62 63 public void obtainComponents (String [] components, String sofaNode) throws RemoteException , InOutException { 64 target.obtainComponents(components, sofaNode); 65 } 66 67 public void distributeComponents (String [] components, String [] sofaNodes) throws RemoteException , InOutException { 68 target.distributeComponents(components, sofaNodes); 69 } 70 71 public byte[] list () throws InOutException { 72 BundleImpl bundle = (BundleImpl) target.list(); 73 byte[] ret = null; 74 try { 75 cz.cuni.sofa.lib.Impl.ByteArrayOutputStream os = new cz.cuni.sofa.lib.Impl.ByteArrayOutputStream(); 76 bundle._write(os); 77 os.close(); 78 ret = os.toByteArray(); 79 } catch (IOException e) { 80 throw new ConnectorTransportException("Can't serialize in the 'InOut2ClientRMISkel.list'.", e); 81 } 82 return ret; 83 } 84 } 85 | Popular Tags |