1 5 package SOFA.SOFAnode.TR.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.TR.ComponentInfo; 14 import SOFA.SOFAnode.TR.TRException; 15 import SOFA.SOFAnode.TR.Impl.BundleImpl; 16 17 20 public class TR2InOutRMISkel extends UnicastRemoteObject implements CNTR2InOutRemote, Linkable { 21 private CNTR2InOut target; 22 23 public TR2InOutRMISkel (String url) throws java.rmi.RemoteException , java.net.MalformedURLException , java.rmi.NotBoundException { 24 super(); 25 String rmihost = System.getProperty("sofa.rmihost", "localhost"); 26 String rmiport = System.getProperty("sofa.rmiport", "1099"); 27 SOFA.SOFAnode.Run.DeplDockRegistry.RgRMIDock rg = (SOFA.SOFAnode.Run.DeplDockRegistry.RgRMIDock) java.rmi.Naming.lookup("//" + rmihost + ":" + rmiport + "/RgRMIDock"); 31 rg.rebind(url, this); 32 } 33 34 public void link (Object target) { 35 this.target = (CNTR2InOut) target; 36 } 37 38 public void storeBundle (byte[] bundleData) throws RemoteException , TRException { 39 BundleImpl bundle = new BundleImpl(); 40 try { 41 bundle._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(bundleData)); 42 } catch (IOException e) { 43 throw new ConnectorTransportException("Can't serialize in the 'storeBundle'.", e); 44 } 45 target.storeBundle(bundle); 46 } 47 48 public byte[] getBundle (ComponentInfo[] descs, ComponentInfo[] comps, boolean inferiors) throws RemoteException , TRException { 49 BundleImpl bundle = (BundleImpl) target.getBundle(descs, comps, inferiors); 50 byte[] ret = null; 51 try { 52 cz.cuni.sofa.lib.Impl.ByteArrayOutputStream os = new cz.cuni.sofa.lib.Impl.ByteArrayOutputStream(); 53 bundle._write(os); 54 os.close(); 55 ret = os.toByteArray(); 56 } catch (IOException e) { 57 throw new ConnectorTransportException("Can't serialize in the 'getBundle'.", e); 58 } 59 return ret; 60 } 61 62 68 public boolean contains (ComponentInfo descrs) throws RemoteException { 69 return target.contains(descrs); 70 } 71 72 public byte[] list () { 73 BundleImpl bundle = (BundleImpl) target.list(); 74 byte[] ret = null; 75 try { 76 cz.cuni.sofa.lib.Impl.ByteArrayOutputStream os = new cz.cuni.sofa.lib.Impl.ByteArrayOutputStream(); 77 bundle._write(os); 78 os.close(); 79 ret = os.toByteArray(); 80 } catch (IOException e) { 81 throw new ConnectorTransportException("Can't serialize in the 'list'.", e); 82 } 83 return ret; 84 } 85 } 86 | Popular Tags |