1 5 package SOFA.SOFAnode.InOut.Connector; 6 7 import java.io.IOException ; 8 import java.rmi.RemoteException ; 9 10 import SOFA.Connector.ConnectorTransportException; 11 import SOFA.SOFAnode.InOut.Bundle; 12 import SOFA.SOFAnode.InOut.InOutException; 13 import SOFA.SOFAnode.TR.ComponentInfo; 14 import SOFA.SOFAnode.TR.Impl.BundleImpl; 15 16 20 public class InOut2InOutRMIStub implements CNInOut2InOut { 21 22 protected CNInOut2InOutRemote target; 23 24 public InOut2InOutRMIStub (String url) throws RemoteException { 25 try { 26 target = (CNInOut2InOutRemote) java.rmi.Naming.lookup(url); 27 } catch (java.net.MalformedURLException e) { 28 throw new RemoteException ("Can't create CNInOut2InOutRemote.\n" + url + "\n", e); 29 } catch (java.rmi.NotBoundException e) { 30 throw new RemoteException ("Can't create CNInOut2InOutRemote.\n" + url + "\n", e); 31 } 32 } 33 34 public Bundle pullBundle (ComponentInfo[] descs, ComponentInfo[] comps, boolean inferiors) throws InOutException { 35 try { 36 byte[] s = target.pullBundle(descs, comps, inferiors); 37 BundleImpl bundle = new BundleImpl(); 38 bundle._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(s)); 39 return bundle; 40 } catch (java.rmi.RemoteException e) { 41 throw new ConnectorTransportException("Remote exception in the 'InOut2InOutRMIStub.pullBundle'.", e); 42 } catch (java.io.IOException e) { 43 throw new ConnectorTransportException("IOException exception in the 'InOut2InOutRMIStub.pullBundle'.", e); 44 } 45 } 46 47 public void pushBundle (Bundle bundle) throws InOutException { 48 byte[] ret = null; 49 try { 50 cz.cuni.sofa.lib.Impl.ByteArrayOutputStream os = new cz.cuni.sofa.lib.Impl.ByteArrayOutputStream(); 51 ((BundleImpl) bundle)._write(os); 52 ret = os.toByteArray(); 53 target.pushBundle(ret); 54 } catch (IOException e) { 55 throw new ConnectorTransportException("Can't serialize in the 'InOut2InOutRMIStub.pushBundle'.", e); 56 } 57 } 58 59 } 60 | Popular Tags |