KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Deployment > NodeManagerServer


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Briclet Frederic
23 Contributor(s): ___________________________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.Deployment;
28
29 import org.omg.CosNaming.NameComponent JavaDoc;
30
31
32 public class NodeManagerServer extends org.objectweb.openccm.corba.ApplicationServer
33 {
34     
35     // ==================================================================
36
//
37
// Internal state.
38
//
39
// ==================================================================
40
/*The file which will store the node ior*/
41     private String JavaDoc nodeIORFilePath;
42     /*The node name*/
43     private String JavaDoc nodeName;
44     /*The NS registration name */
45     private NameComponent JavaDoc[] ncomp;
46     /*the configuration file path*/
47     private String JavaDoc npdFilePath;
48     /*The reference on the current DCI*/
49     private org.objectweb.openccm.OpenCCM_DCI.DCIManager DCI ;
50     // ==================================================================
51
//
52
// Internal methods.
53
//
54
// ==================================================================
55
private void
56     computeArgs(String JavaDoc args[])
57     {
58         for(int i=0;i<args.length;i++){
59             if(args[i].startsWith("NODENAME="))
60                this.nodeName=args[i].substring(9);
61             else if(args[i].startsWith("NPDFILE=-I"))
62                 this.npdFilePath=args[i].substring(10);
63                }
64        nodeIORFilePath=System.getProperty("WorkDir")+"/"+nodeName+".IOR";
65     }
66
67     
68       // ==================================================================
69
//
70
// Constructor.
71
//
72
// ==================================================================
73

74     /**
75      ** The constructor.
76      **/

77     public
78     NodeManagerServer()
79     {
80         // Set EntityResolver for CCM DTDs
81
org.objectweb.ccm.descriptor.EntityResolver.setCCMResolver();
82     }
83
84     // ==================================================================
85
//
86
// Public methods.
87
//
88
// ==================================================================
89

90     /**
91      ** The bootstrap main method.
92      **
93      ** @param args The command-line arguments.
94      **/

95     public static void
96     main(String JavaDoc args[])
97     {
98        NodeManagerServer server = new NodeManagerServer();
99         /*ParameterConverter pc=new ParameterConverter();
100         int status = server.start(pc.convertParameter(args));*/

101         int status = server.start(args);
102        System.exit(status);
103     }
104
105     // ==================================================================
106
//
107
// Methods for the org.objectweb.openccm.corba.ApplicationServer.
108
//
109
// ==================================================================
110

111     /**
112      ** Before running the CORBA::ORB.
113      **
114      ** @param args The command line arguments.
115      **
116      ** @return The status.
117      **/

118     public int
119     before_run(String JavaDoc[] args)
120     {
121
122     try{
123         //Initialize the ORB
124
org.objectweb.openccm.Components.Runtime.init(org.objectweb.openccm.corba.TheORB.getORB());
125         
126         computeArgs(args);
127              
128         //Retrive the DCI reference
129
DCI=
130             org.objectweb.openccm.
131             OpenCCM_DCI.DCIManagerHelper.
132             narrow(org.objectweb.openccm.corba
133                    .TheORB.resolve_initial_reference("DCIManager"));
134         
135         //Retrieve a AssemblyFactoryManagerHome reference
136
org.objectweb.openccm.OpenCCM_DCI.NodeManagerHome nodeHome=
137             org.objectweb.openccm.OpenCCM_DCI.NodeManagerHomeHelper.
138             narrow((new DeploymentComponentFactory()).
139             install_home("org.objectweb.openccm.OpenCCM_DCI.cif.NodeManagerHomeImpl.create_home"));
140
141         //create the node
142
org.objectweb.openccm.OpenCCM_DCI.NodeManager
143             node=nodeHome.create_node(npdFilePath);
144         
145         //Can be use full to avoid to fill a complete
146
// npd file
147
if(nodeName!=null)
148             node.node_name(nodeName);
149
150         //Retrieve a AssemblyFactoryHome reference
151
org.objectweb.openccm.OpenCCM_DCI.ComponentServerManagerHome CSMH=
152             org.objectweb.openccm.OpenCCM_DCI.
153             ComponentServerManagerHomeHelper.
154             narrow((new DeploymentComponentFactory()).
155          install_home("org.objectweb.openccm.OpenCCM_DCI.cif.ComponentServerManagerHomeImpl.create_home"));
156         //connect the component server manager home
157
node.connect_component_server_manager_home(CSMH);
158         
159         //Retrieve a AssemblyFactoryHome reference
160
org.objectweb.openccm.OpenCCM_DCI.ContainerManagerHome CMH=
161             org.objectweb.openccm.OpenCCM_DCI.
162             ContainerManagerHomeHelper.
163             narrow((new DeploymentComponentFactory()).
164         install_home("org.objectweb.openccm.OpenCCM_DCI.cif.ContainerManagerHomeImpl.create_home"));
165        
166         //connect the node management interface
167
node.connect_node_management(DCI.provide_node_management());
168         
169         //Connect the ContainerManagerHome to the node component
170
node.connect_container_manager_home(CMH);
171         //configure complete the node
172
node.configuration_complete();
173
174         // Register the node if required
175
// if(registrationName!=null){
176
/* org.omg.CosNaming.NamingContextExt nce=
177                 org.omg.CosNaming
178                 .NamingContextExtHelper
179                 .narrow(org.objectweb.openccm.corba.TheNameService
180                         .getNamingContext().getNamingContext());
181            String registrationName=
182                 System.getProperty("Node_ns_dir")
183                 +nodeName;
184                         
185           ncomp=org.objectweb.ccm
186                 .descriptor.componentassembly.ccm
187                 .deployer.registrar.RegisterwithnamingDeployer
188                 .rebind(nce,registrationName,node);*/

189            // }
190

191             // Output the IOR of the DCIManager.
192
org.objectweb.openccm.corba.TheORB.save_IOR(node,nodeIORFilePath);
193             
194         return 0;
195     }
196     catch(Exception JavaDoc e){
197         e.printStackTrace();
198         System.out.println(e.getMessage());
199         
200     }
201     return 0;
202
203     }
204     
205     /**
206      ** After running the CORBA::ORB.
207      **/

208     public void
209     after_run()
210     {
211         /*try{
212             if(ncomp!=null){
213                 org.omg.CosNaming.NamingContextExt nce=
214                     org.omg.CosNaming
215                     .NamingContextExtHelper
216                     .narrow(org.objectweb.openccm.corba.TheNameService
217                             .getNamingContext().getNamingContext());
218                 
219                 nce.unbind(ncomp);
220                 
221                 System.err.println("The "+nodeName+"Node is unreferenced");
222             }
223         }
224         catch(Exception e)
225             {
226                 System.err.println("Cannot unbind The "+nodeName+"Node");
227             } */

228
229     }
230     
231 }
232
Popular Tags