KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > ConsumesDef_impl


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

26
27 package org.objectweb.openccm.ir3;
28
29 /**
30  * Implementation of the CORBA::ComponentIR::ConsumesDef interface.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class ConsumesDef_impl
39        extends EventPortDef_impl
40        implements org.omg.CORBA.ComponentIR.ConsumesDefOperations
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     // ==================================================================
49
//
50
// Constructor.
51
//
52
// ==================================================================
53

54     /**
55      * Default constructor.
56      */

57     public
58     ConsumesDef_impl(IFR ifr,
59                      Container_impl container)
60     {
61         // call the EventDef_impl contructor.
62
super(ifr, container);
63
64     // set the tie servant object.
65
setServant(new org.omg.CORBA.ComponentIR.ConsumesDefPOATie(this));
66     }
67
68     // ==================================================================
69
//
70
// Public methods.
71
//
72
// ==================================================================
73

74     /**
75      * Obtain its CORBA::ComponentIR::ConsumesDef object reference.
76      */

77     public org.omg.CORBA.ComponentIR.ConsumesDef
78     asConsumesDef()
79     {
80         return org.omg.CORBA.ComponentIR.ConsumesDefHelper.narrow(asObject());
81     }
82
83     // ==================================================================
84
//
85
// For CORBA::IRObject interface.
86
//
87
// ==================================================================
88

89     /**
90      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
91      */

92     public org.omg.CORBA.DefinitionKind JavaDoc
93     def_kind()
94     {
95         return org.omg.CORBA.DefinitionKind.dk_Consumes;
96     }
97
98     // ==================================================================
99
//
100
// For CORBA::ComponentIR::EventPortDef interface.
101
//
102
// ==================================================================
103

104     // ==================================================================
105
//
106
// For CORBA::ComponentIR::ConsumesDef interface.
107
//
108
// ==================================================================
109

110     // ==================================================================
111
//
112
// For IDL2 mapping.
113
//
114
// ==================================================================
115

116     /**
117      * TODO
118      */

119     protected void
120     whenCreated()
121     {
122         // do nothing if mappings are not enabled.
123
if (!getIFR().getRepository().enable_mappings_)
124             return ;
125
126         // else create the mapping according to the CCM spec
127

128         //
129
// IDL2 mapping
130
//
131
// compute the container base repository id
132
String JavaDoc cont_base_id = getBaseContainerID();
133
134         // consumes mapping :
135
//
136
// <event_type>Consumer get_consumer<sink_name>();
137
//
138

139         // retrieve the <event_type>Consumer interface.
140
org.omg.CORBA.ExtInterfaceDef event_consumer = null;
141         String JavaDoc name = event_.asEventDef().name() + "Consumer";
142         String JavaDoc version = event_.asEventDef().version();
143         String JavaDoc id = computeIDWithoutVersion(event_.asEventDef().id());
144         id = id + "Consumer:" + version;
145
146         event_consumer = org.omg.CORBA.ExtInterfaceDefHelper.narrow(
147                 getIFR().getRepository().lookup_mapped_id(id));
148         
149         name = "get_consumer_" + name();
150         version = version();
151         id = cont_base_id + name + ":" + version;
152         InterfaceDef_impl container = (InterfaceDef_impl)container_;
153
154         container_.mapping_started_ = true;
155         container.create_operation(id, name, version,
156                                    event_consumer,
157                                    org.omg.CORBA.OperationMode.OP_NORMAL,
158                                    new org.omg.CORBA.ParameterDescription JavaDoc[0],
159                                    new org.omg.CORBA.ExceptionDef JavaDoc[0],
160                                    new java.lang.String JavaDoc[0]);
161         container_.mapping_started_ = false;
162
163         //
164
// CIDL mapping
165
//
166
// local interface CCM_<component_name> : ...
167
// {
168
// void push_<name>(in <event_name> event);
169
// };
170
//
171
cont_base_id = container_.getBaseContainerID();
172         version = container_.version();
173
174         String JavaDoc litf_id = cont_base_id + "CCM_" + container_.name() + ":" + version;
175         org.omg.CORBA.ExtLocalInterfaceDef litf = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow(
176              getIFR().getRepository().lookup_mapped_id(litf_id));
177
178         cont_base_id = computeBaseID(litf_id);
179         version = litf.version();
180         name = "push_" + name();
181         id = cont_base_id + name + ":" + version;
182
183         org.omg.CORBA.ParameterDescription JavaDoc[] params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
184         params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
185         params[0].name = "event";
186         params[0].type_def = event_.getImpl().asIDLType();
187         params[0].type = params[0].type_def.type();
188         params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
189         litf.create_operation(id, name, version,
190                               getIFR().getRepository().get_primitive(
191                                            org.omg.CORBA.PrimitiveKind.pk_void),
192                               org.omg.CORBA.OperationMode.OP_NORMAL,
193                               params,
194                               new org.omg.CORBA.ExceptionDef JavaDoc[0],
195                               new java.lang.String JavaDoc[0]);
196     }
197 }
198
Popular Tags