KickJava   Java API By Example, From Geeks To Geeks.

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


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::ConsumesDef. */
42 import org.omg.CORBA.ComponentIR.ConsumesDef;
43 import org.omg.CORBA.ComponentIR.ConsumesDefHelper;
44
45 /**
46  * ConsumesDeclImpl is a wrapper class for IDL consumes port declarations.
47  *
48  * Inherits from:
49  * - EventPortDeclImpl as consumes are event ports.
50  *
51  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
52  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
53  *
54  * @version 0.3
55  */

56
57 public class ConsumesDeclImpl
58        extends EventPortDeclImpl
59        implements org.objectweb.openccm.ast.api.ConsumesDecl
60 {
61     // ==================================================================
62
//
63
// Internal state.
64
//
65
// ==================================================================
66

67     /** Reference to the CORBA 3.0 ConsumesDef. */
68     private ConsumesDef consumes_def_;
69
70     // ==================================================================
71
//
72
// Constructor.
73
//
74
// ==================================================================
75

76     /**
77      * The constructor with the parent scope.
78      *
79      * @param rep The repository of the declaration.
80      * @param parent The parent scope of the declaration.
81      */

82     protected
83     ConsumesDeclImpl(Repository rep,
84                      ScopeImpl parent)
85     {
86         // Call the EventPortDeclImpl constructor.
87
super(rep, parent);
88
89         // Init internal state.
90
consumes_def_ = null;
91     }
92
93     // ==================================================================
94
//
95
// Internal methods.
96
//
97
// ==================================================================
98

99     // ==================================================================
100
//
101
// Internal methods for DeclarationImpl.
102
//
103
// ==================================================================
104

105     /**
106      * Loads infos of the CORBA 3.0 ConsumesDef.
107      *
108      * @param contained The ConsumesDef to load.
109      */

110     protected void
111     load(org.omg.CORBA.Contained JavaDoc contained)
112     {
113         consumes_def_ = ConsumesDefHelper.narrow(contained);
114         super.load(contained);
115     }
116
117     /**
118      * Obtain its CORBA 3.0 Contained reference.
119      *
120      * @return The Contained object associated with the consumes declaration.
121      */

122     protected org.omg.CORBA.Contained JavaDoc
123     getContained()
124     {
125        return consumes_def_;
126     }
127
128     // ==================================================================
129
//
130
// Public methods.
131
//
132
// ==================================================================
133

134     // ==================================================================
135
//
136
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
137
//
138
// ==================================================================
139

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

146     /**
147      * Obtain its DeclarationKind.
148      *
149      * @return The DeclarationKind of the object.
150      */

151     public long
152     getDeclKind()
153     {
154         return DeclarationKind.dk_consumes;
155     }
156
157     /**
158      * Create the consumes declaration into the IFR.
159      */

160     public void
161     create()
162     {
163         consumes_def_ = the_parent_.getComponentDef().
164                         create_consumes(getId(), getName(), getVersion(),
165                                         event_.getEventDef());
166         super.create();
167     }
168
169     // ==================================================================
170
//
171
// Methods for OMG IDL org.objectweb.openccm.ast.api.ClientOperationMapping
172
//
173
// ==================================================================
174

175     /**
176      * Obtain the client operation mapping.
177      *
178      * @return The client operation mapping.
179      */

180     public OperationDecl[]
181     getClientMapping()
182     {
183         if (client_mapping_!=null)
184             return client_mapping_;
185
186         // retrieve the client mapping interface.
187
InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping();
188         client.getContents(true, DeclarationKind.dk_null);
189
190         client_mapping_ = new OperationDecl[1];
191         client_mapping_[0] = (OperationDecl)
192                              client.find("get_consumer_"+getName());
193         return client_mapping_;
194     }
195 }
196
Popular Tags