KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * InOut2ClientRMISkel.java is a part of the SOFA project.
3  * This file was created by pepan on 16.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.Impl.BundleImpl;
15
16 /**
17  * @author Petr Panuska
18  */

19 public class InOut2ClientRMISkel extends UnicastRemoteObject JavaDoc implements CNInOut2ClientRemote, Linkable {
20   CNInOut2Client target;
21
22   public InOut2ClientRMISkel (String JavaDoc url) throws RemoteException JavaDoc, java.net.MalformedURLException JavaDoc, java.rmi.NotBoundException JavaDoc {
23     super();
24     String JavaDoc rmihost = System.getProperty("sofa.rmihost", "localhost");
25     String JavaDoc rmiport = System.getProperty("sofa.rmiport", "1099");
26     // because of remote registering of services
27
// don't be confused with the name '.DeplDockRegistry.RgRMIDock', it has nothing to do with a Depl. Dock
28
// for more info contact Petr Hnetynka
29
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 JavaDoc target) {
34     this.target = (CNInOut2Client) target;
35   }
36
37 /*
38   public void obtainComponent (String fullName, String sofanode) throws InOutException {
39     target.obtainComponent(fullName, sofanode);
40   }
41
42   public void distributeComponent (String fullName, String[] sofanodes) throws InOutException {
43     target.distributeComponent(fullName, sofanodes);
44   }
45
46 */

47   public void obtain (String JavaDoc[] offers, String JavaDoc[] components, String JavaDoc sofaNode) throws RemoteException JavaDoc, InOutException {
48     target.obtain(offers, components, sofaNode);
49   }
50
51   public void distribute (String JavaDoc[] offers, String JavaDoc[] components, String JavaDoc[] sofaNodes) throws RemoteException JavaDoc, InOutException {
52     target.distribute(offers, components, sofaNodes);
53   }
54
55   public void obtainOffers (String JavaDoc[] offers, String JavaDoc sofaNode) throws RemoteException JavaDoc, InOutException {
56     target.obtainOffers(offers, sofaNode);
57   }
58
59   public void distributeOffers (String JavaDoc[] offers, String JavaDoc[] sofaNodes) throws RemoteException JavaDoc, InOutException {
60     target.distributeOffers(offers, sofaNodes);
61   }
62
63   public void obtainComponents (String JavaDoc[] components, String JavaDoc sofaNode) throws RemoteException JavaDoc, InOutException {
64     target.obtainComponents(components, sofaNode);
65   }
66
67   public void distributeComponents (String JavaDoc[] components, String JavaDoc[] sofaNodes) throws RemoteException JavaDoc, 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 JavaDoc e) {
80       throw new ConnectorTransportException("Can't serialize in the 'InOut2ClientRMISkel.list'.", e);
81     }
82     return ret;
83   }
84 }
85
Popular Tags