KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > EmitsDef_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::EmitsDef 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 EmitsDef_impl
39        extends EventPortDef_impl
40        implements org.omg.CORBA.ComponentIR.EmitsDefOperations
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

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

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

57     public
58     EmitsDef_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.EmitsDefPOATie(this));
66     }
67
68     // ==================================================================
69
//
70
// Public methods.
71
//
72
// ==================================================================
73

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

77     public org.omg.CORBA.ComponentIR.EmitsDef
78     asEmitsDef()
79     {
80         return org.omg.CORBA.ComponentIR.EmitsDefHelper.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_Emits;
96     }
97
98     // ==================================================================
99
//
100
// For CORBA::ComponentIR::EventPortDef interface.
101
//
102
// ==================================================================
103

104     // ==================================================================
105
//
106
// For CORBA::ComponentIR::EmitsDef 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         // emits mapping :
135
//
136
// void connect_<source_name>(in <event_type>Consumer consumer)
137
// raises(::Components::AlreadyConnected);
138
//
139
String JavaDoc version = version();
140         String JavaDoc name = "connect_" + name();
141         String JavaDoc id = cont_base_id + name + ":" + version;
142         InterfaceDef_impl container = (InterfaceDef_impl)container_;
143         String JavaDoc cons_id = computeIDWithoutVersion(event_.asEventDef().id());
144         cons_id = cons_id + "Consumer:"+ event_.asEventDef().version();
145
146         org.omg.CORBA.IDLType JavaDoc consumer_itf = org.omg.CORBA.IDLTypeHelper.narrow(
147             getIFR().getRepository().lookup_mapped_id(cons_id));
148         org.omg.CORBA.ParameterDescription JavaDoc[] params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
149         params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
150         params[0].name = "consumer";
151         params[0].type_def = consumer_itf;
152         params[0].type = params[0].type_def.type();
153         params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
154         org.omg.CORBA.ExceptionDef JavaDoc[] excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
155         excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
156             getIFR().getRepository().lookup("::Components::AlreadyConnected"));
157
158         container_.mapping_started_ = true;
159         container.create_operation(id, name, version,
160                                    getIFR().getRepository().get_primitive(
161                                        org.omg.CORBA.PrimitiveKind.pk_void),
162                                    org.omg.CORBA.OperationMode.OP_NORMAL,
163                                    params, excs, new java.lang.String JavaDoc[0]);
164         container_.mapping_started_ = false;
165
166         //
167
// <event_type>Consumer disconnect_<source_name>()
168
// raises(::Components::NoConnection);
169
//
170
name = "disconnect_" + name();
171         id = cont_base_id + name + ":" + version;
172         excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
173         excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
174             getIFR().getRepository().lookup("::Components::NoConnection"));
175
176         container_.mapping_started_ = true;
177         container.create_operation(id, name, version,
178                                    consumer_itf,
179                                    org.omg.CORBA.OperationMode.OP_NORMAL,
180                                    new org.omg.CORBA.ParameterDescription JavaDoc[0],
181                                    excs, new java.lang.String JavaDoc[0]);
182         container_.mapping_started_ = false;
183
184         //
185
// CIDL mapping
186
//
187
// local interface CCM_<component_name>_Context : ...
188
// {
189
// void push_<name>(in <event_name> event);
190
// };
191
//
192
cont_base_id = container_.getBaseContainerID();
193         version = container_.version();
194
195         String JavaDoc litf_id = cont_base_id + "CCM_" + container_.name() + "_Context:" + version;
196         org.omg.CORBA.ExtLocalInterfaceDef litf = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow(
197              getIFR().getRepository().lookup_mapped_id(litf_id));
198
199         cont_base_id = computeBaseID(litf_id);
200         version = litf.version();
201         name = "push_" + name();
202         id = cont_base_id + name + ":" + version;
203
204         params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
205         params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
206         params[0].name = "event";
207         params[0].type_def = event_.getImpl().asIDLType();
208         params[0].type = params[0].type_def.type();
209         params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
210         litf.create_operation(id, name, version,
211                               getIFR().getRepository().get_primitive(
212                                            org.omg.CORBA.PrimitiveKind.pk_void),
213                               org.omg.CORBA.OperationMode.OP_NORMAL,
214                               params,
215                               new org.omg.CORBA.ExceptionDef JavaDoc[0],
216                               new java.lang.String JavaDoc[0]);
217     }
218 }
219
Popular Tags