KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > utils > lib > CompositionInfo


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.openccm.ast.utils.lib;
28
29 // Package dependencies.
30
import org.objectweb.openccm.ast.api.CompositionDecl;
31 import org.objectweb.openccm.ast.api.HomeDecl;
32 import org.objectweb.openccm.ast.api.HomeExecutorDecl;
33 import org.objectweb.openccm.ast.api.ProxyHomeDecl;
34 import org.objectweb.openccm.ast.api.ComponentDecl;
35 import org.objectweb.openccm.ast.api.ExecutorDecl;
36 import org.objectweb.openccm.ast.api.SegmentDecl;
37 import org.objectweb.openccm.ast.api.DeclarationKind;
38 import org.objectweb.openccm.ast.api.Declaration;
39
40 /**
41  * This class provides easy access to composition elements.
42  *
43  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
44  *
45  * @version 0.1
46  */

47
48 public class CompositionInfo
49   implements org.objectweb.openccm.ast.utils.api.CompositionInfo
50 {
51     // ==================================================================
52
//
53
// Internal state.
54
//
55
// ==================================================================
56

57     /** The composition to map. */
58     private CompositionDecl composition_;
59
60     /** The binding home. */
61     private HomeDecl home_;
62
63     /** The contained home executor. */
64     private HomeExecutorDecl home_exec_;
65
66     /** The contained proxy home. */
67     private ProxyHomeDecl proxy_home_;
68
69     /** The component managed by the home to map. */
70     private ComponentDecl comp_;
71
72     /** The component executor binding to the component. */
73     private ExecutorDecl comp_exec_;
74
75     /** Segments contained in the component executor. */
76     private SegmentDecl[] segments_;
77
78     // ==================================================================
79
//
80
// Constructors.
81
//
82
// ==================================================================
83

84     /**
85      * The default constructor.
86      *
87      * @param composition - The composition to manage.
88      **/

89     public CompositionInfo(CompositionDecl composition)
90     {
91         Declaration[] decls = null;
92
93         composition_ = composition;
94
95         /** Get the home executor */
96         decls = composition.getContents(true, DeclarationKind.dk_home_executor);
97         // A composition has 1 home executor.
98
home_exec_ = (HomeExecutorDecl) decls[0];
99
100         /** Get the proxy home */
101         decls = composition.getContents(true, DeclarationKind.dk_proxy_home);
102         // A composition has 0 or 1 proxy home.
103
proxy_home_ = null;
104         if (decls.length == 1)
105         {
106             proxy_home_ = (ProxyHomeDecl) decls[0];
107         }
108
109         /** Get the component executor */
110         decls = home_exec_.getContents(true, DeclarationKind.dk_executor);
111         // A Home Executor has 1 component executor.
112
comp_exec_ = (ExecutorDecl) decls[0];
113
114         /** Get the component */
115         comp_ = home_exec_.getHomeType().getManagedComponent();
116
117         /** Get the home */
118         home_ = home_exec_.getHomeType();
119
120         /** Get segments */
121         decls = comp_exec_.getContents(true, DeclarationKind.dk_segment);
122         segments_ = new SegmentDecl[decls.length];
123         for (int i=0; i<decls.length; i++)
124         {
125             segments_[i] = (SegmentDecl)decls[i];
126         }
127     }
128
129     // ==================================================================
130
//
131
// Internal methods.
132
//
133
// ==================================================================
134

135     // ==================================================================
136
//
137
// Public methods for org.objectweb.openccm.generator.cif.api.CompositionInfo.
138
//
139
// ==================================================================
140

141     /**
142      * Get the Composition declaration.
143      *
144      * @return The Composition declaration.
145      **/

146     public CompositionDecl
147     getComposition()
148     {
149         return composition_;
150     }
151
152     /**
153      * Get the Home declaration.
154      *
155      * @return The Home declaration.
156      **/

157     public HomeDecl
158     getHome()
159     {
160         return home_;
161     }
162
163     /**
164      * Get the Home executor declaration.
165      *
166      * @return The Home executor declaration.
167      **/

168     public HomeExecutorDecl
169     getHomeExecutor()
170     {
171         return home_exec_;
172     }
173
174     /**
175      * Get the Proxy Home declaration.
176      *
177      * @return The Proxy Home declaration.
178      **/

179     public ProxyHomeDecl
180     getProxyHome()
181     {
182         return proxy_home_;
183     }
184
185    /**
186      * Get the Component declaration.
187      *
188      * @return The Component declaration.
189      **/

190     public ComponentDecl
191     getComponent()
192     {
193         return comp_;
194     }
195
196     /**
197      * Get the Component executor declaration.
198      *
199      * @return The Component executor declaration.
200      **/

201     public ExecutorDecl
202     getComponentExecutor()
203     {
204         return comp_exec_;
205     }
206
207     /**
208      * Get segment declarations.
209      *
210      * @return Segment declarations.
211      **/

212     public SegmentDecl[]
213     getSegments()
214     {
215         return segments_;
216     }
217
218     // ==================================================================
219
//
220
// Public methods.
221
//
222
// ==================================================================
223

224 }
225
Popular Tags