KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > OpenCCM_DCI > cif > NodeManagerImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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.OpenCCM_DCI.cif;
28
29 import org.objectweb.openccm.OpenCCM_DCI.*;
30
31 /**
32  * This is the implementation of the NodeManager component type.
33  *
34  * This class inherits from the skeleton
35  * generated by the OpenCCM's CIF to Java mapping generator.
36  *
37  * @author <a HREF="mailto:Frederic.Briclet@lifl.fr">Briclet Frederic</A>
38  */

39
40 public class NodeManagerImpl
41      extends org.objectweb.openccm.OpenCCM_DCI
42              .NodeManagerSessionComposition
43              .NodeManagerSessionImpl
44 {
45     
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51
//The node name
52
private String JavaDoc nodeName;
53     //File path to the NodePropertiesDescriptor
54
private String JavaDoc npdFilePath;
55     
56     private org.omg.CosNaming.NameComponent JavaDoc ncomp[];
57       
58     // ==================================================================
59
//
60
// Internal methods.
61
//
62
// ==================================================================
63
// ==================================================================
64
//
65
// Constructor.
66
//
67
// ==================================================================
68
public NodeManagerImpl(String JavaDoc npdFilePath){
69         //save the file path
70
this.npdFilePath=npdFilePath;
71     }
72   
73     // ==================================================================
74
//
75
// Public methods.
76
//
77
// ==================================================================
78
/**
79      * Container callback to signal that the component is removed.
80      *
81      * @throw org.omg.Components.CCMException For any problems.*
82      */

83     public void
84     ccm_remove()
85     throws org.omg.Components.CCMException
86     {
87
88          try{
89              ((ServerActivatorImpl)
90               obtain_executor("server_activator")).remove();
91          }
92          catch(org.omg.Components.RemoveFailure e)
93          {
94             System.err.println("Cannot remove all the componentservers.");
95          }
96         
97         try{
98             if(ncomp!=null){
99                 org.omg.CosNaming.NamingContextExt JavaDoc nce=
100                     org.omg.CosNaming
101                     .NamingContextExtHelper
102                     .narrow(org.objectweb.openccm.corba.TheNameService
103                             .getNamingContext().getNamingContext());
104                 
105                 nce.unbind(ncomp);
106                 
107                 System.err.println("The "+nodeName+"Node is unreferenced");
108              }
109             }
110         catch(Exception JavaDoc e)
111             {
112                 System.err.println("Cannot unbind The "+nodeName+"Node");
113             }
114                 
115         try{
116             ((org.objectweb.openccm.OpenCCM_DCI.NodeManagerCCM)get_context()).
117                 get_connection_node_management().deregister_node(nodeName);
118             
119         org.objectweb.openccm.Deployment.ShutDownThread tr=
120             new org.objectweb.openccm.Deployment.ShutDownThread();
121         tr.start();
122         try{
123             tr.join();
124             }
125         catch(InterruptedException JavaDoc e){
126             e.printStackTrace();
127             }
128
129                    
130         }
131         catch(org.ist.coach.DCI.UnknownNode e){
132             e.printStackTrace();
133             throw new org.omg.Components.CCMException();
134         }
135         System.exit(0);
136     }
137
138     /**
139      * Completes the component configuration.
140      *
141      * @exception org.omg.Components.InvalidConfiguration
142      * Thrown if the configuration is invalid.
143      */

144     public void
145     configuration_complete()
146     throws org.omg.Components.InvalidConfiguration
147     {
148       try{
149           //setup the node
150
((NodeInformationSegImpl)
151               obtain_executor("node_information")).setTree(npdFilePath);
152           
153           org.omg.Components.SessionContext sc=
154               (org.omg.Components.SessionContext)get_context();
155               
156           org.ist.coach.DCI.NodeManager node=
157                              org.objectweb.openccm.
158                              OpenCCM_DCI.NodeManagerHelper
159                              .narrow(sc.get_CCM_object());
160           //register the node to the DCI
161
((org.objectweb.openccm.OpenCCM_DCI.NodeManagerCCM)get_context()).
162               get_connection_node_management()
163               .register_node(nodeName,node);
164               
165         org.omg.CosNaming.NamingContextExt JavaDoc nce=
166                 org.omg.CosNaming
167                 .NamingContextExtHelper
168                 .narrow(org.objectweb.openccm.corba.TheNameService
169                         .getNamingContext().getNamingContext());
170         String JavaDoc registrationName=
171                 System.getProperty("Node_ns_dir")
172                 +nodeName;
173                         
174         ncomp=org.objectweb.openccm
175                 .descriptor.componentassembly.ccm
176                 .deployer.registrar.RegisterwithnamingDeployer
177                 .rebind(nce,registrationName,node);
178                    
179       }
180       catch(Exception JavaDoc e){
181           e.printStackTrace();
182       }
183     }
184     
185     // ==================================================================
186
//
187
// Accessor methods.
188
//
189
// ==================================================================
190
public void node_name(String JavaDoc node_name){
191         this.nodeName=node_name;
192     }
193
194     public String JavaDoc node_name(){
195      return nodeName;
196     }
197     
198     
199 }
200
Popular Tags