KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > HomeExecutorDeclImpl


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

26
27 package org.objectweb.openccm.ast.lib;
28
29 // Package dependencies.
30
import org.objectweb.openccm.ast.api.DeclarationKind;
31 import org.objectweb.openccm.ast.api.Declaration;
32 import org.objectweb.openccm.ast.api.DelegationList;
33 import org.objectweb.openccm.ast.api.StringList;
34 import org.objectweb.openccm.ast.api.HomeDecl;
35 import org.objectweb.openccm.ast.api.AbstractStorageHomeDecl;
36 import org.objectweb.openccm.ast.api.ExecutorDecl;
37
38 /**
39  * HomeExecutorDeclImpl is a wrapper class for CIDL home executor declarations.
40  *
41  *
42  * Inherits from:
43  * - CidlScopeImpl as executors are also IDL scopes.
44  * - HomeExecutorDecl as OMG IDL for CIDL home executor declarations.
45  *
46  *
47  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
48  * <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
49  *
50  * @version 0.2
51  */

52
53 public class HomeExecutorDeclImpl
54      extends CidlScopeImpl
55   implements org.objectweb.openccm.ast.api.HomeExecutorDecl
56 {
57     // ==================================================================
58
//
59
// Internal state.
60
//
61
// ==================================================================
62

63     /** The associated home declaration. */
64     private HomeDeclImpl home_;
65
66     /** The associated abstract storagehome binding. */
67     private AbstractStorageHomeDeclImpl ashBinding_;
68
69     /** The associated abstract storagehome persistence. */
70     private AbstractStorageHomeDeclImpl ashPersistence_;
71
72     /** List of abstract storagehome delegations. */
73     private DelegationListImpl ash_delegation_;
74
75     /** List of executor delegations. */
76     private DelegationListImpl executor_delegation_;
77
78     /** List of abstract operations. */
79     private StringListImpl operations_;
80
81     // ==================================================================
82
//
83
// Constructor.
84
//
85
// ==================================================================
86

87     /**
88      * The constructor with the parent scope.
89      *
90      * @param rep The repository of the declaration.
91      * @param parent The parent scope of the exception declaration.
92      */

93     public
94     HomeExecutorDeclImpl(Repository rep,
95                          ScopeImpl parent)
96     {
97         // Call the ScopeImpl constructor.
98
super(rep, parent);
99
100         // Init internal state.
101
home_ = null;
102         ashBinding_ = null;
103         ashPersistence_ = null;
104         ash_delegation_ = new DelegationListImpl();
105         executor_delegation_ = new DelegationListImpl();
106         operations_ = new StringListImpl();
107     }
108
109     // ==================================================================
110
//
111
// Internal methods.
112
//
113
// ==================================================================
114

115     // ==================================================================
116
//
117
// Internal methods for DeclarationImpl.
118
//
119
// ==================================================================
120

121     /**
122      * Obtain its CORBA 3.0 Contained reference.
123      *
124      * @return The Contained object associated with the exception
125      * declaration.
126      */

127     protected org.omg.CORBA.Contained JavaDoc
128     getContained()
129     {
130        return null;
131     }
132
133     // ==================================================================
134
//
135
// Internal methods for ScopeImpl.
136
//
137
// ==================================================================
138

139     /**
140      * Obtain its CORBA 3.0 Container reference.
141      *
142      * @return The Container object associated with the exception
143      * declaration.
144      */

145     protected org.omg.CORBA.Container JavaDoc
146     getContainer()
147     {
148         return null;
149     }
150
151     // ==================================================================
152
//
153
// Public methods.
154
//
155
// ==================================================================
156

157     // ==================================================================
158
//
159
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
160
//
161
// ==================================================================
162

163     /**
164      * Obtain the declaration external dependencies.
165      *
166      * Note: for scopes, contained objects are not considered
167      * as dependencies.
168      *
169      * @return The list of dependencies as an array of Declaration.
170      */

171     public Declaration[]
172     getDependencies()
173     {
174         if (dependencies_ != null)
175             return dependencies_;
176
177         java.util.List JavaDoc he_depend = new java.util.ArrayList JavaDoc();
178         Declaration[] depend = null;
179
180         // implemented Home
181
if ( he_depend.indexOf(getHomeType()) == -1 )
182             he_depend.add( getHomeType() );
183         depend = getHomeType().getDependencies();
184         for (int j=0; j<depend.length; j++)
185         {
186             if ( (depend[j] != this) &&
187                  (he_depend.indexOf(depend[j]) == -1) )
188                 he_depend.add(depend[j]);
189         }
190
191         // Managed component
192
he_depend.add( getHomeType().getManagedComponent() );
193         depend = getHomeType().getManagedComponent().getDependencies();
194         for (int j=0; j<depend.length; j++)
195         {
196             if ( (depend[j] != this) &&
197                  (he_depend.indexOf(depend[j]) == -1) )
198                 he_depend.add(depend[j]);
199         }
200
201         // Abstract Storage Home binding
202
if (getAbstractStorageHomeBinding() != null)
203         {
204             he_depend.add( getAbstractStorageHomeBinding() );
205             depend = getAbstractStorageHomeBinding().getDependencies();
206             for (int j=0; j<depend.length; j++)
207             {
208                 if ( (depend[j] != this) &&
209                      (he_depend.indexOf(depend[j]) == -1) )
210                     he_depend.add(depend[j]);
211             }
212         }
213
214         // Home persistence
215
if (getHomePersistence() != null)
216         {
217             he_depend.add( getHomePersistence() );
218             depend = getHomePersistence().getDependencies();
219             for (int j=0; j<depend.length; j++)
220             {
221                 if ( (depend[j] != this) &&
222                      (he_depend.indexOf(depend[j]) == -1) )
223                     he_depend.add(depend[j]);
224             }
225         }
226
227         // Abstract Storage Home delegation
228
// TO DO
229

230         // Executor delegation
231
// TO DO
232

233         // contents
234
Declaration[] decls = getContents(true, DeclarationKind.dk_all);
235         for (int i=0; i<decls.length; i++)
236         {
237             depend = decls[i].getDependencies();
238             for (int j=0; j<depend.length; j++)
239             {
240                 if ( (!containsDecl(depend[j])) &&
241                      (depend[j] != this) &&
242                      (he_depend.indexOf(depend[j]) == -1) )
243                 {
244                     he_depend.add(depend[j]);
245                 }
246             }
247         }
248
249         dependencies_ = (Declaration[])he_depend.toArray(new Declaration[0]);
250         return dependencies_;
251     }
252
253     // ==================================================================
254
//
255
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
256
//
257
// ==================================================================
258

259     /**
260      * Obtain its DeclarationKind.
261      *
262      * @return The DeclarationKind of the object.
263      */

264     public long
265     getDeclKind()
266     {
267         return DeclarationKind.dk_home_executor;
268     }
269
270     /**
271      * Close the exception scope.
272      */

273     public void
274     create()
275     {
276         // Call the Cidl scope method
277
super.create();
278
279       // TODO check if the home executor declaration is correct
280
}
281
282     // ==================================================================
283
//
284
// Methods for OMG IDL org.objectweb.openccm.ast.api.Scope
285
//
286
// ==================================================================
287

288     // ==================================================================
289
//
290
// Methods for OMG IDL org.objectweb.openccm.ast.api.HomeExecutorDecl
291
//
292
// ==================================================================
293

294     /**
295      * Set the associated home declaration.
296      *
297      * @param ash The associated home declaration.
298      */

299     public void
300     setHomeType(HomeDecl h)
301     {
302         home_ = (HomeDeclImpl)h;
303     }
304
305     /**
306      * Obtain the associated home declaration.
307      *
308      * @return The associated home declaration.
309      */

310     public HomeDecl
311     getHomeType()
312     {
313         return home_;
314     }
315
316     /**
317      * Set the associated binding abstract storagehome.
318      *
319      * @param ash The associated binding abstract storagehome.
320      */

321     public void
322     setAbstractStorageHomeBinding(AbstractStorageHomeDecl ash)
323     {
324         ashBinding_ = (AbstractStorageHomeDeclImpl)ash;
325     }
326
327     /**
328      * Obtain the associated binding abstract storagehome.
329      *
330      * @return The associated binding abstract storagehome.
331      */

332     public AbstractStorageHomeDecl
333     getAbstractStorageHomeBinding()
334     {
335         return ashBinding_;
336     }
337
338     /**
339      * Set the associated persistence abstract storagehome.
340      *
341      * @param ash The associated persistence abstract storagehome.
342      */

343     public void
344     setHomePersistence(AbstractStorageHomeDecl ash)
345     {
346         ashPersistence_ = (AbstractStorageHomeDeclImpl)ash;
347     }
348
349     /**
350      * Obtain the associated persistence abstract storagehome.
351      *
352      * @return The associated persistence abstract storagehome.
353      */

354     public AbstractStorageHomeDecl
355     getHomePersistence()
356     {
357         return ashPersistence_;
358     }
359
360     /**
361      * Obtain the list of abstract storagehome delegations.
362      *
363      * @return The list of abstract storagehome delegations.
364      */

365     public DelegationList
366     getAbstractStorageHomeDelegationList()
367     {
368         return ash_delegation_;
369     }
370
371     /**
372      * Obtain the list of executor delegations.
373      *
374      * @return The list of executor delegations.
375      */

376     public DelegationList
377     getExecutorDelegationList()
378     {
379         return executor_delegation_;
380     }
381
382     /**
383      * Obtain the list of abstract operations.
384      *
385      * @return The list of abstract operations.
386      */

387     public StringList
388     getAbstractOperationList()
389     {
390         return operations_;
391     }
392
393     /**
394      * Start a new CIDL executor declaration.
395      *
396      * @param name The name of the CIDL executor declaration.
397      *
398      * @return The new created ExecutorDecl.
399      */

400     public ExecutorDecl
401     startExecutor(String JavaDoc name)
402     {
403         ExecutorDecl decl = new ExecutorDeclImpl(getRepository(), this);
404         decl.setName(name);
405         return decl;
406     }
407 }
408
Popular Tags