KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - 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): Philippe Merle
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.OpenCCM_DCI.cif;
28
29 import org.objectweb.openccm.OpenCCM_DCI.*;
30 import org.objectweb.openccm.corba.*;
31
32 /**
33  * This is the implementation of the NodeInformation facet provide
34  * by the NodeManager component.
35  *
36  * This class inherits from the skeleton
37  * generated by the OpenCCM's CIF to Java mapping generator.
38  *
39  * @author <a HREF="mailto:Frederic.Briclet@lifl.fr">Briclet Frederic</A>
40  */

41 public class NodeInformationSegImpl
42     extends org.objectweb.openccm
43              .OpenCCM_DCI.NodeManagerSessionComposition
44              .NodeInformationSeg
45 {
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51

52     /** The NPD reprenstation tree */
53     private org.objectweb.openccm.descriptor.node.beans.NodeBean nodeTree;
54
55     /** all the descriptors used by the node */
56     private org.ist.coach.DCI.DCIDescriptor[] descriptors;
57
58     /** Prefix for output message */
59     private String JavaDoc prefix="NodeInformation >> ";
60
61     // ==================================================================
62
//
63
// Internal methods..
64
//
65
// ==================================================================
66

67     // ==================================================================
68
//
69
// constructor
70
//
71
// ==================================================================
72

73     // ==================================================================
74
//
75
// Public methods.
76
//
77
// ==================================================================
78

79     /**
80      * TODO simplify the node properties reading
81      * This method set the NodePropertiesDescriptor used to configure
82      * the node.
83      * @param npdFilePath the node properties file path
84      */

85     public void
86     setTree(String JavaDoc npdFilePath)
87     {
88         try
89         {
90             //open the node properties file
91
java.io.File JavaDoc nodeFile= new java.io.File JavaDoc (npdFilePath);
92             //unmarshall the node properties file
93
nodeTree=
94                 org.objectweb.openccm
95                 .descriptor.node.beans
96                 .NodeBeanImpl.unmarshalBean(nodeFile);
97             //set the node_name with the node_tree information or
98
// the java property if no NPF was define
99
if(System.getProperty("NodeName")!=null){
100                 System.err.println(prefix+ "Used NodeName java property");
101                 System.err.println(prefix+ "No user NPD define");
102                 ((org.objectweb.openccm.OpenCCM_DCI.NodeManagerCCM)get_context())
103                     .node_name(System.getProperty("NodeName"));
104             }
105             else
106                 ((org.objectweb.openccm.OpenCCM_DCI.NodeManagerCCM)get_context())
107                     .node_name(nodeTree.getId());
108
109             //save the NodePropertiesDescriptor
110
descriptors=new org.ist.coach.DCI.DCIDescriptor[1];
111             descriptors[0]=new org.ist.coach.DCI.DCIDescriptor();
112             descriptors[0].filename=npdFilePath;
113             descriptors[0].type=org.ist.coach.DCI.DCIDescriptorType.NPD;
114             
115             java.io.BufferedReader JavaDoc br=
116                 new java.io.BufferedReader JavaDoc(new java.io.FileReader JavaDoc(nodeFile));
117             //Read the descriptor and store it.
118
while(br.ready())
119                 descriptors[0].descriptor=
120                     descriptors[0].descriptor+br.readLine()+"\n";
121                        
122             //Setup the componentinstallation directory
123

124             if(System.getProperty("ComponentInstallationDir")!=null){
125                 System.err.println(prefix+ "Used ComponentInstallationDir java property");
126                 System.err.println(prefix+ "No user NPD define");
127                 ((ExtComponentInstallationImpl)
128                  get_main_segment().obtain_executor("component_installation"))
129                     .setComponentInstallationDir(System.getProperty("ComponentInstallationDir"));
130             }
131             else
132                 ((ExtComponentInstallationImpl)
133                  get_main_segment().obtain_executor("component_installation"))
134                     .setComponentInstallationDir(nodeTree.getProperties()
135                                                  .getProperty().getValue()
136                                                  .getValue());
137         }
138         catch(Exception JavaDoc e)
139         {
140             e.printStackTrace();
141         }
142     }
143     
144     /**
145      * Return a propety value which name is properties_name
146      * @param properties_name The name of the property
147      * @return A corba Any object containing the property value
148      */

149     public org.omg.CORBA.Any JavaDoc
150     get_property_value(String JavaDoc properties_name)
151     {
152         // TODO: Must be implemented!
153
throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
154     }
155     
156     /**
157      * Return a node descriptor
158      * @return The descriptors
159      */

160     public org.ist.coach.DCI.DCIDescriptor[]
161     get_node_properties()
162     {
163         if(descriptors!=null)
164             return descriptors;
165             
166         return new org.ist.coach.DCI.DCIDescriptor[0];
167     }
168     
169     /**
170      * Test if a property is set.
171      * @param properties_name The name of the property to test
172      * @return The result of the test
173      */

174     public boolean
175     is_property_defined(java.lang.String JavaDoc propertyName)
176     {
177         // TODO: Must be implemented!
178
throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
179     }
180 }
181
Popular Tags