KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > generator > dependencies > lib > IDL3DeclarationDependencies


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

26
27 package org.objectweb.corba.generator.dependencies.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.ComponentDecl;
33 import org.objectweb.openccm.ast.api.HomeDecl;
34 import org.objectweb.openccm.ast.api.InterfaceDecl;
35 import org.objectweb.openccm.ast.api.InterfacePortDecl;
36 import org.objectweb.openccm.ast.api.EventPortDecl;
37 import org.objectweb.openccm.ast.api.TypeRef;
38 import org.objectweb.openccm.ast.api.TypeKind;
39 import org.objectweb.openccm.ast.api.EventDecl;
40 import org.objectweb.openccm.ast.api.OperationDecl;
41 import java.util.Set JavaDoc;
42
43
44 /**
45  * This class allows you to get classes dependencies for an IDL3 declaration.
46  *
47  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
48  *
49  * @version 0.1
50  */

51
52 public class IDL3DeclarationDependencies
53      extends IDL2DeclarationDependencies
54   implements org.objectweb.corba.generator.dependencies.api.IDL3DeclarationDependencies
55 {
56     // ==================================================================
57
//
58
// Internal state.
59
//
60
// ==================================================================
61

62     // ==================================================================
63
//
64
// Constructor.
65
//
66
// ==================================================================
67

68     /**
69      * The default constructor.
70      */

71     public
72     IDL3DeclarationDependencies()
73     {
74         // Init internal state
75
super();
76     }
77
78     // ==================================================================
79
//
80
// Internal methods.
81
//
82
// ==================================================================
83

84     // ==================================================================
85
//
86
// Public methods for org.objectweb.openccm.generator.cidl.api.IDL3DeclarationDependencies
87
//
88
// ==================================================================
89

90     /**
91      * Get Home File dependencies.
92      * This includes all inherited Homes.
93      *
94      * @param home - The home declaration.
95      * @param visited - List of previously visited declarations. Must not be null.
96      *
97      * @return The list of dependencies as a set of Files.
98      */

99     public Set JavaDoc
100     getHomeDependencies(HomeDecl home,
101                         Set JavaDoc visited)
102     {
103         Set JavaDoc files = null;
104         String JavaDoc path = null;
105         InterfaceDecl[] bases = null;
106
107         // Test if this declaration was visited
108
if ( visited.contains(home) )
109         {
110             return files;
111         }
112         else
113         {
114             // Add this to visited declarations
115
visited.add(home);
116         }
117
118         path = _translator.getAsDirectory(home);
119         files = new java.util.HashSet JavaDoc();
120
121         // Home local Interfaces
122
addStantardIdlFiles(files, path + "CCM_" + home.getName() + "Explicit");
123         addOperationsClass(files, path + "CCM_" + home.getName() + "Explicit");
124         addStantardIdlFiles(files, path + "CCM_" + home.getName() + "Implicit");
125         addOperationsClass(files, path + "CCM_" + home.getName() + "Implicit");
126         addStantardIdlFiles(files, path + "CCM_" + home.getName());
127         addOperationsClass(files, path + "CCM_" + home.getName());
128
129
130         // Home remote Interfaces
131
addStantardIdlFiles(files, path + home.getName() + "Explicit");
132         addOperationsClass(files, path + home.getName() + "Explicit");
133         addPoaIdlFiles(files, path + home.getName() + "Explicit");
134         addStubClass(files, path + home.getName() + "Explicit");
135         addStantardIdlFiles(files, path + home.getName() + "Implicit");
136         addOperationsClass(files, path + home.getName() + "Implicit");
137         addPoaIdlFiles(files, path + home.getName() + "Implicit");
138         addStubClass(files, path + home.getName() + "Implicit");
139         addStantardIdlFiles(files, path + home.getName());
140         addOperationsClass(files, path + home.getName());
141         addPoaIdlFiles(files, path + home.getName());
142         addStubClass(files, path + home.getName());
143
144         // Home skeletons
145
addObjectClass(files, path + home.getName() + "CCM");
146         addObjectClass(files, path + home.getName() + "SkeletonInterceptor");
147         addObjectClass(files, path + home.getName() + "StubInterceptor");
148
149         // Home Meta-Information
150
addObjectClass(files, path + home.getName() + "_homeMI");
151         addObjectClass(files, path + home.getName() + "_interfaceMI");
152
153         // Home implemented interfaces
154
bases = home.getSupportedInterfaceList().getInterfaces();
155         for (int i=0; i<bases.length; i++)
156         {
157             files.addAll( getInterfaceDependencies(bases[i], true, visited) );
158         }
159
160         // Home base home(s)
161
if (home.getBaseHome() != null)
162         {
163             files.addAll( getHomeDependencies(home.getBaseHome(), visited) );
164         }
165
166         // Home contents dependencies
167
files.addAll( getContentsDependencies(home, visited) );
168
169         return files;
170     }
171
172     /**
173      * Get Component File dependencies.
174      * This includes all inherited Components.
175      *
176      * @param comp - The Component declaration.
177      * @param visited - List of previously visited declarations. Must not be null.
178      *
179      * @return The list of dependencies as a set of Files.
180      */

181     public Set JavaDoc
182     getComponentDependencies(ComponentDecl comp,
183                              Set JavaDoc visited)
184     {
185         Set JavaDoc files = null;
186         String JavaDoc path = null;
187         InterfaceDecl[] bases = null;
188
189         files = new java.util.HashSet JavaDoc();
190
191         // Test if this declaration was visited
192
if ( visited.contains(comp) )
193         {
194             return files;
195         }
196         else
197         {
198             // Add this to visited declarations
199
visited.add(comp);
200         }
201
202         path = _translator.getAsDirectory(comp);
203
204         // Component local interfaces
205
addStantardIdlFiles(files, path + "CCM_" + comp.getName());
206         addOperationsClass(files, path + "CCM_" + comp.getName());
207         addStantardIdlFiles(files, path + "CCM_" + comp.getName() + "_Context");
208         addOperationsClass(files, path + "CCM_" + comp.getName() + "_Context");
209         addStantardIdlFiles(files, path + "CCM_" + comp.getName() + "_Executor");
210         addOperationsClass(files, path + "CCM_" + comp.getName() + "_Executor");
211
212         // Component remote interfaces
213
addStantardIdlFiles(files, path + comp.getName());
214         addOperationsClass(files, path + comp.getName());
215         addPoaIdlFiles(files, path + comp.getName());
216         addStubClass(files, path + comp.getName());
217
218         // Component skeletons
219
addObjectClass(files, path + comp.getName() + "CCM");
220         addObjectClass(files, path + comp.getName() + "MonolithicWrapper");
221         addObjectClass(files, path + comp.getName() + "SkeletonInterceptor");
222         addObjectClass(files, path + comp.getName() + "StubInterceptor");
223
224         // Component Meta-Information
225
addObjectClass(files, path + comp.getName() + "_componentMI");
226         addObjectClass(files, path + comp.getName() + "_interfaceMI");
227
228         // Component implemented interfaces
229
bases = comp.getSupportedInterfaceList().getInterfaces();
230         for (int i=0; i<bases.length; i++)
231         {
232             files.addAll( getInterfaceDependencies(bases[i], true, visited) );
233         }
234
235         // Component base component(s)
236
if (comp.getBaseComponent() != null)
237         {
238             files.addAll( getComponentDependencies(comp.getBaseComponent(), visited) );
239         }
240
241         // Component contents dependencies
242
files.addAll( getContentsDependencies(comp, visited) );
243
244         return files;
245     }
246
247     /**
248      * Get Interface Port Declaration File dependencies.
249      * This includes all inherited interfaces.
250      *
251      * @param itf_port - The interface port declaration.
252      * @param server - If true, include server class files.
253      * @param visited - List of previously visited declarations. Must not be null.
254      *
255      * @return The list of dependencies as a set of Files.
256      */

257     public Set JavaDoc
258     getInterfacePortDependencies(InterfacePortDecl itf_port,
259                                  boolean server,
260                                  Set JavaDoc visited)
261     {
262         Set JavaDoc files = null;
263         String JavaDoc path = null,
264                name = null;
265
266         // Test if this declaration was visited
267
if ( visited.contains(itf_port) )
268         {
269             return files;
270         }
271         else
272         {
273             // Add this to visited declarations
274
visited.add(itf_port);
275         }
276
277         path = _translator.getAsDirectory( itf_port.getParent() );
278         files = new java.util.HashSet JavaDoc();
279         name = itf_port.getInterface().getName();
280
281         // Add CCM local interfaces
282
if (server)
283         {
284             addStantardIdlFiles( files, path + "CCM_" + name );
285             addOperationsClass( files, path + "CCM_" + name );
286         }
287
288         // Add CCM interface skeletons
289
files.addAll( getInterfaceDependencies(itf_port.getInterface(), server, visited) );
290         if (server)
291         {
292             addObjectClass(files, path + name + "SkeletonInterceptor");
293             addObjectClass(files, path + name + "StubInterceptor");
294         }
295
296         // Interface Meta-Information
297
if (server)
298         {
299             addObjectClass(files, path + name + "_interfaceMI");
300         }
301
302         return files;
303     }
304
305     /**
306      * Get Event port Declaration File dependencies.
307      * This includes all inherited interfaces.
308      *
309      * @param event_port - The event port declaration.
310      * @param server - If true, include server class files.
311      * @param visited - List of previously visited declarations. Must not be null.
312      *
313      * @return The list of dependencies as a set of Files.
314      */

315     public Set JavaDoc
316     getEventPortDependencies(EventPortDecl event_port,
317                              boolean server,
318                              Set JavaDoc visited)
319     {
320         Set JavaDoc files = null;
321         String JavaDoc path = null,
322                name = null;
323
324         // Test if this declaration was visited
325
if ( visited.contains(event_port) )
326         {
327             return files;
328         }
329         else
330         {
331             // Add this to visited declarations
332
visited.add(event_port);
333         }
334
335         path = _translator.getAsDirectory( event_port.getEvent() );
336         name = event_port.getEvent().getName();
337         files = new java.util.HashSet JavaDoc();
338
339         // Add CCM local interfaces
340
if (server)
341         {
342             addStantardIdlFiles( files, path + "CCM_" + name + "Consumer" );
343             addOperationsClass( files, path + "CCM_" + name + "Consumer" );
344         }
345
346         // Add CCM interface skeletons
347
addStantardIdlFiles( files, path + name + "Consumer" );
348         addStubClass( files, path + name + "Consumer" );
349         addOperationsClass( files, path + name + "Consumer" );
350         if (server)
351         {
352             addPoaIdlFiles( files, path + name + "Consumer" );
353             addObjectClass(files, path + name + "ConsumerSkeletonInterceptor");
354             addObjectClass(files, path + name + "ConsumerStubInterceptor");
355             addObjectClass(files, path + name + "ConsumerWrapper");
356         }
357
358         // Add event and event base event dependencies
359
files.addAll( getValueTypeDependencies(event_port.getEvent(), visited) );
360         addObjectClass(files, path + name + "FactoryHelper");
361
362         return files;
363     }
364
365     /**
366      * Get dependencies for an IDL3 declaration.
367      *
368      * @param decl - Get dependencies for this declaration.
369      * @param visited - List of previously visited declarations. Must not be null.
370      *
371      * @return The list of dependencies as a set of Files.
372      */

373     public Set JavaDoc
374     getDeclarationDependencies(Declaration decl,
375                                Set JavaDoc visited)
376     {
377         Set JavaDoc files = null;
378
379         files = new java.util.HashSet JavaDoc();
380
381         // Test if this declaration was visited (to avoid following tests)
382
if ( visited.contains(decl) )
383         {
384             return files;
385         }
386
387         if (decl.getDeclKind() == DeclarationKind.dk_component)
388         {
389             files.addAll( getComponentDependencies((ComponentDecl) decl, visited) );
390         }
391         else if (decl.getDeclKind() == DeclarationKind.dk_consumes)
392         {
393             files.addAll( getEventPortDependencies((EventPortDecl) decl, true, visited) );
394         }
395         else if ( (decl.getDeclKind() == DeclarationKind.dk_emits)
396                   || (decl.getDeclKind() == DeclarationKind.dk_publishes) )
397         {
398             files.addAll( getEventPortDependencies((EventPortDecl) decl, false, visited) );
399         }
400         else if (decl.getDeclKind() == DeclarationKind.dk_provides)
401         {
402             files.addAll( getInterfacePortDependencies((InterfacePortDecl) decl, true, visited) );
403         }
404         else if (decl.getDeclKind() == DeclarationKind.dk_uses)
405         {
406             files.addAll( getInterfacePortDependencies((InterfacePortDecl) decl, false, visited) );
407         }
408         else if (decl.getDeclKind() == DeclarationKind.dk_home)
409         {
410             files.addAll( getHomeDependencies((HomeDecl) decl, visited) );
411         }
412         else if (decl.getDeclKind() == DeclarationKind.dk_event)
413         {
414             files.addAll( getValueTypeDependencies((EventDecl) decl, visited) );
415         }
416         else if ( (decl.getDeclKind() == DeclarationKind.dk_factory)
417                   ||(decl.getDeclKind() == DeclarationKind.dk_finder) )
418         {
419             files.addAll( getOperationDependencies((OperationDecl) decl, visited) );
420         }
421         else
422         {
423             // Call to IDL2 dependencies
424
files.addAll( super.getDeclarationDependencies(decl, visited) );
425         }
426
427         return files;
428     }
429
430     /**
431      * Get Type Reference dependencies class files.
432      *
433      * @param aconst - Get dependencies from this type reference.
434      * @param visited - List of previously visited declarations. Must not be null.
435      *
436      * @return The list of dependencies as a set of Files.
437      */

438     public Set JavaDoc
439     getTypeRefDependencies(TypeRef type,
440                            Set JavaDoc visited)
441     {
442         TypeKind tk = null;
443         Set JavaDoc files = new java.util.HashSet JavaDoc();
444
445         tk = type.getTypeKind();
446
447         // If type is a declaration, add declaration dependencies
448
if (type.isDeclaration())
449         {
450             Declaration decl = (Declaration) type;
451
452             if (tk == TypeKind.tk_component)
453             {
454                 files.addAll( getComponentDependencies((ComponentDecl) decl, visited) );
455             }
456             else if (tk == TypeKind.tk_home)
457             {
458                 files.addAll( getHomeDependencies((HomeDecl) decl, visited) );
459             }
460             else if (tk == TypeKind.tk_event)
461             {
462                 files.addAll( getValueTypeDependencies((EventDecl) decl, visited) );
463             }
464             else
465             {
466                 // Call to IDL2 dependencies
467
files.addAll( super.getTypeRefDependencies(type, visited) );
468             }
469         }
470         return files;
471     }
472
473     // ==================================================================
474
//
475
// Public methods.
476
//
477
// ==================================================================
478

479 }
480
Popular Tags