KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > packaging > CCMIdRefsSingleton


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

26
27 package org.objectweb.openccm.packaging;
28
29
30 /**
31  * This is the Singleton register for scanning Ids in the GUI
32  *
33  * @author <a HREF="mailto:Christophe.Contreras@lifl.fr">Christophe Contreras</a>
34  *
35  */

36 public class CCMIdRefsSingleton
37 {
38     // ==================================================================
39
//
40
// Internal state.
41
//
42
// ==================================================================
43

44     /** the instance of the registry */
45     private static CCMIdRefsSingleton instance = null;
46
47     /** the assemblies list */
48     private java.util.List JavaDoc assemblies_list ;
49
50     /** the packages list */
51     private java.util.List JavaDoc packages_list ;
52
53     // ==================================================================
54
//
55
// Constructors.
56
//
57
// ==================================================================
58

59     /**
60      * The default constructor.
61      */

62     public
63     CCMIdRefsSingleton()
64     {
65         // inits the lists
66
assemblies_list = new java.util.LinkedList JavaDoc();
67         packages_list = new java.util.LinkedList JavaDoc();
68     }
69
70     // ==================================================================
71
//
72
// Public methods.
73
//
74
// ==================================================================
75

76     /**
77      * adds an assembly to list
78      *
79      * @param Componentassembly ass an instance of CAD
80      */

81     public void
82     addAssembly(org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBean ass)
83     {
84         this.assemblies_list.add(ass);
85     }
86
87     /**
88      * adds a package to list
89      *
90      * @param Softpkg softpkg an instance of CSD
91      */

92     public void
93     addPackage(org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBean softpkg)
94     {
95         this.packages_list.add(softpkg);
96     }
97
98     /**
99      * returns the instances list
100      *
101      * @return List of instances referenced in this panel
102      */

103     public java.util.List JavaDoc
104     getComponentInstList()
105     {
106         java.util.List JavaDoc componentinst_list = new java.util.LinkedList JavaDoc();
107
108         for (java.util.Iterator JavaDoc k = assemblies_list.iterator() ; k.hasNext() ; )
109         {
110             // the instance is an assembly
111
org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBean
112              assembly_instance
113              = (org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBean)
114                 k.next();
115
116
117             java.util.List JavaDoc homeplacements
118              = new java.util.LinkedList JavaDoc();
119
120             homeplacements.addAll(
121                 assembly_instance.getPartitioning().getHomeplacementList()
122                 );
123
124             java.util.List JavaDoc processcollocations
125              = assembly_instance.getPartitioning().getProcesscollocationList();
126
127             for (java.util.Iterator JavaDoc i = processcollocations.iterator() ; i.hasNext() ; )
128             {
129                 org.objectweb.openccm.descriptor.componentassembly.beans.ProcesscollocationBean
130                  element
131                  = (org.objectweb.openccm.descriptor.componentassembly.beans.ProcesscollocationBean)
132                     i.next();
133
134                 homeplacements.addAll(
135                     element.getHomeplacementList()
136                     );
137             }
138
139             java.util.List JavaDoc hostcollocations
140              = assembly_instance.getPartitioning().getHostcollocationList();
141
142             for (java.util.Iterator JavaDoc i = hostcollocations.iterator() ; i.hasNext() ; )
143             {
144                 org.objectweb.openccm.descriptor.componentassembly.beans.HostcollocationBean
145                  element
146                  = (org.objectweb.openccm.descriptor.componentassembly.beans.HostcollocationBean)
147                     i.next();
148
149                 processcollocations
150                  = element.getProcesscollocationList();
151
152                 for (java.util.Iterator JavaDoc j = processcollocations.iterator() ; j.hasNext() ; )
153                 {
154                     org.objectweb.openccm.descriptor.componentassembly.beans.ProcesscollocationBean
155                      subelement
156                      = (org.objectweb.openccm.descriptor.componentassembly.beans.ProcesscollocationBean)
157                         j.next();
158
159                     homeplacements.addAll(
160                         subelement.getHomeplacementList()
161                         );
162                 }
163
164                 homeplacements.addAll(
165                     element.getHomeplacementList()
166                     );
167             }
168
169             for (java.util.Iterator JavaDoc i = homeplacements.iterator() ; i.hasNext() ; )
170             {
171                 org.objectweb.openccm.descriptor.componentassembly.beans.HomeplacementBean
172                  element
173                  = (org.objectweb.openccm.descriptor.componentassembly.beans.HomeplacementBean)
174                     i.next();
175
176                 for (
177                     java.util.Iterator JavaDoc j = element.getComponentinstantiationList().iterator()
178                     ; j.hasNext()
179                     ; )
180                 {
181                     org.objectweb.openccm.descriptor.componentassembly.beans.ComponentinstantiationBean
182                      instance_element
183                      = (org.objectweb.openccm.descriptor.componentassembly.beans.ComponentinstantiationBean)
184                         j.next();
185
186                     componentinst_list.add(
187                         instance_element.getId()
188                         );
189                 }
190             }
191         }
192
193         return componentinst_list;
194     }
195
196     /**
197      * returns the implementations list
198      *
199      * @return List of implementations referenced in this panel
200      */

201     public java.util.List JavaDoc
202     getComponentImplList()
203     {
204         java.util.List JavaDoc componentimpl_list = new java.util.LinkedList JavaDoc();
205
206         for (java.util.Iterator JavaDoc i = packages_list.iterator() ; i.hasNext() ; )
207         {
208             // this instance is a software package descriptor
209
org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBean
210              software_instance
211              = (org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBean)
212                 i.next();
213
214             // gets the componentimplem list of this assembly
215
java.util.List JavaDoc componentimplems
216              = software_instance.getImplementationList();
217
218             // adds the ids for each element
219
for (java.util.Iterator JavaDoc j = componentimplems.iterator() ; j.hasNext() ; )
220             {
221                 org.objectweb.openccm.descriptor.softpkg.beans.ImplementationBean
222                  element
223                  = (org.objectweb.openccm.descriptor.softpkg.beans.ImplementationBean)
224                     j.next();
225
226                 // adds its id to this list
227
componentimpl_list.add(element.getId());
228             }
229         }
230
231         return componentimpl_list;
232     }
233
234     /**
235      * returns the files list
236      *
237      * @return List of componentfiles referenced in this panel
238      */

239     public java.util.List JavaDoc
240     getComponentFilesList()
241     {
242         java.util.List JavaDoc componentfiles_list = new java.util.LinkedList JavaDoc();
243
244         for (java.util.Iterator JavaDoc i = assemblies_list.iterator() ; i.hasNext() ; )
245         {
246             // the instance is an assembly
247
org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBean
248              assembly_instance
249              = (org.objectweb.openccm.descriptor.componentassembly.beans.ComponentassemblyBean)
250                 i.next();
251
252             // gets the componentfiles list of this assembly
253
java.util.List JavaDoc componentfiles
254              = assembly_instance.getComponentfiles().getComponentfileList();
255
256             // adds the ids for each element
257
for (java.util.Iterator JavaDoc j = componentfiles.iterator() ; j.hasNext() ; )
258             {
259                 org.objectweb.openccm.descriptor.componentassembly.beans.ComponentfileBean
260                  element
261                  = (org.objectweb.openccm.descriptor.componentassembly.beans.ComponentfileBean)
262                     j.next();
263
264                 // adds its id to this list
265
componentfiles_list.add(element.getId());
266             }
267         }
268
269         return componentfiles_list;
270     }
271
272     // ==================================================================
273
//
274
// Static methods.
275
//
276
// ==================================================================
277

278     /**
279      * get the instance
280      *
281      */

282     public static CCMIdRefsSingleton
283     getInstance()
284     {
285         if (instance == null)
286         {
287             instance = new CCMIdRefsSingleton();
288         }
289
290         return instance;
291     }
292 }
293
Popular Tags