KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > ManagedObjectClientMonolithicImpl


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

21 package ist.coach.coachEmfClientComponents;
22
23 import intt.itu.itut_x780.*;
24 import intt.itu.itut_q816.*;
25 import intt.itu.itut_x780.CreateErrorConst.*;
26 import intt.itu.itut_x780.ApplicationErrorConst.*;
27 import intt.itu.itut_x780.DeleteErrorConst.*;
28 import intt.itu.itut_m3120.ManagedElementFactory;
29 import intt.itu.itut_m3120.ManagedElementFactoryHelper;
30 import intt.itu.itut_m3120.ManagedElement_F;
31 import intt.itu.itut_m3120.ManagedElement_FHelper;
32
33 import ist.coach.coachEmfCommon.Utils;
34 import ist.coach.coachEmsMib.IpNodeFactory;
35 import ist.coach.coachEmsMib.*;
36
37 import ist.coach.coachEmfServicesComponents.AlarmChannelProvider;
38
39 import java.util.Hashtable JavaDoc;
40 import java.util.Vector JavaDoc;
41 import java.util.Enumeration JavaDoc;
42
43 import java.text.DateFormat JavaDoc;
44
45 import org.omg.CosNaming.NameComponent JavaDoc;
46 import ist.coach.coachEmfClientComponents.gui.GuiMaster;
47 /**
48  ** Implementation class for the
49  ** ::coachEmfClientComponents::ManagedObjectClient component.
50  **/

51 public class ManagedObjectClientMonolithicImpl
52        extends org.omg.CORBA.LocalObject JavaDoc
53        implements CCM_ManagedObjectClient,
54        org.omg.Components.SessionComponent,
55        ist.coach.coachEmfClientComponents.gui.GuiMaster
56 {
57     // ==================================================================
58
//
59
// Internal State.
60
//
61
// ===================================================================
62
/**
63      ** Context reference.
64      **/

65     private CCM_ManagedObjectClient_Context the_context_ = null;
66
67     /** Business Logic **/
68     ist.coach.itut_q816Components.ChannelFinderProvider channel_finder = null;
69     ist.coach.coachEmfClientComponents.gui.GuiClient ui_client = null;
70     private String JavaDoc name_;
71     org.omg.CosNaming.NamingContext JavaDoc root_context;
72
73             // need reference to this object as ManagedObjectClient
74
ManagedObjectClient myself = null;
75
76     Hashtable JavaDoc alarmProviders;
77
78
79     // ==================================================================
80
//
81
// Constructor.
82
//
83
// ===================================================================
84
/**
85      ** The default constructor.
86      **/

87     public
88     ManagedObjectClientMonolithicImpl()
89     {
90         alarmProviders = new Hashtable JavaDoc();
91     }
92     // ==================================================================
93
//
94
// Internal methods.
95
//
96
// ===================================================================
97
// ==================================================================
98
//
99
// Public methods.
100
//
101
// ===================================================================
102
/**
103      ** To obtain the context.
104      **
105      ** @return The context that has been previously set by
106      ** the set_session_context operation.
107      **/

108     public CCM_ManagedObjectClient_Context
109     getContext()
110     {
111         return the_context_;
112     }
113     // ==================================================================
114
//
115
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
116
//
117
// ==================================================================
118
//
119
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
120
//
121
/**
122      ** Completes the component configuration.
123      **
124      ** @throws org.omg.Components.InvalidConfiguration
125      ** Thrown if the configuration is invalid.
126      **/

127     public void
128     configuration_complete()
129     throws org.omg.Components.InvalidConfiguration
130     {
131         System.err.println("Client configuration called...");
132         //
133
// DONE : implement !!!
134
//
135
// HACK: NameService is not needed when defered deployment is implemented
136
try {
137             org.omg.CORBA.ORB JavaDoc orb =
138                 org.objectweb.ccm.CORBA.TheORB.getORB();
139
140             org.omg.CORBA.Object JavaDoc obj =
141                 orb.resolve_initial_references("NameService");
142             root_context = org.omg.CosNaming.NamingContextHelper.narrow(obj);
143         }
144         catch(Exception JavaDoc e_c) {
145             System.err.println("Exception caught will resolving naming service: "
146                     + e_c.getMessage());
147             e_c.printStackTrace();
148         }
149
150         //
151
// Register to all channels!!
152
//
153
NameComponent JavaDoc[] channel_finder_name = new NameComponent JavaDoc[2];
154         channel_finder_name[0] = new NameComponent JavaDoc("coach", "ist");
155         channel_finder_name[1] = new NameComponent JavaDoc("", "ChannelFinderService");
156
157         try {
158              org.omg.CORBA.Object JavaDoc obj =
159                     root_context.resolve(channel_finder_name);
160             channel_finder = ist.coach.itut_q816Components.ChannelFinderProviderHelper.narrow(obj);
161
162             if (channel_finder != null) {
163
164                 ChannelInfoType[] available_channels = channel_finder.provide_query().list();
165
166                 org.omg.CORBA.Object JavaDoc myself_o;
167                 myself_o = ((org.omg.Components.SessionContext) the_context_).get_CCM_object();
168                 myself = ManagedObjectClientHelper.narrow(myself_o);
169
170                 AlarmChannelProvider alarm_channel_provider = null;
171                 for (int i = 0; i < available_channels.length; i++) {
172
173                     if (available_channels[i].channel != null) {
174                             alarm_channel_provider =
175                         ist.coach.coachEmfServicesComponents.AlarmChannelProviderHelper.narrow(
176                                 available_channels[i].channel);
177
178                             if (alarm_channel_provider == null) {
179                                 System.err.println("alarm_channel_provider is null");
180                                 continue;
181                             }
182
183                             String JavaDoc[] eventTypes = alarm_channel_provider.eventTypes();
184                             System.err.println("eventTypes.length = " + eventTypes.length);
185
186                             Vector JavaDoc alarmTypeV = new Vector JavaDoc();
187                             for (int j = 0; j < eventTypes.length; j++) {
188                                 //System.err.println("--->INITIATING SUBSCRIPTION FOR " +
189
// eventTypes[j]);
190
add_alarm_provider(alarm_channel_provider, eventTypes[j]);
191                                     subscribe_alarm(eventTypes[j]);
192
193                             }
194
195                     }
196                 }
197             }
198             else
199                 System.err.println("Client> ChannelFinder reference is null...");
200         }
201         catch(Exception JavaDoc e) {
202                 System.err.println("Client> Could not locate ChannelFinder so that to " +
203                     " subscribe to alarms!");
204                 System.err.println("Message: " + e.getMessage());
205                 e.printStackTrace();
206         }
207
208         //
209
// Start the gui
210
//
211
//HACK THREAD
212
new Thread JavaDoc(ui_client = new ist.coach.coachEmfClientComponents.gui.GuiClient(name_, this));
213         //ui_client = new ist.coach.coachEmfClientComponents.gui.GuiClient(name_, this);
214
System.err.println("Client configuration completed...");
215     }
216     // ==================================================================
217
//
218
// Methods for the OMG IDL Components::SessionComponent local interface.
219
//
220
// ==================================================================
221
//
222
// IDL:omg.org/Components/SessionComponent/set_session_context:1.0
223
//
224
/**
225      * Called by the container when the component session context will be fixed.
226      *
227      * @param context The session context.
228      *
229      * @throws org.omg.Components.CCMException
230      * Thrown if a system level error occured.
231      */

232     public void
233     set_session_context(org.omg.Components.SessionContext context)
234     throws org.omg.Components.CCMException
235     {
236         the_context_ = (CCM_ManagedObjectClient_Context)context;
237     }
238     //
239
// IDL:omg.org/Components/SessionComponent/ccm_activate:1.0
240
//
241
/**
242      *
243      * Called by the container when the component will be activated.
244      *
245      * @throws org.omg.Components.CCMException
246      * Thrown if a system level error occured.
247      */

248     public void
249     ccm_activate()
250     throws org.omg.Components.CCMException
251     {
252         //
253
// Unused by actual OpenCCM containers
254
//
255
}
256     //
257
// IDL:omg.org/Components/SessionComponent/ccm_passivate:1.0
258
//
259
/**
260      *
261      * Called by the container when the component will be passivated.
262      *
263      * @throws org.omg.Components.CCMException
264      * Thrown if a system level error occured.
265      */

266     public void
267     ccm_passivate()
268     throws org.omg.Components.CCMException
269     {
270         //
271
// Unused by actual OpenCCM containers
272
//
273
}
274     //
275
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
276
//
277
/**
278      *
279      * Called by the container when the component will be removed.
280      *
281      * @throws org.omg.Components.CCMException
282      * Thrown if a system level error occured.
283      */

284     public void
285     ccm_remove()
286     throws org.omg.Components.CCMException
287     {
288         //
289
// DONE: implement !!!
290
//
291
// Release the associated gui client.
292
ui_client.dispose();
293
294     }
295
296     public void add_alarm_provider(AlarmChannelProvider alarm_channel_provider,
297                         String JavaDoc alarmType) {
298
299
300         Vector JavaDoc alarmTypeV = new Vector JavaDoc();
301
302         if (alarmProviders.containsKey(alarmType))
303             alarmTypeV = (Vector JavaDoc) alarmProviders.remove(alarmType);
304
305         AlarmSubscriptionInfo alarm_channel_provider_record;
306         int alarmTypeV_size = alarmTypeV.size();
307
308         for(int i = 0; i < alarmTypeV_size; i++) {
309             alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i);
310             if (alarm_channel_provider_record.alarm_channel_provider.channelId().equals(
311                     alarm_channel_provider.channelId()))
312                     alarmTypeV.removeElementAt(i);
313         }
314         alarm_channel_provider_record = new AlarmSubscriptionInfo(alarm_channel_provider, null);
315         alarmTypeV.add(alarm_channel_provider_record);
316
317         alarmProviders.put(alarmType, alarmTypeV);
318 // System.err.println("Addinf provider of " + alarmType + " alarms");
319

320     }
321
322     public void subscribe_alarm(String JavaDoc alarmType) {
323
324
325         if (! alarmProviders.containsKey(alarmType))
326             return;
327
328         Vector JavaDoc alarmTypeV = new Vector JavaDoc();
329         alarmTypeV = (Vector JavaDoc) alarmProviders.get(alarmType);
330
331         int alarmTypeV_size = alarmTypeV.size();
332
333         AlarmChannelProvider alarm_channel_provider = null;
334         org.omg.Components.Cookie ck = null;
335
336         AlarmSubscriptionInfo alarm_channel_provider_record;
337
338         for(int i = 0; i < alarmTypeV_size; i++) {
339
340             alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i);
341             alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider;
342
343           try {
344             if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) {
345                   ck = alarm_channel_provider.subscribe_objectCreation_alarm(
346                         myself.get_consumer_object_creation_alarm());
347             }
348             else
349             if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) {
350                   ck = alarm_channel_provider.subscribe_objectDeletion_alarm(
351                        myself.get_consumer_object_deletion_alarm());
352             }
353             else
354             if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) {
355                 ck = alarm_channel_provider.subscribe_stateChanged_alarm(
356                        myself.get_consumer_state_changed_alarm());
357             }
358             else
359             if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) {
360                 ck = alarm_channel_provider.subscribe_operational_alarm(
361                        myself.get_consumer_operational_violation_alarm());
362             }
363             else
364             if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) {
365                     ck = alarm_channel_provider.subscribe_heartbeat_event(
366                      myself.get_consumer_heartbeat_alarm());
367             }
368             else
369             if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) {
370                 ck = alarm_channel_provider.subscribe_channelChange_event(
371                     myself.get_consumer_channel_change_alarm());
372             }
373           }
374           catch(org.omg.Components.ExceededConnectionLimit ex1) {
375             System.err.println("org.omg.Components.ExceededConnectionLimit caught " +
376                     ex1.getMessage());
377             }
378
379             if (ck == null) {
380                     System.err.println("Subscription cookie of " + alarmType +
381                             " is NULL!");
382                   continue;
383             }
384
385             AlarmSubscriptionInfo info = new AlarmSubscriptionInfo(
386                         alarm_channel_provider, ck);
387
388             alarmTypeV = (Vector JavaDoc) alarmProviders.remove(alarmType);
389             alarmTypeV.removeElementAt(i);
390             alarmTypeV.add(info);
391
392             alarmProviders.put(alarmType, alarmTypeV);
393             System.err.println("Subscription for " + alarmType + " finished!");
394         }
395     }
396
397     public void unsubscribe_alarm(String JavaDoc alarmType) {
398
399     if (! alarmProviders.containsKey(alarmType))
400             return;
401
402         Vector JavaDoc alarmTypeV = new Vector JavaDoc();
403         alarmTypeV = (Vector JavaDoc) alarmProviders.get(alarmType);
404
405         int alarmTypeV_size = alarmTypeV.size();
406
407         AlarmChannelProvider alarm_channel_provider = null;
408         org.omg.Components.Cookie ck = null;
409
410         AlarmSubscriptionInfo alarm_channel_provider_record;
411         org.omg.Components.Cookie cookie = null;
412
413         for(int i = 0; i < alarmTypeV_size; i++) {
414
415             alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i);
416             alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider;
417             cookie = alarm_channel_provider_record.cookie;
418
419             if (cookie == null)
420                 continue;
421
422           try {
423             if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) {
424                   alarm_channel_provider.unsubscribe_objectCreation_alarm(cookie);
425             }
426             else
427             if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) {
428                   alarm_channel_provider.unsubscribe_objectDeletion_alarm(cookie);
429             }
430             else
431             if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) {
432                 alarm_channel_provider.unsubscribe_stateChanged_alarm(cookie);
433             }
434             else
435             if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) {
436                 alarm_channel_provider.unsubscribe_operational_alarm(cookie);
437             }
438             else
439             if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) {
440                 alarm_channel_provider.unsubscribe_heartbeat_event(cookie);
441             }
442             else
443             if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) {
444                 alarm_channel_provider.unsubscribe_channelChange_event(cookie);
445             }
446
447           }
448           catch(org.omg.Components.InvalidConnection ex1) {}
449         }
450     }
451
452     public void set_heartbeat_period(short period) {
453
454           NameComponent JavaDoc[] heartbeat_name =new NameComponent JavaDoc[2];
455           heartbeat_name[0] = new NameComponent JavaDoc("coach", "ist");
456           heartbeat_name[1] = new NameComponent JavaDoc("", "HeartbeatService");
457
458           try {
459             org.omg.CORBA.Object JavaDoc obj = root_context.resolve(heartbeat_name);
460
461             ist.coach.itut_q816Components.HeartbeatProvider heartbeat_provider =
462               ist.coach.itut_q816Components.HeartbeatProviderHelper.narrow(obj);
463
464                 heartbeat_provider.provide_admin().periodSet(period);
465           }
466           catch(Exception JavaDoc e) {
467             System.err.println("Client: set_heartbeat_period> Caught Exception " +
468                   e.getMessage());
469             e.printStackTrace(System.err);
470           }
471     }
472
473     // ==================================================================
474
//
475
// Public methods for the CCM_ManagedObjectClient local interface.
476
//
477
// ==================================================================
478
//
479
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_object_creation_alarm:1.0
480
//
481
/**
482      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_object_creation_alarm operation.
483      **/

484     public void
485     push_object_creation_alarm(ist.coach.itut_q816Components.ObjectCreation event)
486     {
487         //
488
// TODO : implement
489
//
490
System.err.println("---->ObjectCreation received: ");
491         System.err.println("Source Object Name = " + Utils.name2string(event.source));
492         System.err.println("Source Object Type = " + event.sourceClass);
493         System.err.println("Notification Id = " + String.valueOf(
494                     event.notificationIdentifier));
495         System.err.println("Time = " + String.valueOf(event.eventTime.time));
496
497         java.util.Date JavaDoc event_date = new java.util.Date JavaDoc(event.eventTime.time);
498         DateFormat JavaDoc df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
499         String JavaDoc time_str = df.format(event_date);
500
501         ui_client.print_alarm(time_str,
502                 ist.coach.coachEmfClientComponents.gui.GuiMessages.object_creation_alarm,
503                 Utils.name2string(event.source), event.sourceClass,
504                 String.valueOf(event.notificationIdentifier), " ");
505     }
506     //
507
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_object_deletion_alarm:1.0
508
//
509
/**
510      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_object_deletion_alarm operation.
511      **/

512     public void
513     push_object_deletion_alarm(ist.coach.itut_q816Components.ObjectDeletion event)
514     {
515         //
516
// TODO : implement
517
//
518
System.err.println("---->ObjectDeletion received: ");
519         System.err.println("Source Object Name = " + Utils.name2string(event.source));
520         System.err.println("Source Object Type = " + event.sourceClass);
521         System.err.println("Notification Id = " + event.notificationIdentifier);
522
523         java.util.Date JavaDoc event_date = new java.util.Date JavaDoc(event.eventTime.time);
524         DateFormat JavaDoc df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
525         String JavaDoc time_str = df.format(event_date);
526
527
528         ui_client.print_alarm(time_str,
529                 ist.coach.coachEmfClientComponents.gui.GuiMessages.object_deletion_alarm,
530                 Utils.name2string(event.source), event.sourceClass,
531                 String.valueOf(event.notificationIdentifier), "");
532     }
533     //
534
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_operational_violation_alarm:1.0
535
//
536
/**
537      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_operational_violation_alarm operation.
538      **/

539     public void
540     push_operational_violation_alarm(ist.coach.itut_q816Components.OperationalViolation event)
541     {
542         //
543
// TODO : implement
544
//
545
System.err.println("---->OperationalViolation received: ");
546         System.err.println("Source Object Name = " + Utils.name2string(event.source));
547         System.err.println("Source Object Type = " + event.sourceClass);
548         System.err.println("Notification Id = " + event.notificationIdentifier);
549
550         java.util.Date JavaDoc event_date = new java.util.Date JavaDoc(event.eventTime.time);
551         DateFormat JavaDoc df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
552         String JavaDoc time_str = df.format(event_date);
553
554         ui_client.print_alarm(time_str,
555                 ist.coach.coachEmfClientComponents.gui.GuiMessages.operation_violation_alarm,
556                 Utils.name2string(event.source), event.sourceClass,
557                 String.valueOf(event.notificationIdentifier), "");
558     }
559     //
560
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_state_changed_alarm:1.0
561
//
562
/**
563      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_state_changed_alarm operation.
564      **/

565     public void
566     push_state_changed_alarm(ist.coach.itut_q816Components.StateChangedEvent event)
567     {
568         //
569
// DONE : implement
570
//
571
System.err.println("---->StateChangedEvent received: ");
572         System.err.println("Source Object Name = " + Utils.name2string(event.source));
573         System.err.println("Source Object Type = " + event.sourceClass);
574         System.err.println("Notification Id = " + event.notificationIdentifier);
575         String JavaDoc details = new String JavaDoc();
576         for(int i = 0; i < event.attributeList.length; i++) {
577           details += event.attributeList[i].attributeName + " changed ";
578           if (event.attributeList[i].oldValue != null) {
579             OperationalStateType oldState = OperationalStateTypeHelper.extract(
580                       event.attributeList[i].oldValue);
581             details += " from ";
582             switch(oldState.value()) {
583               case OperationalStateType._disabled :
584                 details += "Disabled";
585                  break;
586               case OperationalStateType._enabled :
587                 details += "Enabled";
588                 break;
589               default:
590                 details += "Unknown";
591            }
592           }
593           if (event.attributeList[i].newValue != null) {
594             OperationalStateType newState = OperationalStateTypeHelper.extract(
595                       event.attributeList[i].newValue);
596             details += " to ";
597             switch(newState.value()) {
598               case OperationalStateType._disabled :
599                 details += "Disabled";
600                  break;
601               case OperationalStateType._enabled :
602                 details += "Enabled";
603                 break;
604               default:
605                 details += "Unknown";
606            }
607           }
608         }
609
610         java.util.Date JavaDoc event_date = new java.util.Date JavaDoc(event.eventTime.time);
611         DateFormat JavaDoc df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
612         String JavaDoc time_str = df.format(event_date);
613
614         ui_client.print_alarm(time_str,
615                 ist.coach.coachEmfClientComponents.gui.GuiMessages.state_changed_alarm,
616                 Utils.name2string(event.source), event.sourceClass,
617                 String.valueOf(event.notificationIdentifier), details);
618     }
619     //
620
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_channel_change_alarm:1.0
621
//
622
/**
623      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_channel_change_alarm operation.
624      **/

625     public void
626     push_channel_change_alarm(ist.coach.itut_q816Components.ChannelChangeEvent event)
627     {
628         //
629
// TODO : implement
630
//
631
ui_client.print_alarm("",
632                 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm,
633                 "", "", "", "");
634     }
635     //
636
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_heartbeat_alarm:1.0
637
//
638
/**
639      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_heartbeat_alarm operation.
640      **/

641     public void
642     push_heartbeat_alarm(ist.coach.itut_q816Components.Heartbeat event)
643     {
644         //
645
// TODO : implement
646
//
647
java.util.Date JavaDoc event_date = new java.util.Date JavaDoc(event.timeStamp.time);
648         DateFormat JavaDoc df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
649         String JavaDoc time_str = df.format(event_date);
650         ui_client.print_alarm(time_str,
651                 ist.coach.coachEmfClientComponents.gui.GuiMessages.heartbeat_alarm,
652                 event.channelID, "AlarmChannel",
653                 "", "");
654     }
655     //
656
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_l_attribute_value_change_alarm:1.0
657
//
658
/**
659      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_l_attribute_value_change_alarm operation.
660      **/

661     public void
662     push_l_attribute_value_change_alarm(ist.coach.coachEmfServicesComponents.LogAttributeValueChange event)
663     {
664         //
665
// TODO : implement
666
//
667
}
668     //
669
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_l_threshold_alarm:1.0
670
//
671
/**
672      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_l_threshold_alarm operation.
673      **/

674     public void
675     push_l_threshold_alarm(ist.coach.coachEmfServicesComponents.LogThresholdAlarm event)
676     {
677         //
678
// TODO : implement
679
//
680
}
681     //
682
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient_Executor/name:1.0
683
//
684
/**
685      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::name attribute as accessor operation.
686      **/

687     public java.lang.String JavaDoc
688     name()
689     {
690         //
691
// DONE : implement
692
//
693
return name_;
694     }
695
696     /**
697      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::name attribute as mutator operation.
698      **/

699     public void
700     name(java.lang.String JavaDoc val)
701     {
702         //
703
// DONE : implement
704
//
705

706         name_ = val;
707         if (ui_client != null)
708             ui_client.set_name(name_);
709         System.err.println("Name is set to " + name_);
710     }
711
712     // ==================================================================
713
//
714
// Methods for the ist.coach.coachEmfClientComponents.gui.GuiMaster interface
715
//
716
// ==================================================================
717

718     public void print(String JavaDoc msg) {
719         ui_client.print(msg);
720         // HACK - Use of trace can be exploited
721
System.out.print(msg);
722     }
723
724     public void println(String JavaDoc msg) {
725         ui_client.println(msg);
726         System.out.println(msg);
727     }
728
729     public String JavaDoc createByManager(String JavaDoc object_class,
730                         String JavaDoc[] param_names,
731                         Object JavaDoc[] values,
732                         String JavaDoc parent_key_val) {
733
734         NameComponent JavaDoc[] parent_object_key = Utils.string2name(parent_key_val);
735         String JavaDoc new_object_key = (values != null && values.length > 0) ?
736             (String JavaDoc) values[0] : new String JavaDoc();
737
738         //println("create is called on " + object_class);
739
//println("param_names = " + param_names[0]);
740
//println("param_val = " + (String) values[0]);
741

742         try {
743
744             NameComponent JavaDoc[] factoryfinder_name =new NameComponent JavaDoc[2];
745             factoryfinder_name[0] = new NameComponent JavaDoc("coach", "ist");
746             factoryfinder_name[1] = new NameComponent JavaDoc("", "FactoryFinder");
747
748             org.omg.CORBA.Object JavaDoc obj = root_context.resolve(factoryfinder_name);
749
750              ist.coach.itut_q816Components.FactoryFinderProvider factory_finder =
751                 ist.coach.itut_q816Components.FactoryFinderProviderHelper.narrow(obj);
752
753             ManagedObjectFactory mobject_f = factory_finder.provide_query().find(
754                             object_class + "Factory");
755
756 /***
757              ManagedObjectFactory mobject_f =
758                 ManagedObjectFactoryHelper.narrow(
759                      factory_finder.provide_query().find(
760                 object_class + "Factory"));
761         **/

762
763             /** NameBinding is <subordinate_class>_<superior_class>.
764                 If superior class is the root object then kind is organisation
765             */

766             String JavaDoc nameBinding = object_class + "_"
767                     + Utils.name2kind(parent_key_val);
768             System.err.println("Name Binding is " + nameBinding);
769
770             if (mobject_f == null) {
771                 System.err.println("Factory Object was null!!");
772                  return new String JavaDoc();
773             }
774
775             NameComponent JavaDoc[] new_name = null;
776             //new_object_key = new String();
777

778                 /* HACK: INTROSPECTION COULD BE EXPLORED!! */
779             if (object_class.equals("ManagedObject")) {
780                  new_name = mobject_f.create_base(nameBinding,
781                                 parent_object_key, new_object_key);
782             }
783             else
784             if (object_class.equals("ManagedElement")) {
785
786                 ManagedElementFactory element_factory =
787                   ManagedElementFactoryHelper.narrow(mobject_f);
788
789                 String JavaDoc userLabel = new String JavaDoc();
790                 if (values.length > 1 && values[1] != null)
791                     userLabel = (String JavaDoc) values[1];
792                 System.err.print("userLabel = " + userLabel + ", ");
793
794                 String JavaDoc vendorName = new String JavaDoc();
795                 if (values.length > 2 && values[2] != null)
796                     vendorName = (String JavaDoc) values[2];
797                 System.err.print("vendorName = " + vendorName + ", ");
798
799                 String JavaDoc version = new String JavaDoc();
800                 if (values.length > 3 && values[3] != null)
801                     version = (String JavaDoc) values[3];
802                 System.err.print("version = " + version + ", ");
803
804                 String JavaDoc locationName = new String JavaDoc();
805                 if (values.length > 4 && values[4] != null)
806                     locationName = (String JavaDoc) values[4];
807                 System.err.println("locationName = " + locationName);
808
809                 new_name = element_factory.create(nameBinding,
810                                     parent_object_key,
811                                     new_object_key,
812                                     new String JavaDoc[0],
813                                     intt.itu.itut_x780.AdministrativeStateType.locked,
814                                     userLabel,
815                                     vendorName,
816                                     version,
817                                     locationName
818               );
819
820             }
821             else
822             if (object_class.equals("IpNode")) {
823
824                 IpNodeFactory ipnode_factory = IpNodeFactoryHelper.narrow(
825                         mobject_f);
826
827                 String JavaDoc domainName = new String JavaDoc();
828                 if (values.length > 1 && values[1] != null)
829                     domainName = (String JavaDoc) values[1];
830                 System.err.print("domainName = " + domainName + ", ");
831
832                 String JavaDoc hostname = new String JavaDoc();
833                 if (values.length > 2 && values[2] != null)
834                     hostname = (String JavaDoc) values[2];
835                 System.err.print("hostname = " + hostname + ", ");
836
837                 byte[] managementIPAddress = new byte[0];
838                 if (values.length > 3 && values[3] != null)
839                     managementIPAddress = ((String JavaDoc) values[3]).getBytes();
840                 System.err.print("managementIPAddress = " + values[3] + ", ");
841
842                 int supportedSnmpVersions = 0;
843                 if (values.length > 4 && values[4] != null)
844                     supportedSnmpVersions = Integer.parseInt((String JavaDoc) values[4]);
845                 System.err.println("supportedSnmpVersions = " + supportedSnmpVersions);
846
847                 String JavaDoc userLabel = new String JavaDoc();
848                 if (values.length > 5 && values[5] != null)
849                     userLabel = (String JavaDoc) values[5];
850                 System.err.print("userLabel = " + userLabel + ", ");
851
852                 String JavaDoc vendorName = new String JavaDoc();
853                 if (values.length > 6 && values[6] != null)
854                     vendorName = (String JavaDoc) values[6];
855                 System.err.print("vendorName = " + vendorName + ", ");
856
857                 String JavaDoc version = new String JavaDoc();
858                 if (values.length > 7 && values[7] != null)
859                     version = (String JavaDoc) values[7];
860                 System.err.print("version = " + version + ", ");
861
862                 String JavaDoc locationName = new String JavaDoc();
863                 if (values.length > 8 && values[8] != null)
864                     locationName = (String JavaDoc) values[8];
865                 System.err.println("locationName = " + locationName);
866
867                 int snmpPort = 0;
868                 if (values.length > 9 && values[9] != null)
869                     snmpPort = Integer.parseInt((String JavaDoc) values[9]);
870                 System.err.print("snmpPort = " + snmpPort + ", ");
871
872                 String JavaDoc sysName = new String JavaDoc();
873                 if (values.length > 10 && values[10] != null)
874                     sysName = (String JavaDoc) values[10];
875                 System.err.print("sysName = " + values[10] + ", ");
876
877                 String JavaDoc sysContact = new String JavaDoc();
878                 if (values.length > 11 && values[11] != null)
879                     sysContact = (String JavaDoc) values[11];
880                 System.err.print("sysContact = " + values[11]);
881
882                  //new_name = ((IpNodeFactory) mobject_f).create(nameBinding,
883
System.err.println("Ready to call create on IpNodeFactory!");
884                  new_name = ipnode_factory.create(nameBinding,
885                                     parent_object_key,
886                                     new_object_key,
887                                     new String JavaDoc[0],
888                                     domainName,
889                                     hostname,
890                                     managementIPAddress,
891                                     supportedSnmpVersions,
892                                     intt.itu.itut_x780.AdministrativeStateType.locked,
893                                     userLabel,
894                                     vendorName,
895                                     version,
896                                     locationName,
897                                     snmpPort,
898                                     sysName,
899                                     sysContact
900                             );
901
902             }
903             if (new_name != null && new_name.length > 0) {
904                 new_object_key = Utils.name2string(new_name);
905             }
906             else
907                 new_object_key = new String JavaDoc();
908         }
909         catch(CreateError create_e) {
910             treat_create_exceptions(create_e);
911             new_object_key = new String JavaDoc();
912         }
913         catch(ApplicationError appl_e) {
914             treat_application_exceptions(appl_e);
915             new_object_key = new String JavaDoc();
916         }
917         catch(Exception JavaDoc e_c) {
918             System.err.println("Exception caught: " + e_c.getMessage());
919             e_c.printStackTrace();
920             new_object_key = new String JavaDoc();
921         }
922
923         return new_object_key;
924     }
925
926     public boolean removeByManager(String JavaDoc name) {
927
928         if (name == null || name.length() == 0)
929             return false;
930
931         try {
932             NameComponent JavaDoc[] terminator_name = new NameComponent JavaDoc[2];
933             terminator_name[0] = new NameComponent JavaDoc("coach", "ist");
934             terminator_name[1] = new NameComponent JavaDoc("", "TerminatorService");
935
936             org.omg.CORBA.Object JavaDoc obj = root_context.resolve(terminator_name);
937
938             ist.coach.itut_q816Components.TerminatorServiceProvider terminator =
939                 ist.coach.itut_q816Components.TerminatorServiceProviderHelper.narrow(obj);
940
941             if (terminator != null) {
942                 terminator.provide_terminator().deleteByName(Utils.string2name(name));
943                 return true;
944             }
945
946         }
947         catch(DeleteError delete_e) {
948             treat_delete_exceptions(delete_e);
949             return false;
950         }
951         catch(Exception JavaDoc e_c) {
952             System.err.println("Exception caught: " + e_c.getMessage());
953             e_c.printStackTrace();
954             return false;
955         }
956         return false;
957
958     }
959
960     public ManagedObjectValueType attributesGet(String JavaDoc object_class,
961                                 String JavaDoc object_key,
962                                 String JavaDoc []attributes) {
963
964
965         System.err.println("\n--->attributesGet is called for " + object_key +
966                 " of type " + object_class);
967
968         ManagedObjectValueType attributes_values = null;
969         NameComponent JavaDoc[] facade_name = new NameComponent JavaDoc[2];
970         try {
971             if (object_key == null || object_key.length() == 0)
972                 return null;
973
974             facade_name[0] = new NameComponent JavaDoc("coach", "ist");
975             facade_name[1] =
976                 //new NameComponent("", object_class + "Facade");
977
new NameComponent JavaDoc("", Utils.name2facade(object_key));
978
979             //System.err.println("Before resolving " + Utils.name2string(facade_name));
980
org.omg.CORBA.Object JavaDoc obj = root_context.resolve(facade_name);
981
982             //System.err.println("Before narrowing " + Utils.name2string(facade_name));
983

984             intt.itu.itut_x780.ManagedObject_F mobject_f =
985             intt.itu.itut_x780.ManagedObject_FHelper.narrow(obj);
986             //ist.coach.itut_x780Components.ManagedObjectProvider mobject_f =
987
//ist.coach.itut_x780Components.ManagedObjectProviderHelper.narrow(obj);
988

989             if (mobject_f == null) {
990                 System.err.println("Facade object can not be found!");
991                 return null;
992             }
993
994             NameComponent JavaDoc[] obj_name = Utils.string2name(object_key);
995
996             attributes_values = (ManagedObjectValueType) mobject_f.attributesGet(
997                     Utils.string2name(object_key),
998                     new intt.itu.itut_x780.StringSetTypeHolder(attributes));
999
1000        }
1001        catch(ApplicationError appl_e) {
1002            treat_application_exceptions(appl_e);
1003        }
1004        catch(Exception JavaDoc e_c) {
1005            System.err.println("Exception caught>"
1006                    + Utils.name2string(facade_name) +
1007                        ": " + e_c.getMessage());
1008            e_c.printStackTrace();
1009        }
1010
1011        return attributes_values;
1012    }
1013
1014    public String JavaDoc[] getContained(String JavaDoc superior) {
1015
1016        //System.err.println("\n--->getContained is called for " + superior);
1017
String JavaDoc[] subordinates = new String JavaDoc[0];
1018        try {
1019
1020            NameComponent JavaDoc[] c_query = new NameComponent JavaDoc[2];
1021            c_query[0] = new NameComponent JavaDoc("coach", "ist");
1022            c_query[1] = new NameComponent JavaDoc("", "ContainmentService");
1023            org.omg.CORBA.Object JavaDoc obj = root_context.resolve(c_query);
1024
1025            ist.coach.itut_q816Components.ContainmentServiceProvider containment =
1026                ist.coach.itut_q816Components.ContainmentServiceProviderHelper.narrow(obj);
1027
1028            if (containment != null) {
1029                NameComponent JavaDoc[][] children =
1030                    containment.provide_containment_query().getContained(
1031                        Utils.string2name(superior));
1032            //println("Get contained " + superior + " returned " + children.length+ " children");
1033

1034                if (children != null && children.length > 0) {
1035                    subordinates = new String JavaDoc[children.length];
1036                    for(int i = 0; i < subordinates.length; i++)
1037                        subordinates[i] = Utils.name2string(children[i]);
1038                }
1039            }
1040        }
1041        catch(Exception JavaDoc e_c) {
1042            System.err.println("Exception caught: " + e_c.getMessage());
1043            e_c.printStackTrace();
1044        }
1045
1046        return subordinates;
1047    }
1048
1049    public boolean setAttributes(String JavaDoc object_key, Vector JavaDoc set_data) {
1050
1051        System.err.println("setAttributes is called on " + object_key +
1052                " of type " + Utils.name2kind(object_key));
1053
1054        if (object_key == null || object_key.length() == 0)
1055                return false;
1056
1057        String JavaDoc objectkind = Utils.name2kind(object_key);
1058        NameComponent JavaDoc[] facade_name = new NameComponent JavaDoc[2];
1059        try {
1060            facade_name[0] = new NameComponent JavaDoc("coach", "ist");
1061            facade_name[1] =
1062                new NameComponent JavaDoc("", Utils.name2facade(object_key));
1063             org.omg.CORBA.Object JavaDoc obj = root_context.resolve(facade_name);
1064
1065            if (objectkind.equals("ManagedElement")) {
1066
1067                ManagedElement_F facade = ManagedElement_FHelper.narrow(obj);
1068                Enumeration JavaDoc set_operations = set_data.elements();
1069                while(set_operations.hasMoreElements()) {
1070                    InvokeSetData set_method = (InvokeSetData) set_operations.nextElement();
1071                    set_method.methodName.invoke(facade, set_method.methodArguments);
1072                }
1073            }
1074            else
1075            if (objectkind.equals("IpNode")) {
1076
1077                IpNode_F facade = IpNode_FHelper.narrow(obj);
1078                Enumeration JavaDoc set_operations = set_data.elements();
1079                while(set_operations.hasMoreElements()) {
1080                    InvokeSetData set_method = (InvokeSetData) set_operations.nextElement();
1081                    set_method.methodName.invoke(facade, set_method.methodArguments);
1082                }
1083            }
1084            else
1085            if (objectkind.equals("LogicalInterface")) {
1086                LogicalInterface_F facade = LogicalInterface_FHelper.narrow(obj);
1087                Enumeration JavaDoc set_operations = set_data.elements();
1088                while(set_operations.hasMoreElements()) {
1089                    InvokeSetData set_method = (InvokeSetData) set_operations.nextElement();
1090                    set_method.methodName.invoke(facade, set_method.methodArguments);
1091                }
1092            }
1093
1094
1095        }
1096        //catch(ApplicationError appl_e) {
1097
// treat_application_exceptions(appl_e);
1098
// return false;
1099
//}
1100
catch(Exception JavaDoc e_c) {
1101            System.err.println("Exception caught>"
1102                    + Utils.name2string(facade_name) +
1103                        ": " + e_c.getMessage());
1104            e_c.printStackTrace();
1105            return false;
1106        }
1107        return true;
1108    }
1109
1110
1111    public void treat_create_exceptions(CreateError create_e) {
1112        System.err.println("Client caught exception during create operation:");
1113            switch(create_e.info.error.value) {
1114                case intt.itu.itut_x780.CreateErrorConst.duplicateName.value :
1115                    System.err.println("Object already exists");
1116                    System.err.println(create_e.info.details);
1117                    break;
1118                case intt.itu.itut_x780.CreateErrorConst.invalidNameBinding.value :
1119                    System.err.println("InvalidNameBinding has been provided");
1120                    System.err.println(create_e.info.details);
1121                    break;
1122                case intt.itu.itut_x780.CreateErrorConst.badName.value :
1123                    System.err.println("Bad Name");
1124                    System.err.println(create_e.info.details);
1125                    break;
1126            default:
1127                System.err.println(create_e.info.details);
1128            }
1129            ui_client.showCreateError(create_e.info.details);
1130    }
1131
1132    public void treat_delete_exceptions(DeleteError delete_e) {
1133        System.err.println("Client caught exception during remove operation");
1134            switch(delete_e.info.error.value) {
1135                case intt.itu.itut_x780.DeleteErrorConst.notDeletable.value :
1136                    System.err.println("Element can not be deleted by the manager");
1137                    System.err.println(delete_e.info.details);
1138                    break;
1139                case intt.itu.itut_x780.DeleteErrorConst.containsObjects.value :
1140                    System.err.println("Element contains children and thus can not be deleted");
1141                    System.err.println(delete_e.info.details);
1142                    break;
1143                default:
1144                    System.err.println(delete_e.info.details);
1145            }
1146            ui_client.showDeleteError(delete_e.info.details);
1147
1148    }
1149
1150     public void treat_application_exceptions(ApplicationError appl_e) {
1151            System.err.println("Application exception caught:");
1152            switch(appl_e.info.error.value) {
1153                case intt.itu.itut_x780.ApplicationErrorConst.objectNotFound.value :
1154                    System.err.println("Object Not Found");
1155                    System.err.println(appl_e.info.details);
1156                    break;
1157                case intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value :
1158                    System.err.println("Invalid Parameter");
1159                    System.err.println(appl_e.info.details);
1160                    break;
1161            default:
1162                System.err.println(appl_e.info.details);
1163            }
1164            ui_client.showAttributesError(appl_e.info.details);
1165    }
1166
1167
1168private class AlarmSubscriptionInfo {
1169
1170    org.omg.Components.Cookie cookie;
1171    AlarmChannelProvider alarm_channel_provider;
1172
1173    AlarmSubscriptionInfo(AlarmChannelProvider alarm_channel_provider,
1174                        org.omg.Components.Cookie cookie) {
1175
1176        this.alarm_channel_provider = alarm_channel_provider;
1177        this.cookie = cookie;
1178    }
1179}
1180}
1181
Popular Tags