KickJava   Java API By Example, From Geeks To Geeks.

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


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

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** Used to access AST DeclarationKind. */
30 import org.objectweb.openccm.ast.api.DeclarationKind;
31
32 /** Used to access AST InterfaceDecl. */
33 import org.objectweb.openccm.ast.api.InterfaceDecl;
34
35 /** Used to access AST OperationDecl. */
36 import org.objectweb.openccm.ast.api.OperationDecl;
37
38 /** Used to access AST ComponentDecl. */
39 import org.objectweb.openccm.ast.api.ComponentDecl;
40
41 /** To use CORBA::ComponentIR::PublishesDef. */
42 import org.omg.CORBA.ComponentIR.PublishesDef;
43 import org.omg.CORBA.ComponentIR.PublishesDefHelper;
44
45 /**
46  * PublishesDeclImpl is a wrapper class for IDL publishes port declarations.
47  *
48  * Inherits from:
49  * - EventPortDeclImpl as consumes are event ports,
50  * - LocalContextOperationMapping
51  * to obtain the local context operation mapping.
52  *
53  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
54  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
55  *
56  * @version 0.3
57  */

58
59 public class PublishesDeclImpl
60        extends EventPortDeclImpl
61        implements org.objectweb.openccm.ast.api.PublishesDecl
62 {
63     // ==================================================================
64
//
65
// Internal state.
66
//
67
// ==================================================================
68

69     /** Reference to the CORBA 3.0 PublishesDef. */
70     private PublishesDef publishes_def_;
71
72     /** Local context operation mapping. */
73     private OperationDecl[] local_context_mapping_;
74
75     // ==================================================================
76
//
77
// Constructor.
78
//
79
// ==================================================================
80

81     /**
82      * The constructor with the parent scope.
83      *
84      * @param rep The repository of the declaration.
85      * @param parent The parent scope of the publishes declaration.
86      */

87     protected
88     PublishesDeclImpl(Repository rep,
89                       ScopeImpl parent)
90     {
91         // Call the EventPortDeclImpl constructor.
92
super(rep, parent);
93
94         // Init internal state.
95
publishes_def_ = null;
96         local_context_mapping_ = null;
97     }
98
99     // ==================================================================
100
//
101
// Internal methods.
102
//
103
// ==================================================================
104

105     // ==================================================================
106
//
107
// Internal methods for DeclarationImpl.
108
//
109
// ==================================================================
110

111     /**
112      * Loads infos of the CORBA 3.0 PublishesDef.
113      *
114      * @param contained The PublishesDef to load.
115      */

116     protected void
117     load(org.omg.CORBA.Contained JavaDoc contained)
118     {
119         publishes_def_ = PublishesDefHelper.narrow(contained);
120         super.load(contained);
121     }
122
123     /**
124      * Obtain its CORBA 3.0 Contained reference.
125      *
126      * @return The Contained object associated with
127      * the publishes declaration.
128      */

129     protected org.omg.CORBA.Contained JavaDoc
130     getContained()
131     {
132        return publishes_def_;
133     }
134
135     // ==================================================================
136
//
137
// Public methods.
138
//
139
// ==================================================================
140

141     // ==================================================================
142
//
143
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
144
//
145
// ==================================================================
146

147     // ==================================================================
148
//
149
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
150
//
151
// ==================================================================
152

153     /**
154      * Obtain its DeclarationKind.
155      *
156      * @return The DeclarationKind of the object.
157      */

158     public long
159     getDeclKind()
160     {
161         return DeclarationKind.dk_publishes;
162     }
163
164     /**
165      * Create the publishes declaration into the IFR.
166      */

167     public void
168     create()
169     {
170         publishes_def_ = the_parent_.getComponentDef().
171                          create_publishes(getId(), getName(), getVersion(),
172                                           event_.getEventDef());
173         super.create();
174     }
175
176     // ==================================================================
177
//
178
// Methods for OMG IDL org.objectweb.openccm.ast.api.ClientOperationMapping
179
//
180
// ==================================================================
181

182     /**
183      * Obtain the client operation mapping.
184      *
185      * @return The client operation mapping.
186      */

187     public OperationDecl[]
188     getClientMapping()
189     {
190         if (client_mapping_!=null)
191             return client_mapping_;
192
193         // retrieve the client mapping interface.
194
InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping();
195         client.getContents(true, DeclarationKind.dk_null);
196
197         client_mapping_ = new OperationDecl[2];
198         client_mapping_[0] = (OperationDecl)client.find("subscribe_"+getName());
199         client_mapping_[1] = (OperationDecl)client.find("unsubscribe_"+getName());
200
201         return client_mapping_;
202     }
203
204     // ==================================================================
205
//
206
// Methods for OMG IDL org.objectweb.openccm.ast.api.EventPortDecl
207
//
208
// ==================================================================
209

210     // ==================================================================
211
//
212
// Methods for OMG IDL org.objectweb.openccm.ast.api.LocalContextOperationMapping
213
//
214
// ==================================================================
215

216     /**
217      * Obtain the local context operation mapping.
218      *
219      * @return The local context operation mapping.
220      */

221     public OperationDecl[]
222     getLocalContextMapping()
223     {
224         if (local_context_mapping_!=null)
225             return local_context_mapping_;
226
227         // retrieve the context mapping local interface.
228
InterfaceDecl context = ((ComponentDecl)the_parent_).getLocalContextMapping();
229         context.getContents(true, DeclarationKind.dk_null);
230
231         local_context_mapping_ = new OperationDecl[1];
232         local_context_mapping_[0] = (OperationDecl)
233                                     context.find("push_"+getName());
234         return local_context_mapping_;
235     }
236 }
237
Popular Tags