KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > InOut > Connector > InOut2InOutRMISkel


1 /**
2  * InOut2InOutRMISkel.java is a part of the SOFA project.
3  * This file was created by pepan on 18.4.2003.
4  */

5 package SOFA.SOFAnode.InOut.Connector;
6
7 import java.io.IOException JavaDoc;
8 import java.rmi.RemoteException JavaDoc;
9 import java.rmi.server.UnicastRemoteObject JavaDoc;
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 /**
18  *
19  * @author Petr Panuska
20  */

21 public class InOut2InOutRMISkel extends UnicastRemoteObject JavaDoc implements CNInOut2InOutRemote, Linkable {
22   CNInOut2InOut target;
23
24   public InOut2InOutRMISkel (String JavaDoc url) throws RemoteException JavaDoc, java.net.MalformedURLException JavaDoc, java.rmi.NotBoundException JavaDoc {
25     super();
26     String JavaDoc rmihost = System.getProperty("sofa.rmihost", "localhost");
27     String JavaDoc rmiport = System.getProperty("sofa.rmiport", "1099");
28     // because of remote registering of services
29
// don't be confused with the name '.DeplDockRegistry.RgRMIDock', it has nothing to do with a Depl. Dock
30
// for more info contact Petr Hnetynka
31
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 JavaDoc target) {
36     this.target = (CNInOut2InOut) target;
37   }
38
39   public byte[] pullBundle (ComponentInfo[] descs, ComponentInfo[] comps, boolean inferiors) throws RemoteException JavaDoc, 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 JavaDoc 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 JavaDoc, InOutException {
54     BundleImpl bundle = new BundleImpl();
55     try {
56       bundle._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(bundleData));
57     } catch (IOException JavaDoc e) {
58       throw new ConnectorTransportException("Can't serialize in the 'InOut2InOutRMISkel.pushBundle'.", e);
59     }
60     target.pushBundle(bundle);
61   }
62 }
63
Popular Tags