KickJava   Java API By Example, From Geeks To Geeks.

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


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.CompositionDecl;
33 import org.objectweb.openccm.ast.api.ComponentDecl;
34 import org.objectweb.openccm.ast.api.HomeExecutorDecl;
35 import org.objectweb.openccm.ast.api.ExecutorDecl;
36 import org.objectweb.openccm.ast.api.SegmentDecl;
37 import org.objectweb.openccm.ast.utils.api.CompositionInfo;
38 import java.util.Set JavaDoc;
39
40
41 /**
42  * This class allows you to get classes dependencies for a CIDL declaration.
43  *
44  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
45  *
46  * @version 0.1
47  */

48
49 public class CIDLDeclarationDependencies
50      extends IDL3DeclarationDependencies
51   implements org.objectweb.corba.generator.dependencies.api.CIDLDeclarationDependencies
52 {
53     // ==================================================================
54
//
55
// Internal state.
56
//
57
// ==================================================================
58

59     // ==================================================================
60
//
61
// Constructor.
62
//
63
// ==================================================================
64

65     /**
66      * The default constructor.
67      */

68     public
69     CIDLDeclarationDependencies()
70     {
71         // Init internal state
72
super();
73     }
74
75     // ==================================================================
76
//
77
// Internal methods.
78
//
79
// ==================================================================
80

81     // ==================================================================
82
//
83
// Public methods for org.objectweb.openccm.generator.cidl.api.CIDLDeclarationDependencies
84
//
85
// ==================================================================
86

87     /**
88      * Get dependencies for a CIDL declaration.
89      *
90      * @param decl - Get dependencies for this declaration.
91      *
92      * @return The list of dependencies as a set of Files.
93      */

94     public Set JavaDoc
95     getDeclarationDependencies(Declaration decl)
96     {
97         Set JavaDoc files = null;
98
99         files = new java.util.HashSet JavaDoc();
100
101         if (decl.getDeclKind() == DeclarationKind.dk_composition)
102         {
103             files.addAll( getCompositionDependencies((CompositionDecl) decl) );
104         }
105         else if (decl.getDeclKind() == DeclarationKind.dk_home_executor)
106         {
107             files.addAll( getHomeExecutorDependencies((HomeExecutorDecl) decl) );
108         }
109         else if (decl.getDeclKind() == DeclarationKind.dk_executor)
110         {
111             files.addAll( getExecutorDependencies((ExecutorDecl) decl) );
112         }
113         else if (decl.getDeclKind() == DeclarationKind.dk_proxy_home)
114         {
115             // TO DO
116
}
117         else if (decl.getDeclKind() == DeclarationKind.dk_segment)
118         {
119             files.addAll( getSegmentDependencies((SegmentDecl) decl) );
120         }
121         else
122         {
123             // Call to IDL3 dependencies
124
files.addAll( super.getDeclarationDependencies(decl, new java.util.HashSet JavaDoc()) );
125         }
126             // TO DO
127
/* PSDL declaration kinds :
128                | dk_abstract_storage_home | dk_abstract_storage_type
129                | dk_psdl_operation
130                | dk_storage_home | dk_storage_home_factory
131                | dk_storage_home_key | dk_storage_type
132                | dk_storage_type_state_member
133                | dk_storage_type_store_directive;
134             */

135
136         return files;
137     }
138
139    /**
140      * Get Composition File dependencies.
141      *
142      * @param composition - The composition declaration.
143      *
144      * @return The list of dependencies as a set of Files.
145      */

146     public Set JavaDoc
147     getCompositionDependencies(CompositionDecl composition)
148     {
149         CompositionInfo comp = null;
150         Set JavaDoc files = null;
151
152         files = new java.util.TreeSet JavaDoc();
153         comp = new org.objectweb.openccm.ast.utils.lib.CompositionInfo(composition);
154
155         // Add home executor dependencies
156
files.addAll( getHomeExecutorDependencies(comp.getHomeExecutor()) );
157
158         // Add component executor dependencies
159
files.addAll( getExecutorDependencies(comp.getComponentExecutor()) );
160
161         return files;
162     }
163
164    /**
165      * Get Home Executor File dependencies.
166      *
167      * @param home_exec - The home executor declaration.
168      *
169      * @return The list of dependencies as a set of Files.
170      */

171     public Set JavaDoc
172     getHomeExecutorDependencies(HomeExecutorDecl home_exec)
173     {
174         Set JavaDoc files = null;
175         String JavaDoc path = null;
176
177         path = _translator.getAsDirectory(home_exec);
178         files = new java.util.TreeSet JavaDoc();
179
180         // Home Executor CIF Interfaces
181
addStantardIdlFiles(files, path + "CIF_" + home_exec.getName());
182         addOperationsClass(files, path + "CIF_" + home_exec.getName());
183
184         // Home Executor skeleton class
185
addObjectClass(files, path + home_exec.getName());
186
187         // Add Home dependencies
188
files.addAll( getHomeDependencies( home_exec.getHomeType(),
189                                            new java.util.HashSet JavaDoc() )
190                     );
191
192         return files;
193     }
194
195     /**
196      * Get Component Executor File dependencies.
197      *
198      * @param exec - The Component executor declaration.
199      *
200      * @return The list of dependencies as a set of Files.
201      */

202     public Set JavaDoc
203     getExecutorDependencies(ExecutorDecl exec)
204     {
205         Set JavaDoc files = null;
206         String JavaDoc path = null;
207         ComponentDecl comp = null;
208         HomeExecutorDecl home_exec = null;
209         Declaration[] decls = null;
210
211         path = _translator.getAsDirectory(exec.getParent());
212         files = new java.util.TreeSet JavaDoc();
213
214         // Component Executor local Interfaces
215
addStantardIdlFiles(files, path + "CIF_" + exec.getName());
216         addOperationsClass(files, path + "CIF_" + exec.getName());
217
218         // Component Executor Segment Base CIF Interfaces
219
addStantardIdlFiles(files, path + "CIF_SegmentBase");
220         addOperationsClass(files, path + "CIF_SegmentBase");
221
222         // Component Executor skeleton class
223
addObjectClass(files, path + exec.getName());
224
225         // Add Component dependencies
226
home_exec = (HomeExecutorDecl) exec.getParent();
227         comp = home_exec.getHomeType().getManagedComponent();
228         files.addAll( getComponentDependencies( comp,
229                                                 new java.util.HashSet JavaDoc() )
230                     );
231
232         // Add segments dependencies
233
decls = exec.getContents(true, DeclarationKind.dk_segment);
234         for (int i=0; i<decls.length; i++)
235         {
236             files.addAll( getSegmentDependencies((SegmentDecl) decls[i]) );
237         }
238
239         return files;
240     }
241
242      /**
243      * Get Segment File dependencies.
244      *
245      * @param seg - The Segment declaration.
246      *
247      * @return The list of dependencies as a set of Files.
248      */

249     public Set JavaDoc
250     getSegmentDependencies(SegmentDecl seg)
251     {
252         Set JavaDoc files = null;
253         String JavaDoc path = null;
254
255         path = _translator.getAsDirectory(seg.getParent().getParent());
256         files = new java.util.TreeSet JavaDoc();
257
258         // Segment CIF Interfaces
259
addStantardIdlFiles(files, path + "CIF_" + seg.getName());
260         addOperationsClass(files, path + "CIF_" + seg.getName());
261
262         // Segment skeleton class
263
addObjectClass(files, path + seg.getName());
264
265         return files;
266     }
267
268     // ==================================================================
269
//
270
// Public methods.
271
//
272
// ==================================================================
273

274 }
275
Popular Tags