KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Containers > Plugins > PortSpecificConfiguration


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

26
27 package org.objectweb.openccm.Containers.Plugins;
28
29 /**
30  * This interface ??????.
31  *
32  * @author <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
33  *
34  * @version 0.3
35  */

36
37 public class PortSpecificConfiguration
38        extends org.omg.CORBA.LocalObject JavaDoc
39        implements org.objectweb.openccm.Containers.SystemConfiguration
40 {
41     // ==================================================================
42
//
43
// Internal state.
44
//
45
// ==================================================================
46

47     /**
48      ** Associations of (port_uid, system home class)
49      **/

50     protected org.objectweb.ccm.util.Table call_coordinator_sh_;
51
52     /**
53      ** Assocations of (port_uid, array of system home class)
54      **/

55     protected org.objectweb.ccm.util.Table call_controllers_sh_;
56
57     /**
58      ** Associations of (port_uid, property set)
59      **/

60     protected org.objectweb.ccm.util.Table call_coordinator_ps_;
61
62     /**
63      ** Associations of (port_uid, array of property set)
64      **/

65     protected org.objectweb.ccm.util.Table call_controllers_ps_;
66
67     /**
68      ** Associations of (port_uid, system home class)
69      **/

70     protected org.objectweb.ccm.util.Table act_coordinator_sh_;
71
72     /**
73      ** Assocations of (port_uid, array of system home class)
74      **/

75     protected org.objectweb.ccm.util.Table act_controllers_sh_;
76
77     /**
78      ** Associations of (port_uid, property set)
79      **/

80     protected org.objectweb.ccm.util.Table act_coordinator_ps_;
81
82     /**
83      ** Associations of (port_uid, array of property set)
84      **/

85     protected org.objectweb.ccm.util.Table act_controllers_ps_;
86
87     /**
88      ** The policies for the component.
89      **/

90     protected java.lang.String JavaDoc[] policies_;
91
92     /**
93      ** Reference to the parent configuration.
94      **/

95     protected org.objectweb.openccm.Containers.SystemConfiguration parent_configuration_;
96
97     /**
98      ** The ::CORBA::RepositoryId of the component without the version field.
99      **/

100     protected java.lang.String JavaDoc the_component_base_uid_;
101
102     /**
103      ** The version of the component.
104      **/

105     protected java.lang.String JavaDoc the_component_version_;
106
107     // ==================================================================
108
//
109
// Constructor.
110
//
111
// ==================================================================
112

113     /**
114      ** The constructor.
115      **
116      **/

117     public
118     PortSpecificConfiguration()
119     {
120         call_coordinator_sh_ = new org.objectweb.ccm.util.Table();
121         call_controllers_sh_ = new org.objectweb.ccm.util.Table();
122         call_coordinator_ps_ = new org.objectweb.ccm.util.Table();
123         call_controllers_ps_ = new org.objectweb.ccm.util.Table();
124         act_coordinator_sh_ = new org.objectweb.ccm.util.Table();
125         act_controllers_sh_ = new org.objectweb.ccm.util.Table();
126         act_coordinator_ps_ = new org.objectweb.ccm.util.Table();
127         act_controllers_ps_ = new org.objectweb.ccm.util.Table();
128         policies_ = new java.lang.String JavaDoc[0];
129         parent_configuration_ = null;
130         the_component_base_uid_ = "";
131         the_component_version_ = "1.0";
132     }
133
134     // ==================================================================
135
//
136
// Internal methods.
137
//
138
// ==================================================================
139

140     /**
141      **
142      **/

143     protected java.lang.String JavaDoc
144     getCallCoordinatorSystemHome(java.lang.String JavaDoc uid)
145     {
146         return (java.lang.String JavaDoc)call_coordinator_sh_.get(uid);
147     }
148
149     /**
150      **
151      **/

152     protected org.objectweb.openccm.Containers.PropertySet
153     getCallCoordinatorPropertySet(java.lang.String JavaDoc uid)
154     {
155         return (org.objectweb.openccm.Containers.PropertySet)call_coordinator_ps_.get(uid);
156     }
157
158     /**
159      **
160      **/

161     protected java.lang.String JavaDoc[]
162     getCallControllersSystemHome(java.lang.String JavaDoc uid)
163     {
164         return (java.lang.String JavaDoc[])call_controllers_sh_.get(uid);
165     }
166
167     /**
168      **
169      **/

170     protected org.objectweb.openccm.Containers.PropertySet[]
171     getCallControllersPropertySet(java.lang.String JavaDoc uid)
172     {
173         return (org.objectweb.openccm.Containers.PropertySet[])call_controllers_ps_.get(uid);
174     }
175
176     /**
177      **
178      **/

179     protected java.lang.String JavaDoc
180     getActCoordinatorSystemHome(java.lang.String JavaDoc uid)
181     {
182         return (java.lang.String JavaDoc)act_coordinator_sh_.get(uid);
183     }
184
185     /**
186      **
187      **/

188     protected org.objectweb.openccm.Containers.PropertySet
189     getActCoordinatorPropertySet(java.lang.String JavaDoc uid)
190     {
191         return (org.objectweb.openccm.Containers.PropertySet)act_coordinator_ps_.get(uid);
192     }
193
194     /**
195      **
196      **/

197     protected java.lang.String JavaDoc[]
198     getActControllersSystemHome(java.lang.String JavaDoc uid)
199     {
200         return (java.lang.String JavaDoc[])act_controllers_sh_.get(uid);
201     }
202
203     /**
204      **
205      **/

206     protected org.objectweb.openccm.Containers.PropertySet[]
207     getActControllersPropertySet(java.lang.String JavaDoc uid)
208     {
209         return (org.objectweb.openccm.Containers.PropertySet[])act_controllers_ps_.get(uid);
210     }
211
212     /**
213      **
214      **/

215     protected java.lang.String JavaDoc[]
216     getPCAPolicies()
217     {
218         return policies_;
219     }
220
221     // ==================================================================
222
//
223
// Public methods.
224
//
225
// ==================================================================
226

227     /**
228      **
229      **/

230     public void
231     setComponentUId(java.lang.String JavaDoc comp_uid)
232     {
233         int idx = comp_uid.lastIndexOf(':');
234         the_component_base_uid_ = comp_uid.substring(0, idx);
235         the_component_version_ = comp_uid.substring(idx+1);
236     }
237
238     /**
239      **
240      **/

241     public void
242     setCallCoordinator(java.lang.String JavaDoc port_name,
243                        java.lang.String JavaDoc home_alias)
244     {
245         // Note that the component version is assumed.
246
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
247         call_coordinator_sh_.put(uid, home_alias);
248     }
249
250     /**
251      **
252      **/

253     public void
254     setCallCoordinatorConfig(java.lang.String JavaDoc port_name,
255                              org.objectweb.openccm.Containers.PropertySet config)
256     {
257         // Note that the component version is assumed.
258
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
259         call_coordinator_ps_.put(uid, config);
260     }
261
262     /**
263      **
264      **/

265     public void
266     setCallControllers(java.lang.String JavaDoc port_name,
267                        java.lang.String JavaDoc[] homes_alias)
268     {
269         // Note that the component version is assumed.
270
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
271         call_controllers_sh_.put(uid, homes_alias);
272     }
273
274     /**
275      **
276      **/

277     public void
278     setCallControllersConfig(java.lang.String JavaDoc port_name,
279                              org.objectweb.openccm.Containers.PropertySet[] configs)
280     {
281         // Note that the component version is assumed.
282
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
283         call_controllers_ps_.put(uid, configs);
284     }
285
286     /**
287      **
288      **/

289     public void
290     setActCoordinator(java.lang.String JavaDoc port_name,
291                       java.lang.String JavaDoc home_alias)
292     {
293         // Note that the component version is assumed.
294
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
295         act_coordinator_sh_.put(uid, home_alias);
296     }
297
298     /**
299      **
300      **/

301     public void
302     setActCoordinatorConfig(java.lang.String JavaDoc port_name,
303                             org.objectweb.openccm.Containers.PropertySet config)
304     {
305         // Note that the component version is assumed.
306
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
307         act_coordinator_ps_.put(uid, config);
308     }
309
310     /**
311      **
312      **/

313     public void
314     setActControllers(java.lang.String JavaDoc port_name,
315                       java.lang.String JavaDoc[] homes_alias)
316     {
317         // Note that the component version is assumed.
318
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
319         act_controllers_sh_.put(uid, homes_alias);
320     }
321
322     /**
323      **
324      **/

325     public void
326     setActControllersConfig(java.lang.String JavaDoc port_name,
327                             org.objectweb.openccm.Containers.PropertySet[] configs)
328     {
329         // Note that the component version is assumed.
330
java.lang.String JavaDoc uid = the_component_base_uid_ + '/' + port_name + ':' + the_component_version_;
331         act_controllers_ps_.put(uid, configs);
332     }
333
334     /**
335      **
336      **/

337     public void
338     setPCAPolicies(java.lang.String JavaDoc[] policies)
339     {
340         policies_ = policies;
341     }
342
343     // ==================================================================
344
//
345
// Public methods for the SystemConfiguration interface.
346
//
347
// ==================================================================
348

349     //
350
// IDL:goal.lifl.fr/OpenCCM/Containers/SystemConfiguration/create_call_coordinator:1.0
351
//
352
/**
353      **
354      **/

355     public org.objectweb.openccm.Containers.CallCoordinator
356     create_call_coordinator(java.lang.String JavaDoc uid,
357                             java.lang.String JavaDoc op_name,
358                             org.objectweb.openccm.Containers.SystemHomeFinder finder)
359     {
360         java.lang.String JavaDoc home_alias = null;
361         org.objectweb.openccm.Containers.PropertySet config = null;
362
363         home_alias = getCallCoordinatorSystemHome(uid);
364         config = getCallCoordinatorPropertySet(uid);
365
366         if ((home_alias==null) && (parent_configuration_!=null))
367             return parent_configuration_.create_call_coordinator(uid, op_name, finder);
368         else if (home_alias==null)
369             home_alias = "EmptyCoordinatorHome";
370
371         try
372         {
373             org.objectweb.openccm.Containers.SystemHome home = null;
374             org.objectweb.openccm.Containers.CallCoordinator result = null;
375
376             home = finder.find_system_home(home_alias);
377             result = (org.objectweb.openccm.Containers.CallCoordinator)home.create_component(config);
378             result.configure(config);
379             return result;
380         }
381         catch(org.objectweb.openccm.Containers.HomeNotFound ex)
382         {
383             throw new Error JavaDoc("System home : "+home_alias+" was not found");
384         }
385         catch(org.objectweb.openccm.Containers.CreationFailed ex)
386         {
387             throw new Error JavaDoc("Creation of system component for system home : "+home_alias+" failed");
388         }
389         catch(org.objectweb.openccm.Containers.ConfigurationFailed ex)
390         {
391             throw new Error JavaDoc("Configuration of system component for system home : "+home_alias+" failed");
392         }
393     }
394
395     //
396
// IDL:goal.lifl.fr/OpenCCM/Containers/SystemConfiguration/create_call_controllers:1.0
397
//
398
/**
399      **
400      **/

401     public org.objectweb.openccm.Containers.CallController[]
402     create_call_controllers(java.lang.String JavaDoc uid,
403                             java.lang.String JavaDoc op_name,
404                             org.objectweb.openccm.Containers.SystemHomeFinder finder)
405     {
406         org.objectweb.openccm.Containers.CallController[] result = null;
407         java.lang.String JavaDoc[] homes_alias = null;
408         org.objectweb.openccm.Containers.PropertySet[] configs = null;
409
410         homes_alias = getCallControllersSystemHome(uid);
411         configs = getCallControllersPropertySet(uid);
412
413         if ((homes_alias==null) && (parent_configuration_!=null))
414             return parent_configuration_.create_call_controllers(uid, op_name, finder);
415         else if (homes_alias==null)
416     {
417             homes_alias = new java.lang.String JavaDoc[1];
418             homes_alias[0] = "EmptyControllerHome";
419             configs = new org.objectweb.openccm.Containers.PropertySet[1];
420             configs[0] = null;
421         }
422
423         int i=0;
424
425         try
426         {
427             result = new org.objectweb.openccm.Containers.CallController[homes_alias.length];
428             org.objectweb.openccm.Containers.SystemHome home = null;
429             for (;i<homes_alias.length;i++)
430         {
431                 home = finder.find_system_home(homes_alias[i]);
432                 result[i] = (org.objectweb.openccm.Containers.CallController)home.create_component(configs[i]);
433                 result[i].configure(configs[i]);
434         }
435
436             if (parent_configuration_!=null)
437             {
438                 org.objectweb.openccm.Containers.CallController[] tmp1 = null;
439                 org.objectweb.openccm.Containers.CallController[] tmp2 = null;
440                 tmp1 = parent_configuration_.create_call_controllers(uid, op_name, finder);
441                 if (tmp1!=null)
442                 {
443                     int l = tmp1.length + result.length;
444                     tmp2 = new org.objectweb.openccm.Containers.CallController[l];
445                     java.lang.System.arraycopy(result, 0, tmp2, 0, result.length);
446                     java.lang.System.arraycopy(tmp1, 0, tmp2, result.length, tmp1.length);
447                     return tmp2;
448                 }
449             }
450
451             return result;
452         }
453         catch(org.objectweb.openccm.Containers.HomeNotFound ex)
454         {
455             throw new Error JavaDoc("System home :"+homes_alias[i]+" was not found");
456         }
457         catch(org.objectweb.openccm.Containers.CreationFailed ex)
458         {
459             throw new Error JavaDoc("Creation of system component for system home :"+homes_alias[i]+" failed");
460         }
461         catch(org.objectweb.openccm.Containers.ConfigurationFailed ex)
462         {
463             throw new Error JavaDoc("Configuration of system component for system home :"+homes_alias[i]+" failed");
464         }
465     }
466
467     //
468
// IDL:goal.lifl.fr/OpenCCM/Containers/Container/SystemConfiguration/create_activation_coordinator:1.0
469
//
470
/**
471      **
472      **/

473     public org.objectweb.openccm.Containers.ActivationCoordinator
474     create_activation_coordinator(java.lang.String JavaDoc uid,
475                                   org.objectweb.openccm.Containers.SystemHomeFinder finder)
476     {
477         java.lang.String JavaDoc home_alias = null;
478         org.objectweb.openccm.Containers.PropertySet config = null;
479
480         home_alias = getActCoordinatorSystemHome(uid);
481         config = getActCoordinatorPropertySet(uid);
482
483         if ((home_alias==null) && (parent_configuration_!=null))
484             return parent_configuration_.create_activation_coordinator(uid, finder);
485         else if (home_alias==null)
486             // should never be called !!!
487
throw new java.lang.Error JavaDoc("Can\'t use an empty coordinator for activation");
488
489
490         try
491         {
492             org.objectweb.openccm.Containers.SystemHome home = null;
493             org.objectweb.openccm.Containers.ActivationCoordinator result = null;
494
495             home = finder.find_system_home(home_alias);
496             result = (org.objectweb.openccm.Containers.ActivationCoordinator)home.create_component(config);
497             result.configure(config);
498             return result;
499         }
500         catch(org.objectweb.openccm.Containers.HomeNotFound ex)
501         {
502             throw new Error JavaDoc("System home : "+home_alias+" was not found");
503         }
504         catch(org.objectweb.openccm.Containers.CreationFailed ex)
505         {
506             throw new Error JavaDoc("Creation of system component for system home : "+home_alias+" failed");
507         }
508         catch(org.objectweb.openccm.Containers.ConfigurationFailed ex)
509         {
510             throw new Error JavaDoc("Configuration of system component for system home : "+home_alias+" failed");
511         }
512     }
513
514     //
515
// IDL:goal.lifl.fr/OpenCCM/Containers/Container/SystemConfiguration/create_activation_controllers:1.0
516
//
517
/**
518      **
519      **/

520     public org.objectweb.openccm.Containers.ActivationController[]
521     create_activation_controllers(java.lang.String JavaDoc uid,
522                                   org.objectweb.openccm.Containers.SystemHomeFinder finder)
523     {
524         org.objectweb.openccm.Containers.ActivationController[] result = null;
525         org.objectweb.openccm.Containers.ActivationController[] tmp = null;
526         java.lang.String JavaDoc[] homes_alias = null;
527         org.objectweb.openccm.Containers.PropertySet[] configs = null;
528
529         homes_alias = getActControllersSystemHome(uid);
530         configs = getActControllersPropertySet(uid);
531
532         if ((homes_alias==null) && (parent_configuration_!=null))
533             return parent_configuration_.create_activation_controllers(uid, finder);
534         else if (homes_alias==null)
535             // should never be called !!!
536
throw new java.lang.Error JavaDoc("Can\'t use an empty controller for activation");
537
538         int i=0;
539
540         try
541         {
542             result = new org.objectweb.openccm.Containers.ActivationController[homes_alias.length];
543             org.objectweb.openccm.Containers.SystemHome home = null;
544             for (;i<homes_alias.length;i++)
545         {
546                 home = finder.find_system_home(homes_alias[i]);
547                 result[i] = (org.objectweb.openccm.Containers.ActivationController)home.create_component(configs[i]);
548                 result[i].configure(configs[i]);
549         }
550
551             if (parent_configuration_!=null)
552             {
553                 org.objectweb.openccm.Containers.ActivationController[] tmp1 = null;
554                 org.objectweb.openccm.Containers.ActivationController[] tmp2 = null;
555                 tmp1 = parent_configuration_.create_activation_controllers(uid, finder);
556                 if (tmp1!=null)
557                 {
558                     int l = tmp1.length + result.length;
559                     tmp2 = new org.objectweb.openccm.Containers.ActivationController[l];
560                     java.lang.System.arraycopy(result, 0, tmp2, 0, result.length);
561                     java.lang.System.arraycopy(tmp1, 0, tmp2, result.length, tmp1.length);
562                     return tmp2;
563                 }
564             }
565
566             return result;
567         }
568         catch(org.objectweb.openccm.Containers.HomeNotFound ex)
569         {
570             throw new Error JavaDoc("System home :"+homes_alias[i]+" was not found");
571         }
572         catch(org.objectweb.openccm.Containers.CreationFailed ex)
573         {
574             throw new Error JavaDoc("Creation of system component for system home :"+homes_alias[i]+" failed");
575         }
576         catch(org.objectweb.openccm.Containers.ConfigurationFailed ex)
577         {
578             throw new Error JavaDoc("Configuration of system component for system home :"+homes_alias[i]+" failed");
579         }
580     }
581
582     //
583
// IDL:goal.lifl.fr/OpenCCM/Containers/SystemConfiguration/create_PCAPolicies:1.0
584
//
585
/**
586      **
587      **/

588     public org.objectweb.openccm.Containers.PCAPolicy[]
589     create_PCAPolicies(java.lang.String JavaDoc uid,
590                        org.objectweb.openccm.Containers.SystemHomeFinder finder)
591     {
592         org.objectweb.openccm.Containers.PCAPolicy[] result = null;
593         java.lang.String JavaDoc[] homes_alias = null;
594
595         homes_alias = getPCAPolicies();
596         int i=0;
597         try
598         {
599             result = new org.objectweb.openccm.Containers.PCAPolicy[homes_alias.length];
600             org.objectweb.openccm.Containers.SystemHome home = null;
601             for (;i<homes_alias.length;i++)
602         {
603                 home = finder.find_system_home(homes_alias[i]);
604                 result[i] = (org.objectweb.openccm.Containers.PCAPolicy)home.create_component(null);
605                 result[i].configure(null);
606         }
607         }
608         catch(org.objectweb.openccm.Containers.HomeNotFound ex)
609         {
610             throw new Error JavaDoc("System home :"+homes_alias[i]+" was not found");
611         }
612         catch(org.objectweb.openccm.Containers.CreationFailed ex)
613         {
614             throw new Error JavaDoc("Creation of system component for system home :"+homes_alias[i]+" failed");
615         }
616         catch(org.objectweb.openccm.Containers.ConfigurationFailed ex)
617         {
618             throw new Error JavaDoc("Configuration of system component for system home :"+homes_alias[i]+" failed");
619         }
620
621         if ((result.length==0) && (parent_configuration_!=null))
622             return parent_configuration_.create_PCAPolicies(uid, finder);
623         else if (result.length==0)
624             return new org.objectweb.openccm.Containers.PCAPolicy[0];
625
626         return result;
627     }
628
629     //
630
// IDL:goal.lifl.fr/OpenCCM/Containers/SystemConfiguration/set_parent_configuration:1.0
631
//
632
/**
633      **
634      **/

635     public void
636     set_parent_configuration(org.objectweb.openccm.Containers.SystemConfiguration config)
637     {
638         parent_configuration_ = config;
639     }
640
641     // ==================================================================
642
//
643
// Public methods for the SystemComponent interface.
644
//
645
// ==================================================================
646

647     // ==================================================================
648
//
649
// Public methods for the Configuration interface.
650
//
651
// ==================================================================
652

653     //
654
// IDL:goal.lifl.fr/OpenCCM/Containers/Configuration/configure:1.0
655
//
656
/**
657      **
658      **/

659     public void
660     configure(org.objectweb.openccm.Containers.PropertySet config)
661     throws org.objectweb.openccm.Containers.ConfigurationFailed
662     {
663         //
664
// TODO : do nothing ???
665
//
666
throw new org.objectweb.openccm.Containers.ConfigurationFailed("not implemented !");
667     }
668 }
669
Popular Tags