KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > ManagedObjectClientComposition > ManagedObjectClientImpl


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.ManagedObjectClientComposition;
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 import ist.coach.coachEmfServicesComponents.BasicLogProviderHome;
39 import ist.coach.coachEmfServicesComponents.BasicLogProviderHomeHelper;
40 import ist.coach.coachEmfServicesComponents.BasicLogProvider;
41 import ist.coach.coachEmfServices.EmfBasicLog.BasicLog;
42 import ist.coach.coachEmfClientComponents.ManagedObjectClientPackage.basic_logsConnection;
43 import ist.coach.coachEmfServices.EmfBasicLog.LogRecord;
44 //import ist.coach.coachEmfCommon.NamePrimaryKeyImpl;
45

46 import ist.coach.coachEmfClientComponents.InvokeSetData;
47 import ist.coach.coachEmfClientComponents.ManagedObjectClient;
48 import ist.coach.coachEmfClientComponents.ManagedObjectClientHelper;
49 import java.util.Hashtable JavaDoc;
50 import java.util.Vector JavaDoc;
51 import java.util.Enumeration JavaDoc;
52
53 import java.text.DateFormat JavaDoc;
54
55 import org.omg.CosNaming.NameComponent JavaDoc;
56 import ist.coach.coachEmfClientComponents.gui.GuiMaster;
57 /**
58  ** Implementation class for the
59  ** ::coachEmfClientComponents::ManagedObjectClient component.
60  **/

61 public class ManagedObjectClientImpl
62        extends ist.coach.coachEmfClientComponents.ManagedObjectClientComposition.ManagedObjectClient_impl
63        implements ist.coach.coachEmfClientComponents.gui.GuiMaster
64 {
65     // ==================================================================
66
//
67
// Internal State.
68
//
69
// ===================================================================
70

71     /** Business Logic **/
72     ist.coach.itut_q816Components.ChannelFinderProvider channel_finder = null;
73     ist.coach.coachEmfClientComponents.gui.GuiClient ui_client = null;
74     private String JavaDoc name_;
75     private String JavaDoc ems_root_;
76     private String JavaDoc root_id_, root_kind_;
77     org.omg.CosNaming.NamingContext JavaDoc root_context;
78
79
80             // need reference to this object as ManagedObjectClient
81
ManagedObjectClient myself = null;
82
83     Hashtable JavaDoc alarmProviders;
84     Hashtable JavaDoc logProviders;
85     Vector JavaDoc subscribed_log_events;
86     Thread JavaDoc child_thread = null;
87
88     // ==================================================================
89
//
90
// Constructor.
91
//
92
// ===================================================================
93
/**
94      ** The default constructor.
95      **/

96     public
97     ManagedObjectClientImpl()
98     {
99         alarmProviders = new Hashtable JavaDoc();
100         subscribed_log_events = new Vector JavaDoc();
101     }
102     // ==================================================================
103
//
104
// Internal methods.
105
//
106
// ===================================================================
107
// ==================================================================
108
//
109
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
110
//
111
// ==================================================================
112
//
113
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
114
//
115
/**
116      ** Completes the component configuration.
117      **
118      ** @throws org.omg.Components.InvalidConfiguration
119      ** Thrown if the configuration is invalid.
120      **/

121     public void
122     configuration_complete()
123     throws org.omg.Components.InvalidConfiguration
124     {
125         //System.err.println("Client configuration called...");
126
//
127
// DONE : implement !!!
128
//
129
// HACK: NameService is not needed when defered deployment is implemented
130
try {
131             org.omg.CORBA.ORB JavaDoc orb =
132                 org.objectweb.ccm.CORBA.TheORB.getORB();
133
134             org.omg.CORBA.Object JavaDoc obj =
135                 orb.resolve_initial_references("NameService");
136             root_context = org.omg.CosNaming.NamingContextHelper.narrow(obj);
137         }
138         catch(Exception JavaDoc e_c) {
139             System.err.println("Exception caught will resolving naming service: "
140                     + e_c.getMessage());
141             e_c.printStackTrace();
142         }
143
144         subscribed_log_events.add(GuiMaster.INFO_LOG);
145         subscribed_log_events.add(GuiMaster.ERROR_LOG);
146         subscribed_log_events.add(GuiMaster.WARNING_LOG);
147
148         // LogService must be found to retrieve log records and events
149
//
150
//
151
// HACK: currently home_finder interface has not been finalised by openccm.
152
// the only way to find the homes is through the Naming Service
153
//
154

155           //org.objectweb.openccm.components.HomeManager home_manager =
156
// org.objectweb.ccm.Components.Runtime.get_home_manager();
157
/************************
158         NameComponent[] homefinder_name = new NameComponent[3];
159         homefinder_name[0] = new NameComponent("OpenCCM", "");
160         homefinder_name[1] = new NameComponent("Services", "");
161         homefinder_name[2] = new NameComponent("HomeFinder", "");
162
163         try {
164              org.omg.CORBA.Object obj =
165                     root_context.resolve(homefinder_name);
166             org.omg.Components.HomeFinder home_manager =
167                   org.omg.Components.HomeFinderHelper.narrow(obj);
168
169           if (home_manager != null)
170             System.err.println("Client> Home Manager was found!");
171           org.omg.Components.CCMHome ccm_logHome = home_manager.find_home_by_home_type(
172             BasicLogProviderHomeHelper.id());
173           //org.omg.Components.CCMHome ccm_logHome = home_manager.find_home_by_name("BasicLogHome");
174           BasicLogProviderHome logHome = BasicLogProviderHomeHelper.narrow(ccm_logHome);
175           if (logHome != null)
176             System.err.println("Client> Log Home has been retrieved!");
177
178           ist.coach.coachEmfServices.EmfBasicLog.BasicLog[] list_logs =
179               logHome.list_logs();
180           for(int i = 0; i < list_logs.length; i++) {
181             System.err.print("ManagedObjectClient>list_logs[" + i + "].id = " + list_logs[i].id() + ", ");
182             System.err.print("list_logs[" + i + "].get_max_size = " + list_logs[i].get_max_size());
183
184           }
185           //logHome.create();
186           //BasicLogProvider newLog = logHome.create(new NamePrimaryKeyImpl(1));
187           //newLog.configuration_complete();
188           //System.err.println("TEST = " + newLog.provide_i_BasicLog().id());
189           //System.err.println("Client> new log with id " + newLog.logId() + " has been created!");
190         }
191         catch(org.omg.Components.HomeNotFound ex_home) {
192           System.err.println("Client> Log Home can not be found!" + ex_home.getMessage());
193           ex_home.printStackTrace(System.err);
194         }
195
196         catch(org.omg.Components.DuplicateKeyValue log_ex) {
197           System.err.println("Client> Log component can not be created due to DuplicateKeyValue");
198         }
199         //catch(org.omg.CORBA.TypeCodePackage.BadKind log_ex2) {
200         // System.err.println("Client> Log Home can not be found due to bad kind!");
201         //}
202         catch(org.omg.Components.InvalidKey log_ex3) {
203           System.err.println("Client> Log component can not be created due to InvalidKey");
204         }
205         catch(org.omg.Components.CreateFailure log_ex4) {
206           System.err.println("Client> CreateFailure");
207         }
208
209         catch(Exception e) {
210                 System.err.println("Client> Could not locate Log components");
211                 System.err.println("Message: " + e.getMessage());
212                 e.printStackTrace();
213         }
214
215 ************************/

216         //
217
// Register to all channels!!
218
//
219
NameComponent JavaDoc[] channel_finder_name = new NameComponent JavaDoc[3];
220         channel_finder_name[0] = new NameComponent JavaDoc(root_id_, root_kind_);
221         channel_finder_name[1] = new NameComponent JavaDoc("emf", "services");
222         //channel_finder_name[0] = new NameComponent("coach", "ist");
223
channel_finder_name[2] = new NameComponent JavaDoc("", "ChannelFinderService");
224
225         try {
226              org.omg.CORBA.Object JavaDoc obj =
227                     root_context.resolve(channel_finder_name);
228             channel_finder = ist.coach.itut_q816Components.ChannelFinderProviderHelper.narrow(obj);
229
230             if (channel_finder != null) {
231
232                 ChannelInfoType[] available_channels = channel_finder.provide_query().list();
233
234                 org.omg.CORBA.Object JavaDoc myself_o;
235                 myself_o = ((org.omg.Components.SessionContext) get_context()).get_CCM_object();
236                 myself = ManagedObjectClientHelper.narrow(myself_o);
237
238                 AlarmChannelProvider alarm_channel_provider = null;
239                 for (int i = 0; i < available_channels.length; i++) {
240
241                     if (available_channels[i].channel != null) {
242                             alarm_channel_provider =
243                         ist.coach.coachEmfServicesComponents.AlarmChannelProviderHelper.narrow(
244                                 available_channels[i].channel);
245
246                             if (alarm_channel_provider == null) {
247                                 System.err.println("alarm_channel_provider is null");
248                                 continue;
249                             }
250
251                             String JavaDoc[] eventTypes = alarm_channel_provider.eventTypes();
252                             System.err.println("eventTypes.length = " + eventTypes.length);
253
254                             Vector JavaDoc alarmTypeV = new Vector JavaDoc();
255                             for (int j = 0; j < eventTypes.length; j++) {
256                                 //System.err.println("--->INITIATING SUBSCRIPTION FOR " +
257
// eventTypes[j]);
258
add_alarm_provider(alarm_channel_provider, eventTypes[j]);
259                                     subscribe_alarm(eventTypes[j]);
260
261                             }
262
263                     }
264                 }
265             }
266             else
267                 System.err.println("Client> ChannelFinder reference is null...");
268         }
269         catch(Exception JavaDoc e) {
270                 System.err.println("Client> Could not locate ChannelFinder so that to " +
271                     " subscribe to alarms!");
272                 System.err.println("Message: " + e.getMessage());
273                 e.printStackTrace();
274         }
275
276         //
277
// Start the gui
278
//
279
//HACK THREAD
280
child_thread = new Thread JavaDoc( ui_client = new ist.coach.coachEmfClientComponents.gui.GuiClient(name_, ems_root_,
281                      this));
282         //ui_client = new ist.coach.coachEmfClientComponents.gui.GuiClient(name_, this);
283
System.err.println("Client configuration completed...");
284     }
285     // ==================================================================
286
//
287
// Methods for the OMG IDL Components::SessionComponent local interface.
288
//
289
//
290
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
291
//
292
/**
293      *
294      * Called by the container when the component will be removed.
295      *
296      * @throws org.omg.Components.CCMException
297      * Thrown if a system level error occured.
298      */

299     public void
300     ccm_remove()
301     throws org.omg.Components.CCMException
302     {
303         //
304
// DONE: implement !!!
305
//
306
// Release the associated gui client.
307
ui_client.dispose();
308     if (child_thread != null) {
309         child_thread.stop();
310     }
311
312     }
313
314     public void add_alarm_provider(AlarmChannelProvider alarm_channel_provider,
315                         String JavaDoc alarmType) {
316
317
318         Vector JavaDoc alarmTypeV = new Vector JavaDoc();
319
320         if (alarmProviders.containsKey(alarmType))
321             alarmTypeV = (Vector JavaDoc) alarmProviders.remove(alarmType);
322
323         AlarmSubscriptionInfo alarm_channel_provider_record;
324         int alarmTypeV_size = alarmTypeV.size();
325
326         for(int i = 0; i < alarmTypeV_size; i++) {
327             alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i);
328             if (alarm_channel_provider_record.alarm_channel_provider.channelId().equals(
329                     alarm_channel_provider.channelId()))
330                     alarmTypeV.removeElementAt(i);
331         }
332         alarm_channel_provider_record = new AlarmSubscriptionInfo(alarm_channel_provider, null);
333         alarmTypeV.add(alarm_channel_provider_record);
334
335         alarmProviders.put(alarmType, alarmTypeV);
336 // System.err.println("Addinf provider of " + alarmType + " alarms");
337

338     }
339
340     public void subscribe_alarm(String JavaDoc alarmType) {
341
342
343         if (! alarmProviders.containsKey(alarmType))
344             return;
345
346         Vector JavaDoc alarmTypeV = new Vector JavaDoc();
347         alarmTypeV = (Vector JavaDoc) alarmProviders.get(alarmType);
348
349         int alarmTypeV_size = alarmTypeV.size();
350
351         AlarmChannelProvider alarm_channel_provider = null;
352         org.omg.Components.Cookie ck = null;
353
354         AlarmSubscriptionInfo alarm_channel_provider_record;
355
356         for(int i = 0; i < alarmTypeV_size; i++) {
357
358             alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i);
359             alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider;
360
361           try {
362             if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) {
363                   ck = alarm_channel_provider.subscribe_objectCreation_alarm(
364                         myself.get_consumer_object_creation_alarm());
365             }
366             else
367             if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) {
368                   ck = alarm_channel_provider.subscribe_objectDeletion_alarm(
369                        myself.get_consumer_object_deletion_alarm());
370             }
371             else
372             if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) {
373                 ck = alarm_channel_provider.subscribe_stateChanged_alarm(
374                        myself.get_consumer_state_changed_alarm());
375             }
376             else
377             if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) {
378                 ck = alarm_channel_provider.subscribe_operational_alarm(
379                        myself.get_consumer_operational_violation_alarm());
380             }
381             else
382             if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) {
383                     ck = alarm_channel_provider.subscribe_heartbeat_event(
384                      myself.get_consumer_heartbeat_alarm());
385             }
386             else
387             if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) {
388                 ck = alarm_channel_provider.subscribe_channelChange_event(
389                     myself.get_consumer_channel_change_alarm());
390             }
391           }
392           catch(org.omg.Components.ExceededConnectionLimit ex1) {
393             System.err.println("org.omg.Components.ExceededConnectionLimit caught " +
394                     ex1.getMessage());
395             }
396
397             if (ck == null) {
398                     System.err.println("Subscription cookie of " + alarmType +
399                             " is NULL!");
400                   continue;
401             }
402
403             AlarmSubscriptionInfo info = new AlarmSubscriptionInfo(
404                         alarm_channel_provider, ck);
405
406             alarmTypeV = (Vector JavaDoc) alarmProviders.remove(alarmType);
407             alarmTypeV.removeElementAt(i);
408             alarmTypeV.add(info);
409
410             alarmProviders.put(alarmType, alarmTypeV);
411             System.err.println("Subscription for " + alarmType + " finished!");
412         }
413     }
414
415     public void unsubscribe_alarm(String JavaDoc alarmType) {
416
417     if (! alarmProviders.containsKey(alarmType))
418             return;
419
420         Vector JavaDoc alarmTypeV = new Vector JavaDoc();
421         alarmTypeV = (Vector JavaDoc) alarmProviders.get(alarmType);
422
423         int alarmTypeV_size = alarmTypeV.size();
424
425         AlarmChannelProvider alarm_channel_provider = null;
426         org.omg.Components.Cookie ck = null;
427
428         AlarmSubscriptionInfo alarm_channel_provider_record;
429         org.omg.Components.Cookie cookie = null;
430
431         for(int i = 0; i < alarmTypeV_size; i++) {
432
433             alarm_channel_provider_record = (AlarmSubscriptionInfo) alarmTypeV.get(i);
434             alarm_channel_provider = alarm_channel_provider_record.alarm_channel_provider;
435             cookie = alarm_channel_provider_record.cookie;
436
437             if (cookie == null)
438                 continue;
439
440           try {
441             if (alarmType.equals(GuiMaster.OBJECT_CREATION_ALARM)) {
442                   alarm_channel_provider.unsubscribe_objectCreation_alarm(cookie);
443             }
444             else
445             if (alarmType.equals(GuiMaster.OBJECT_DELETION_ALARM)) {
446                   alarm_channel_provider.unsubscribe_objectDeletion_alarm(cookie);
447             }
448             else
449             if (alarmType.equals(GuiMaster.STATE_CHANGED_ALARM)) {
450                 alarm_channel_provider.unsubscribe_stateChanged_alarm(cookie);
451             }
452             else
453             if (alarmType.equals(GuiMaster.OPERATIONAL_ALARM)) {
454                 alarm_channel_provider.unsubscribe_operational_alarm(cookie);
455             }
456             else
457             if (alarmType.equals(GuiMaster.HEARTBEAT_ALARM)) {
458                 alarm_channel_provider.unsubscribe_heartbeat_event(cookie);
459             }
460             else
461             if (alarmType.equals(GuiMaster.CHANNEL_CHANGE_ALARM)) {
462                 alarm_channel_provider.unsubscribe_channelChange_event(cookie);
463             }
464
465           }
466           catch(org.omg.Components.InvalidConnection ex1) {}
467         }
468     }
469
470     public void set_heartbeat_period(short period) {
471
472           NameComponent JavaDoc[] heartbeat_name =new NameComponent JavaDoc[3];
473           heartbeat_name[0] = new NameComponent JavaDoc(root_id_, root_kind_);
474           heartbeat_name[1] = new NameComponent JavaDoc("emf", "services");
475           //heartbeat_name[0] = new NameComponent("coach", "ist");
476
heartbeat_name[2] = new NameComponent JavaDoc("", "HeartbeatService");
477
478           try {
479             org.omg.CORBA.Object JavaDoc obj = root_context.resolve(heartbeat_name);
480
481             ist.coach.itut_q816Components.HeartbeatProvider heartbeat_provider =
482               ist.coach.itut_q816Components.HeartbeatProviderHelper.narrow(obj);
483
484                 heartbeat_provider.provide_admin().periodSet(period);
485           }
486           catch(Exception JavaDoc e) {
487             System.err.println("Client: set_heartbeat_period> Caught Exception " +
488                   e.getMessage());
489             e.printStackTrace(System.err);
490           }
491     }
492
493     public String JavaDoc[] get_all_logs() {
494
495         logProviders = new Hashtable JavaDoc();
496
497         basic_logsConnection[] connected_logs = get_context().get_connections_basic_logs();
498         String JavaDoc[] connected_logs_str = new String JavaDoc[connected_logs.length];
499
500         for(int i = 0; i < connected_logs.length; i++) {
501           connected_logs_str[i] = connected_logs[i].objref.get_display_name();
502           System.err.println("ManagedObjectClient> " + connected_logs_str[i] + " Log found...");
503           logProviders.put(connected_logs_str[i],
504                           connected_logs[i].objref);
505         }
506
507
508         return connected_logs_str;
509     }
510
511     public ist.coach.coachEmfServices.EmfBasicLog.LogRecord[] retrieve_logs(
512             String JavaDoc log_name, long from_time, int how_many) {
513
514         ist.coach.coachEmfServices.EmfBasicLog.LogRecord[] records =
515             new ist.coach.coachEmfServices.EmfBasicLog.LogRecord[0];
516
517         if (! logProviders.containsKey(log_name))
518             return records;
519
520         BasicLog requested_log = (BasicLog) logProviders.get(log_name);
521         ist.coach.coachEmfServices.EmfBasicLog.IteratorHolder iteratorH =
522             new ist.coach.coachEmfServices.EmfBasicLog.IteratorHolder();
523
524         records = requested_log.retrieve(from_time, how_many, iteratorH);
525         System.err.println("ManagedObjectClientImpl> retrieved_logs = " + records.length);
526         return records;
527     }
528
529     public synchronized void subscribe_log(String JavaDoc logType) {
530         if (! subscribed_log_events.contains(logType))
531           subscribed_log_events.add(logType);
532     }
533
534     public synchronized void unsubscribe_log(String JavaDoc logType) {
535         if (subscribed_log_events.contains(logType))
536           subscribed_log_events.remove(logType);
537     }
538
539     // ==================================================================
540
//
541
// Public methods for the CCM_ManagedObjectClient local interface.
542
//
543

544     //
545
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient/push_channel_change_alarm:1.0
546
//
547
/**
548      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient::push_channel_change_alarm operation.
549      **/

550     public void
551     push(ist.coach.itut_q816Components.ChannelChangeEvent event)
552     {
553         //
554
// DONE : implement
555
//
556
AlarmChannelProvider alarm_channel_provider =
557                     ist.coach.coachEmfServicesComponents.AlarmChannelProviderHelper.narrow(
558                                 event.channelInfo.channel);
559
560             String JavaDoc[] eventTypes = alarm_channel_provider.eventTypes();
561             String JavaDoc display_types_str = new String JavaDoc();
562             for (int j = 0; j < eventTypes.length; j++) {
563                     add_alarm_provider(alarm_channel_provider, eventTypes[j]);
564                     display_types_str += eventTypes[j];
565                     if (j < eventTypes.length - 1)
566                         display_types_str += ", ";
567
568             }
569             String JavaDoc[] sourceClasses = alarm_channel_provider.sourceClasses();
570             String JavaDoc display_source_str = new String JavaDoc();
571             for (int j = 0; j < sourceClasses.length; j++) {
572                     display_source_str += sourceClasses[j];
573                     if (j < sourceClasses.length - 1)
574                         display_source_str += ", ";
575             }
576         if (event.channelModification == ChannelModificationType.ChannelCreate) {
577
578             for (int j = 0; j < eventTypes.length; j++)
579                     add_alarm_provider(alarm_channel_provider, eventTypes[j]);
580
581             ui_client.print_alarm("",
582                 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm,
583                 "ChannelFinder", event.channelInfo.channelID, "",
584                 "Create: " + display_types_str + " events will be served from " + display_source_str + " sources");
585         }
586         else
587         if (event.channelModification == ChannelModificationType.ChannelUpdate) {
588             ui_client.print_alarm("",
589                 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm,
590                 "ChannelFinder", event.channelInfo.channelID, "",
591                 "Modify: " + display_types_str + " events will be served from " + display_source_str + " sources");
592         }
593         else
594         if (event.channelModification == ChannelModificationType.ChannelDelete) {
595             ui_client.print_alarm("",
596                 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm,
597                 "ChannelFinder", event.channelInfo.channelID, "",
598                 "Remove: " + display_types_str + " events will not be served from " + display_source_str + " sources");
599         }
600 /***
601         ui_client.print_alarm("",
602                 ist.coach.coachEmfClientComponents.gui.GuiMessages.channel_change_alarm,
603                 "", "", "", "");
604 ******/

605     }
606
607
608     //
609
// IDL:coach.ist/coachEmfClientComponents/CCM_ManagedObjectClient_Executor/name:1.0
610
//
611
/**
612      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::name attribute as accessor operation.
613      **/

614     public java.lang.String JavaDoc
615     name()
616     {
617         //
618
// DONE : implement
619
//
620
return name_;
621     }
622
623     /**
624      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::name attribute as mutator operation.
625      **/

626     public void
627     name(java.lang.String JavaDoc val)
628     {
629         //
630
// DONE : implement
631
//
632

633         name_ = val;
634         if (ui_client != null)
635             ui_client.set_name(name_);
636         System.err.println("Name is set to " + name_);
637     }
638
639     /**
640      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::ems_root attribute as accessor operation.
641      **/

642     public java.lang.String JavaDoc
643     ems_root()
644     {
645         //
646
// DONE : implement
647
//
648
return ems_root_;
649     }
650
651     /**
652      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::ems_root attribute as mutator operation.
653      **/

654     public void
655     ems_root(java.lang.String JavaDoc val)
656     {
657         //
658
// DONE : implement
659
//
660

661         ems_root_ = val;
662         System.err.println("EMS Root is set to " + ems_root_);
663     }
664
665     /**
666      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::root_id attribute as accessor operation.
667      **/

668     public java.lang.String JavaDoc
669     root_id()
670     {
671         //
672
// DONE : implement
673
//
674
return root_id_;
675     }
676
677     /**
678      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::root_id attribute as mutator operation.
679      **/

680     public void
681     root_id(java.lang.String JavaDoc val)
682     {
683         //
684
// DONE : implement
685
//
686

687         root_id_ = val;
688         System.err.println("EMS Root ID is set to " + root_id_);
689     }
690
691     /**
692      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::root_kind attribute as accessor operation.
693      **/

694     public java.lang.String JavaDoc
695     root_kind()
696     {
697         //
698
// DONE : implement
699
//
700
return root_kind_;
701     }
702
703     /**
704      ** Implementation of the ::coachEmfClientComponents::CCM_ManagedObjectClient_Executor::root_kind attribute as mutator operation.
705      **/

706     public void
707     root_kind(java.lang.String JavaDoc val)
708     {
709         //
710
// DONE : implement
711
//
712

713         root_kind_ = val;
714         System.err.println("EMS Root Kind is set to " + root_kind_);
715     }
716     // ==================================================================
717
//
718
// Methods for the ist.coach.coachEmfClientComponents.gui.GuiMaster interface
719
//
720
// ==================================================================
721

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

746         try {
747
748             NameComponent JavaDoc[] factoryfinder_name =new NameComponent JavaDoc[3];
749             factoryfinder_name[0] = new NameComponent JavaDoc(root_id_, root_kind_);
750             factoryfinder_name[1] = new NameComponent JavaDoc("emf", "services");
751             //factoryfinder_name[0] = new NameComponent("coach", "ist");
752
factoryfinder_name[2] = new NameComponent JavaDoc("", "FactoryFinder");
753
754             org.omg.CORBA.Object JavaDoc obj = root_context.resolve(factoryfinder_name);
755
756              ist.coach.itut_q816Components.FactoryFinderProvider factory_finder =
757                 ist.coach.itut_q816Components.FactoryFinderProviderHelper.narrow(obj);
758
759             ManagedObjectFactory mobject_f = factory_finder.provide_query().find(
760                             object_class + "Factory");
761
762 /***
763              ManagedObjectFactory mobject_f =
764                 ManagedObjectFactoryHelper.narrow(
765                      factory_finder.provide_query().find(
766                 object_class + "Factory"));
767         **/

768
769             /** NameBinding is <subordinate_class>_<superior_class>.
770                 If superior class is the root object then kind is organisation
771             */

772             String JavaDoc nameBinding = object_class + "_"
773                     + Utils.name2kind(parent_key_val);
774             System.err.println("Name Binding is " + nameBinding);
775
776             if (mobject_f == null) {
777                 System.err.println("Factory Object was null!!");
778                  return new String JavaDoc();
779             }
780
781             NameComponent JavaDoc[] new_name = null;
782             //new_object_key = new String();
783

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

997             intt.itu.itut_x780.ManagedObject_F mobject_f =
998             intt.itu.itut_x780.ManagedObject_FHelper.narrow(obj);
999             //ist.coach.itut_x780Components.ManagedObjectProvider mobject_f =
1000
//ist.coach.itut_x780Components.ManagedObjectProviderHelper.narrow(obj);
1001

1002            if (mobject_f == null) {
1003                System.err.println("Facade object can not be found!");
1004                return null;
1005            }
1006
1007            NameComponent JavaDoc[] obj_name = Utils.string2name(object_key);
1008
1009            attributes_values = (ManagedObjectValueType) mobject_f.attributesGet(
1010                    Utils.string2name(object_key),
1011                    new intt.itu.itut_x780.StringSetTypeHolder(attributes));
1012
1013        }
1014        catch(ApplicationError appl_e) {
1015            treat_application_exceptions(appl_e);
1016        }
1017        catch(Exception JavaDoc e_c) {
1018            System.err.println("Exception caught>"
1019                    + Utils.name2string(facade_name) +
1020                        ": " + e_c.getMessage());
1021            e_c.printStackTrace();
1022        }
1023
1024        return attributes_values;
1025    }
1026
1027    public String JavaDoc[] getContained(String JavaDoc superior) {
1028
1029        //System.err.println("\n--->getContained is called for " + superior);
1030
String JavaDoc[] subordinates = new String JavaDoc[0];
1031        try {
1032
1033            NameComponent JavaDoc[] c_query = new NameComponent JavaDoc[3];
1034            //c_query[0] = new NameComponent("coach", "ist");
1035
c_query[0] = new NameComponent JavaDoc(root_id_, root_kind_);
1036            c_query[1] = new NameComponent JavaDoc("emf", "services");
1037            c_query[2] = new NameComponent JavaDoc("", "ContainmentService");
1038            org.omg.CORBA.Object JavaDoc obj = root_context.resolve(c_query);
1039
1040            ist.coach.itut_q816Components.ContainmentServiceProvider containment =
1041                ist.coach.itut_q816Components.ContainmentServiceProviderHelper.narrow(obj);
1042
1043            if (containment != null) {
1044                NameComponent JavaDoc[][] children =
1045                    containment.provide_containment_query().getContained(
1046                        Utils.string2name(superior));
1047            //println("Get contained " + superior + " returned " + children.length+ " children");
1048

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