KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > FactoryDef_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::FactoryDef 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 FactoryDef_impl
39        extends HomeOperationBase
40        implements org.omg.CORBA.ComponentIR.FactoryDefOperations
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

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

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

57     public
58     FactoryDef_impl(IFR ifr,
59                     HomeDef_impl home)
60     {
61         // call the HomeOperationBase constructor.
62
super(ifr, home);
63
64         // set the tie servant object.
65
setServant(new org.omg.CORBA.ComponentIR.FactoryDefPOATie(this));
66     }
67
68     // ==================================================================
69
//
70
// Public methods.
71
//
72
// ==================================================================
73

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

77     public org.omg.CORBA.ComponentIR.FactoryDef
78     asFactoryDef()
79     {
80         return org.omg.CORBA.ComponentIR.FactoryDefHelper.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_Factory;
96     }
97
98     // ==================================================================
99
//
100
// For CORBA::OperationDef interface.
101
//
102
// ==================================================================
103

104     // ==================================================================
105
//
106
// For CORBA::ComponentIR::FactoryDef 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
//
132
//
133
// add factory as an operation in the explicit interface.
134
//
135
InterfaceDef_impl explicit = ((HomeDef_impl)container_).base_interfaces_[0].getImpl();
136         String JavaDoc explicit_base_id = explicit.getBaseID();
137         String JavaDoc id = explicit_base_id + name() + ":" + version();
138         org.omg.CORBA.ExceptionDef JavaDoc[] excs1 = exceptions();
139         org.omg.CORBA.ExceptionDef JavaDoc[] excs2 = new org.omg.CORBA.ExceptionDef JavaDoc[excs1.length+1];
140         excs2[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
141                 getIFR().getRepository().lookup("::Components::CreateFailure"));
142         for (int i=0;i<excs1.length;i++)
143             excs2[i+1] = excs1[i];
144
145         explicit.create_operation(id, name(), version(), result_def(), mode(), params(),
146                                   excs2, contexts());
147
148         //
149
// CIDL mapping
150
//
151
//
152
// add factory as an operation in the explicit executor interface
153
//
154
String JavaDoc cont_base_id = container_.getBaseContainerID();
155
156         String JavaDoc explicit_exe_id = cont_base_id + "CCM_" + container_.name() + "Explicit:" + container_.version();
157         org.omg.CORBA.ExtLocalInterfaceDef explicit_exe = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow(
158              getIFR().getRepository().lookup_mapped_id(explicit_exe_id));
159         org.omg.CORBA.InterfaceDef JavaDoc enterprise_comp = org.omg.CORBA.InterfaceDefHelper.narrow(
160              getIFR().getRepository().lookup("::Components::EnterpriseComponent"));
161
162         id = cont_base_id + "CCM_" + container_.name() + "Explicit/" + name() + ":" + version();
163
164         explicit_exe.create_operation(id, name(), version(),
165                                       enterprise_comp,
166                                       mode(),
167                                       params(),
168                                       exceptions(),
169                                       contexts());
170     }
171 }
172
Popular Tags