KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfServicesComponents > AlarmChannelProviderComposition > AlarmChannelProviderImpl


1 /*====================================================================
2
3 This file was produced by the OpenCCM CIF_JIMPL generator.
4
5 OpenCCM: The Open CORBA Component Model Platform
6 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
7 Contact: openccm@objectweb.org
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA
23
24 Initial developer(s): Christophe Demarey.
25 Contributor(s): ______________________________________.
26
27 ====================================================================*/

28
29 package ist.coach.coachEmfServicesComponents.AlarmChannelProviderComposition;
30
31
32 /**
33  * This is the CIDL-based implementation of the
34  * OMG IDL3 IDL:coach.ist/coachEmfServicesComponents/AlarmChannelProvider:1.0 component type.
35  *
36  * @author OpenCCM CIF_Jimpl Compiler.
37  */

38 public class AlarmChannelProviderImpl
39      extends ist.coach.coachEmfServicesComponents.AlarmChannelProviderComposition.AlarmChannelProvider_impl
40 {
41     // ==================================================================
42
//
43
// Internal states.
44
//
45
// ==================================================================
46
public static final String JavaDoc OBJECT_TYPE = "AlarmChannelProvider";
47         /* business logic */
48     private String JavaDoc _channelId = "Undefined";
49     private String JavaDoc[] _sourceClasses = null;
50     private String JavaDoc[] _excludedSourceClasses = null;
51     private String JavaDoc[] _eventTypes = null;
52     private String JavaDoc[] _excludedEventTypes = null;
53     intt.itu.itut_q816.ChannelFinderComponent channel_finder = null;
54
55         /* This boolean signifies that any change in the properties should trigger
56             notification of ChannelFinder
57          */

58     private boolean postInit = false;
59     private org.omg.CORBA.Object JavaDoc myself;
60     // ==================================================================
61
//
62
// Constructors.
63
//
64
// ==================================================================
65

66     public AlarmChannelProviderImpl()
67     {
68     }
69
70     // ==================================================================
71
//
72
// Methods.
73
//
74
// ==================================================================
75

76     /**
77      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::channelId attribute as accessor operation.
78      */

79     public String JavaDoc
80     channelId()
81     {
82        //
83
// DONE : implement
84
//
85
return _channelId;
86     }
87
88     /**
89      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::channelId attribute as mutator operation.
90      */

91     public void
92     channelId(String JavaDoc channelId)
93     {
94         //
95
// DONE : implement
96
//
97
if (channelId != null && ! "undefined".equals(channelId))
98             _channelId = new String JavaDoc(channelId);
99
100         System.err.println("Channel Id is set to " + _channelId);
101     }
102
103     /**
104      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::sourceClasses attribute as accessor operation.
105      */

106     public String JavaDoc[]
107     sourceClasses()
108     {
109         //
110
// DONE : implement
111
//
112
return _sourceClasses;
113     }
114
115     /**
116      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::sourceClasses attribute as mutator operation.
117      */

118     public void
119     sourceClasses(String JavaDoc[] sourceClasses)
120     {
121         //
122
// DONE : implement
123
//
124
System.err.print(channelId() + "AlarmChannelProvider will serve:");
125         if (sourceClasses == null)
126             _sourceClasses = new String JavaDoc[0];
127         else
128             _sourceClasses = sourceClasses;
129
130         if (postInit)
131             performUpdate();
132
133         for (int i = 0; i < _sourceClasses.length; i++)
134             System.err.print(_sourceClasses[i] + ", ");
135         System.err.println();
136     }
137
138     /**
139      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::excludedSourceClasses attribute as accessor operation.
140      */

141     public String JavaDoc[]
142     excludedSourceClasses()
143     {
144         //
145
// DONE : implement
146
//
147
return _excludedSourceClasses;
148     }
149
150     /**
151      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::excludedSourceClasses attribute as mutator operation.
152      */

153     public void
154     excludedSourceClasses(String JavaDoc[] excludedSourceClasses)
155     {
156         //
157
// DONE : implement
158
//
159
if (excludedSourceClasses == null)
160             _excludedSourceClasses = new String JavaDoc[0];
161         else
162             _excludedSourceClasses = excludedSourceClasses;
163
164         if (postInit)
165             performUpdate();
166
167     }
168
169     /**
170      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::eventTypes attribute as accessor operation.
171      */

172     public String JavaDoc[]
173     eventTypes()
174     {
175        //
176
// DONE : implement
177
//
178
return _eventTypes;
179     }
180
181     /**
182      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::eventTypes attribute as mutator operation.
183      */

184     public void
185     eventTypes(String JavaDoc[] eventTypes)
186     {
187         //
188
// DONE : implement
189
//
190

191         if (eventTypes == null)
192             _eventTypes = new String JavaDoc[0];
193         else
194             _eventTypes = eventTypes;
195
196         if (postInit)
197             performUpdate();
198
199         System.err.println(channelId() + " " + _eventTypes.length + " eventTypes supported..");
200     }
201
202     /**
203      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::excludedeventTypes attribute as accessor operation.
204      */

205     public String JavaDoc[]
206     excludedeventTypes()
207     {
208         //
209
// DONE : implement
210
//
211
return _excludedEventTypes;
212     }
213
214     /**
215      * Implementation of the ::coachEmfServicesComponents::CCM_AlarmChannelProvider_Executor::excludedeventTypes attribute as mutator operation.
216      */

217     public void
218     excludedeventTypes(String JavaDoc[] excludedeventTypes)
219     {
220         //
221
// DONE : implement
222
//
223
if (excludedeventTypes == null)
224             _excludedEventTypes = new String JavaDoc[0];
225         else
226             _excludedEventTypes = excludedeventTypes;
227
228         if (postInit)
229             performUpdate();
230
231     }
232
233     public void performUpdate() {
234
235         try {
236             channel_finder.update(_channelId,
237                                 OBJECT_TYPE,
238                                 _eventTypes,
239                                 _excludedEventTypes,
240                                 _sourceClasses,
241                                 _excludedSourceClasses,
242                                 myself);
243
244         }
245         catch(intt.itu.itut_x780.ApplicationError ex) {
246             System.err.println("Application Error exception caught while updating " +
247                 "AlarmChannelProvider " + _channelId + " to ChannelFinder");
248         }
249         catch(intt.itu.itut_q816.ChannelNotFound channel_ex) {
250             System.err.println("ChannelAlreadyRegistered exception caught while updating " +
251                 "AlarmChannelProvider " + _channelId + " to ChannelFinder");
252         }
253     }
254     // ==================================================================
255
//
256
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
257
//
258
// ==================================================================
259
//
260
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
261
//
262
/**
263      ** Completes the component configuration.
264      **
265      ** @throws org.omg.Components.InvalidConfiguration
266      ** Thrown if the configuration is invalid.
267      **/

268     public void
269     configuration_complete()
270     throws org.omg.Components.InvalidConfiguration
271     {
272         //
273
// DONE : implement !!!
274
//
275

276         System.err.println("AlarmChannelProvider configuration started...");
277         channel_finder = get_context().get_connection_channelfinder_admin();
278
279         if (channel_finder == null || _channelId == null) {
280             System.err.println("AlarmChannelProvider failed to locate ChannelFinder!");
281             throw new org.omg.Components.InvalidConfiguration();
282         }
283
284         if (_sourceClasses == null || _sourceClasses.length == 0) {
285             System.err.println("Alarm Channel sourceClasses are not set..Proceeding manually");
286             _sourceClasses = new String JavaDoc[1];
287             _sourceClasses[0] = "IpNode";
288
289             _excludedSourceClasses = new String JavaDoc[0];
290         }
291
292         if (_eventTypes == null || _eventTypes.length == 0) {
293             System.err.println("Alarm Channel eventTypes are not set..Proceeding manually");
294             _eventTypes = new String JavaDoc[6];
295             _eventTypes[0] = "ObjectCreation";
296             _eventTypes[1] = "ObjectDeletion";
297             _eventTypes[2] = "StateChangedEvent";
298             _eventTypes[3] = "Heartbeat";
299             _eventTypes[4] = "ChannelChangeEvent";
300             _eventTypes[5] = "OperationalViolation";
301
302             _excludedEventTypes = new String JavaDoc[0];
303         }
304
305
306         try {
307
308             //org.omg.CORBA.Object myself =
309
myself =
310                 ((org.omg.Components.SessionContext) get_context()).get_CCM_object();
311             if (myself == null)
312             System.err.println("AlarmChannelProvider there is a problem getting myself as a component!");
313
314             channel_finder.register(_channelId,
315                                     OBJECT_TYPE,
316                                     _eventTypes,
317                                     _excludedEventTypes,
318                                     _sourceClasses,
319                                     _excludedSourceClasses,
320                                     myself);
321
322         }
323         catch(intt.itu.itut_x780.ApplicationError ex) {
324             System.err.println("Application Error exception caught while registering " +
325                 "AlarmChannelProvider " + _channelId + " to ChannelFinder");
326         }
327         catch(intt.itu.itut_q816.ChannelAlreadyRegistered channel_ex) {
328             System.err.println("ChannelAlreadyRegistered exception caught while registering " +
329                 "AlarmChannelProvider " + _channelId + " to ChannelFinder");
330         }
331         catch(org.omg.Components.IllegalState state_ex) {
332             System.err.println("org.omg.Components.IllegalState exception caught while registering " +
333                 "AlarmChannelProvider " + _channelId + " to ChannelFinder");
334         }
335
336         postInit = true;
337         System.err.println(_channelId + " AlarmChannelProvider configuration completed...");
338
339
340     }
341
342     //
343
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
344
//
345
/**
346      *
347      * Called by the container when the component will be removed.
348      *
349      * @throws org.omg.Components.CCMException
350      * Thrown if a system level error occured.
351      */

352     public void
353     ccm_remove()
354     throws org.omg.Components.CCMException
355     {
356         //
357
// DONE: implement !!!
358
//
359
try {
360             channel_finder.unregister(_channelId);
361         }
362         catch(intt.itu.itut_q816.ChannelNotFound channel_ex) {
363             System.err.println("ChannelNotFound exception caught unregistering " +
364                 _channelId + " from ChannelFinderService ");
365
366         }
367         catch(intt.itu.itut_x780.ApplicationError ex) {
368             System.err.println("ApplicationError exception caught unregistering " +
369                 _channelId + " from ChannelFinderService ");
370         }
371     }
372 }
373
Popular Tags