KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > IDL3 > ModuleDeclImpl


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): Philippe Merle, Mathieu Vadet.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.ccm.IDL3;
28
29 /**
30  * This class manages IDL module declarations.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class ModuleDeclImpl
39        extends ForwardScopeImpl
40        implements ModuleDecl
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      ** Reference to the CORBA 3.0 ModuleDef.
50      **/

51     private org.omg.CORBA.ComponentIR.ModuleDef component_module_def_;
52
53     /**
54      **
55      **/

56     private boolean completed_;
57
58     // ==================================================================
59
//
60
// Constructor.
61
//
62
// ==================================================================
63

64     /**
65      ** The constructor with the parent scope.
66      **
67      ** @param parent The parent scope of the module declaration.
68      **/

69     protected
70     ModuleDeclImpl(Repository rep, ScopeImpl parent)
71     {
72         // Call the ScopeImpl constructor.
73
super(rep, parent);
74
75         // Init internal state.
76
component_module_def_ = null;
77         the_declaration_kind_ = DeclarationKind._dk_module;
78         completed_ = false;
79     }
80
81     // ==================================================================
82
//
83
// Internal methods.
84
//
85
// ==================================================================
86

87     /**
88      ** Loads infos of the CORBA 3.0 ModuleDef.
89      **
90      ** @param moduleDef The ModuleDef to load.
91      **/

92     protected void
93     load(org.omg.CORBA.Contained JavaDoc contained)
94     {
95         component_module_def_ = org.omg.CORBA.ComponentIR.ModuleDefHelper.narrow(contained);
96         super.load(contained);
97     }
98
99     /**
100      ** Loads infos of the CORBA 3.0 ModuleDef.
101      **
102      ** @param moduleDef The ModuleDef to load.
103      **/

104     protected void
105     loadAsMapping(org.omg.CORBA.Contained JavaDoc contained)
106     {
107         component_module_def_ = org.omg.CORBA.ComponentIR.ModuleDefHelper.narrow(contained);
108         super.loadAsMapping(contained);
109     }
110
111     // ==================================================================
112
//
113
// Methods for the Declaration interface.
114
//
115
// ==================================================================
116

117     /**
118      ** Create the interface declaration into the IFR.
119      **/

120     public void
121     create()
122     {
123         if (getContainer() == null)
124     {
125             createContainer();
126             if (the_parent_!=null)
127                 the_parent_.addDecl(this);
128         }
129         else if (!completed_)
130             completeContainer();
131     }
132
133     /**
134      ** Obtain the declaration external dependencies.
135      ** Note: for scopes, contained objects are not considered
136      ** as dependencies.
137      **
138      ** @return The list of dependencies as an array of Declaration.
139      **/

140     public Declaration[]
141     getDependencies()
142     {
143         if (dependencies_!=null)
144             return dependencies_;
145
146         Declaration[] decls = getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_all);
147         Declaration[] depend = null;
148         org.objectweb.ccm.util.Vector module_depend = new org.objectweb.ccm.util.Vector();
149
150         // contents
151
for (int i=0;i<decls.length;i++)
152         {
153             depend = decls[i].getDependencies();
154             for (int j=0;j<depend.length;j++)
155             {
156                 if ((!containsDecl(depend[j])) &&
157                     (module_depend.indexOf(depend[j])==-1))
158                     module_depend.add(depend[j]);
159             }
160         }
161
162         dependencies_ = (Declaration[])module_depend.toArray(new Declaration[0]);
163         return dependencies_;
164     }
165
166     // ==================================================================
167
//
168
// Methods for the inherited DeclarationImpl class.
169
//
170
// ==================================================================
171

172     /**
173      ** Obtain its CORBA 3.0 Contained reference.
174      **
175      ** @return The Contained object associated with the module declaration.
176      **/

177     protected org.omg.CORBA.Contained JavaDoc
178     getContained()
179     {
180        return component_module_def_;
181     }
182
183     // ==================================================================
184
//
185
// Methods for the inherited ForwardScopeImpl class.
186
//
187
// ==================================================================
188

189     /**
190      ** Create the container object.
191      **/

192     protected void
193     createContainer()
194     {
195         // Create it only if it was not previously created.
196
if (component_module_def_==null)
197         {
198            // Create a ModuleDef into the IFR.
199
component_module_def_ =
200                the_parent_.getComponentContainer().create_component_module(getId(), getName(), getVersion());
201         }
202     }
203
204     /**
205      ** Complete the container object.
206      **/

207     protected void
208     completeContainer()
209     {
210         completed_ = true;
211     }
212
213     // ==================================================================
214
//
215
// Methods for the inherited ScopeImpl class.
216
//
217
// ==================================================================
218

219     /**
220      ** Obtain its CORBA 3.0 Container reference.
221      **
222      ** @return The Container object associated with the module declaration.
223      **/

224     protected org.omg.CORBA.Container JavaDoc
225     getContainer()
226     {
227        return component_module_def_;
228     }
229
230     /**
231      ** Obtain its CORBA 3.0 Container reference.
232      **
233      ** @return The Container object associated with the module declaration.
234      **/

235     protected org.omg.CORBA.ComponentIR.Container
236     getComponentContainer()
237     {
238        return component_module_def_;
239     }
240 }
241
Popular Tags