KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Components > CCMHomeBase


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 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): Mathieu Vadet, Philippe Merle.
23 Contributor(s): Sylvain Leblanc, Romain Rouvoy________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.Components;
28
29 /**
30  * This class is a basic implementation of the CCMHome interface.
31  * It also implements all generic operations for CCM homes.
32  *
33  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
34  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
35  *
36  * @version 0.3
37  */

38
39 public abstract class CCMHomeBase
40 extends org.omg.CORBA.LocalObject JavaDoc
41 implements org.omg.Components.CCMHomeOperations,
42            org.omg.Components.HomeConfigurationOperations,
43            org.objectweb.openccm.Deployment.CCMHomeLocal
44 {
45     // ==================================================================
46
//
47
// Internal state.
48
//
49
// ==================================================================
50

51     protected org.objectweb.openccm.Deployment.listener.CCMHomeListener listener_;
52
53     /**
54      * The list of managed components.
55      */

56     protected java.util.Vector JavaDoc components_;
57
58     // ==================================================================
59
//
60
// Constructor.
61
//
62
// ==================================================================
63

64     /**
65      ** The constructor.
66      **
67      **/

68     protected
69     CCMHomeBase()
70     {
71         listener_ = null;
72         org.objectweb.openccm.Deployment.listener.TheCCMHomeConfigurator.get_instance().configure_ccm_home(this);
73         components_ = new java.util.Vector JavaDoc();
74     }
75
76     // ==================================================================
77
//
78
// Internal methods that must be implemented by subclasses.
79
//
80
// ==================================================================
81

82     /**
83      **
84      **/

85     protected abstract java.lang.String JavaDoc
86     _component_uid_();
87
88     /**
89      **
90      **/

91     protected abstract java.lang.String JavaDoc
92     _home_uid_();
93
94     /**
95      **
96      **/

97     protected abstract org.objectweb.openccm.Containers.HomeServant
98     _home_servant_();
99
100     // ==================================================================
101
//
102
// Internal methods.
103
//
104
// ==================================================================
105

106     /**
107      ** Create a CCM component reference.
108      **
109      ** @return The CCM component reference.
110      **/

111     protected final org.omg.Components.CCMObject
112     _create_with_instance(org.omg.Components.EnterpriseComponent comp)
113     {
114         org.omg.Components.CCMObject ref = null;
115
116         // create the reference
117
ref = _home_servant_().the_PCA().create_component_reference_with_instance(_home_servant_(), comp);
118                 listener_.on_create(ref);
119     // add to the component list.
120
components_.add(ref);
121         return ref;
122     }
123
124     /**
125      ** Create a CCM component reference.
126      **
127      ** @return The CCM component reference.
128      **/

129     protected final org.omg.Components.CCMObject
130     _find_with_instance(org.omg.Components.EnterpriseComponent comp)
131     {
132         org.omg.Components.CCMObject ref = null;
133
134         // find the reference
135
ref = _home_servant_().the_PCA().find_component_reference_with_instance(_home_servant_(), comp);
136         return ref;
137     }
138
139     // ==================================================================
140
//
141
// Public methods.
142
//
143
// ==================================================================
144
/**
145          ** Add a new plugin to the list of deployment plugins
146          **
147          ** @param listener the plugin listener to add
148          **/

149     public void
150     add_listener (org.objectweb.openccm.Deployment.listener.CCMHomeListener listener)
151     {
152                 if (listener_ == null)
153                         listener_ = listener;
154                 else
155                         listener_.set_delegate(listener);
156     }
157
158     // ==================================================================
159
//
160
// Methods for the Components::CCMHome interface.
161
//
162
// ==================================================================
163

164     //
165
// IDL:omg.org/Components/CCMHome/get_component_def:1.0
166
//
167
/**
168      ** Obtains the component definition into the Interface Repository.
169      **
170      ** @return The reference to the component definition.
171      **/

172     public final org.omg.CORBA.IRObject JavaDoc
173     get_component_def()
174     {
175         // Obtain the Interface Repository.
176
org.omg.CORBA.Repository JavaDoc ir =
177                         org.objectweb.openccm.corba.TheInterfaceRepository.getRepository();
178                 
179                 // Check if the Interface Repository is known.
180
if(ir != null)
181                 {
182                         throw new org.omg.CORBA.INTF_REPOS JavaDoc();
183                 }
184
185                 // Lookup the managed component repository Id.
186
return ir.lookup_id(_component_uid_());
187     }
188
189     //
190
// IDL:omg.org/Components/CCMHome/get_home_def:1.0
191
//
192
/**
193      ** Obtains the home definition into the Interface Repository.
194      **
195      ** @return The reference to the home definition.
196      **/

197     public final org.omg.CORBA.IRObject JavaDoc
198     get_home_def()
199     {
200         // Obtain the Interface Repository.
201
org.omg.CORBA.Repository JavaDoc ir =
202                         org.objectweb.openccm.corba.TheInterfaceRepository.getRepository();
203                 
204                 // Check if the Interface Repository is known.
205
if(ir != null)
206                 {
207                         throw new org.omg.CORBA.INTF_REPOS JavaDoc();
208                 }
209                 
210                 // Lookup the home repository Id.
211
return ir.lookup_id(_home_uid_());
212     }
213
214     //
215
// IDL:omg.org/Components/CCMHome/remove_home:1.0
216
//
217
/**
218      **
219      **/

220     public void
221     remove_home()
222     throws org.omg.Components.RemoveFailure
223     {
224 /* Bug #306
225    NEW CODE
226 */

227         // Removes all its components.
228
org.omg.Components.CCMObject[] components = get_components();
229         for(int i=0; i<components.length; i++)
230         {
231             components[i].remove();
232         }
233
234         // Removes the home.
235
_home_servant_().remove();
236     }
237
238     //
239
// IDL:omg.org/Components/CCMHome/get_components:1.0
240
//
241
/**
242      * Obtains an array containing the created components.
243      */

244     public org.omg.Components.CCMObject[]
245     get_components()
246     {
247         return (org.omg.Components.CCMObject[])
248                components_.toArray(new org.omg.Components.CCMObject[0]);
249     }
250
251 /*
252   New operation added according to the
253   OpenCCM Task #633 and OMG issue #6001.
254
255   Contributor: Philippe Merle - INRIA
256 */

257     //
258
// IDL:omg.org/Components/CCMHome/get_container:1.0
259
//
260
/**
261      * Obtains the Container where the home is installed.
262      */

263     public org.omg.Components.Deployment.Container
264     get_container()
265     {
266         return _home_servant_().the_container_base().the_container_ref();
267     }
268
269     // ==================================================================
270
//
271
// Methods for the Components::HomeConfiguration interface.
272
//
273
// ==================================================================
274

275     //
276
// IDL:omg.org/Components/HomeConfiguration/set_configurator:1.0
277
//
278
/**
279      ** Sets the configurator associated to this home.
280      **
281      ** @param cfg The configurator.
282      **/

283     public final void
284     set_configurator(org.omg.Components.Configurator cfg)
285     {
286                 // TODO: Must be implemented!
287
throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
288     }
289
290     //
291
// IDL:omg.org/Components/HomeConfiguration/set_configuration_values:1.0
292
//
293
/**
294      ** Sets the configuration values.
295      **
296      ** @param config The set of configuration values.
297      **/

298     public final void
299     set_configuration_values(org.omg.Components.ConfigValue[] config)
300     {
301                 // TODO: Must be implemented!
302
throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
303     }
304
305     //
306
// IDL:omg.org/Components/HomeConfiguration/complete_component_configuration:1.0
307
//
308
/**
309      ** Completes component configuration.
310      **
311      ** @param b Complete or not component configuration.
312      **/

313     public final void
314     complete_component_configuration(boolean b)
315     {
316                 // TODO: Must be implemented!
317
throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
318     }
319
320     //
321
// IDL:omg.org/Components/HomeConfiguration/disable_home_configuration:1.0
322
//
323
/**
324      ** Disables home configuration.
325      **/

326     public final void
327     disable_home_configuration()
328     {
329                 // TODO: Must be implemented!
330
throw new org.omg.CORBA.NO_IMPLEMENT JavaDoc();
331     }
332 }
333
334
335
336
337
338
339
340
341
342
343
Popular Tags