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.ComponentInfo; 15 import SOFA.SOFAnode.TR.Impl.BundleImpl; 16 17 21 public class InOut2InOutRMISkel extends UnicastRemoteObject implements CNInOut2InOutRemote, Linkable { 22 CNInOut2InOut target; 23 24 public InOut2InOutRMISkel (String url) throws RemoteException , java.net.MalformedURLException , java.rmi.NotBoundException { 25 super(); 26 String rmihost = System.getProperty("sofa.rmihost", "localhost"); 27 String rmiport = System.getProperty("sofa.rmiport", "1099"); 28 SOFA.SOFAnode.Run.DeplDockRegistry.RgRMIDock rg = (SOFA.SOFAnode.Run.DeplDockRegistry.RgRMIDock) java.rmi.Naming.lookup("//" + rmihost + ":" + rmiport + "/RgRMIDock"); 32 rg.rebind(url, this); 33 } 34 35 public void link (Object target) { 36 this.target = (CNInOut2InOut) target; 37 } 38 39 public byte[] pullBundle (ComponentInfo[] descs, ComponentInfo[] comps, boolean inferiors) throws RemoteException , InOutException { 40 BundleImpl bundle = (BundleImpl) target.pullBundle(descs, comps, inferiors); 41 byte[] ret = null; 42 try { 43 cz.cuni.sofa.lib.Impl.ByteArrayOutputStream os = new cz.cuni.sofa.lib.Impl.ByteArrayOutputStream(); 44 bundle._write(os); 45 os.close(); 46 ret = os.toByteArray(); 47 } catch (IOException e) { 48 throw new ConnectorTransportException("Can't serialize in the 'InOut2InOutRMISkel.pullBundle'.", e); 49 } 50 return ret; 51 } 52 53 public void pushBundle (byte[] bundleData) throws RemoteException , InOutException { 54 BundleImpl bundle = new BundleImpl(); 55 try { 56 bundle._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(bundleData)); 57 } catch (IOException e) { 58 throw new ConnectorTransportException("Can't serialize in the 'InOut2InOutRMISkel.pushBundle'.", e); 59 } 60 target.pushBundle(bundle); 61 } 62 } 63 | Popular Tags |