KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > Boot > DeplDockRMIStub


1 /* $Id: DeplDockRMIStub.java,v 1.1.1.1 2003/02/11 16:19:40 bures Exp $ */
2 package SOFA.Connector.Boot;
3
4 import SOFA.Connector.ConnectorTransportException;
5
6 /** RMI stub for DeplDock connector.
7   *
8   * @author Petr Hnetynka
9   */

10 public class DeplDockRMIStub implements CNDeplDock {
11   private CNDeplDockRemote tgt = null;
12
13   public DeplDockRMIStub(String JavaDoc url) throws java.rmi.RemoteException JavaDoc {
14     try {
15       tgt = (CNDeplDockRemote) java.rmi.Naming.lookup(url);
16     } catch (java.net.MalformedURLException JavaDoc e) {
17       throw new java.rmi.RemoteException JavaDoc("Can't create DeplDockRMIStub", e);
18     } catch (java.rmi.NotBoundException JavaDoc e) {
19       throw new java.rmi.RemoteException JavaDoc("Can't create DeplDockRMIStub", e);
20     }
21   }
22
23   public SOFA.SOFAnode.Run.Deployment.TechnologyDescriptor[] describeUnderlyingEnvironment() {
24     try {
25       byte[][] s = tgt.describeUnderlyingEnvironment();
26       SOFA.SOFAnode.Run.Deployment.TechnologyDescriptor[] td = new SOFA.SOFAnode.Run.Deployment.TechnologyDescriptor[s.length];
27       for (int i=0; i<s.length; i++) {
28         td[i] = new SOFA.SOFAnode.Run.Deployment.TechnologyDescriptor();
29         td[i]._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(s[i]));
30       }
31       return td;
32     } catch (java.rmi.RemoteException JavaDoc e) {
33       throw new ConnectorTransportException("Remote exception in the \"describeUnderlyingEnvironment\".", e);
34     } catch (java.io.IOException JavaDoc e) {
35       throw new ConnectorTransportException("IOException in the \"describeUnderlyingEnvironment\".", e);
36     }
37   }
38   
39   public SOFA.Connector.Reference instantiate(SOFA.SOFAnode.Run.Deployment.DeploymentDescriptor dd, String JavaDoc name) throws SOFA.SOFAnode.Run.Deployment.DeploymentException {
40     try {
41       cz.cuni.sofa.lib.Impl.ByteArrayOutputStream os = new cz.cuni.sofa.lib.Impl.ByteArrayOutputStream();
42       dd._write(os);
43       
44       byte[] s = tgt.instantiate(os.toByteArray(), name);
45
46       SOFA.Connector.Reference ref = new SOFA.Connector.Reference ();
47       ref._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(s));
48       return ref;
49     } catch (java.rmi.RemoteException JavaDoc e) {
50       throw new ConnectorTransportException("Remote exception in the \"instantiate\".", e);
51     } catch (java.io.IOException JavaDoc e) {
52       throw new ConnectorTransportException("IOException in the \"instantiate\".", e);
53     }
54   }
55
56   public SOFA.Connector.Reference getReference(String JavaDoc name) throws SOFA.SOFAnode.Run.Deployment.DeploymentException {
57     try {
58       
59       byte[] s = tgt.getReference(name);
60
61       SOFA.Connector.Reference ref = new SOFA.Connector.Reference ();
62       ref._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(s));
63       return ref;
64     } catch (java.rmi.RemoteException JavaDoc e) {
65       throw new ConnectorTransportException("Remote exception in the \"getReference\".", e);
66     } catch (java.io.IOException JavaDoc e) {
67       throw new ConnectorTransportException("IOException in the \"getReference\".", e);
68     }
69   }
70
71   public String JavaDoc[] namesOfAllRunningComponents() {
72     try {
73       return tgt.namesOfAllRunningComponents();
74     } catch (java.rmi.RemoteException JavaDoc e) {
75       throw new ConnectorTransportException("Remote exception in the \"namesOfAllRunningComponents\".", e);
76     }
77   }
78   
79   public String JavaDoc[] namesOfAllRunningApplications() {
80     try {
81       return tgt.namesOfAllRunningApplications();
82     } catch (java.rmi.RemoteException JavaDoc e) {
83       throw new ConnectorTransportException("Remote exception in the \"namesOfAllRunningApplications\".", e);
84     }
85   }
86
87   public void removeComponent(String JavaDoc name) throws SOFA.SOFAnode.Run.Deployment.DeploymentException {
88     try {
89       tgt.removeComponent(name);
90     } catch (java.rmi.RemoteException JavaDoc e) {
91       throw new ConnectorTransportException("Remote exception in the \"removeComponent\".", e);
92     }
93   }
94
95
96 }
97
Popular Tags