KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > runtime > EmitterSet


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@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
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.ccm.runtime;
31
32 import org.objectweb.corba.runtime.*;
33
34 /**
35  ** <p></p>
36  **/

37 public class EmitterSet
38 implements java.io.Serializable JavaDoc
39 {
40     // set
41
static final private String JavaDoc _class_name = "EmitterSet";
42     private Emitter[] _elements;
43
44     // default constructor
45
public
46     EmitterSet()
47     {
48         // set
49
_elements = new Emitter[0];
50     }
51
52     // constructor with array of emitters
53
public
54     EmitterSet(Emitter[] emitters)
55     {
56         // set
57
_elements = emitters;
58     }
59
60     //
61
// public operations
62
//
63

64     final public void
65     initializeChannel(org.omg.Components.CCM2Context ctx)
66     {
67         Emitter[] emitters = _elements;
68         for (int i=0;i<emitters.length;i++) {
69             try {
70                 int chid = ctx.get_events().get_channel(emitters[i].name);
71                 emitters[i].channel_id = chid;
72             } catch (org.omg.Components.ChannelUnavailable ex) {
73                 // TODO: what should be done ?
74
final String JavaDoc opname = "initializeChannel";
75                 TheLogger.error(_class_name, opname, "FAILED", ex);
76             }
77         }
78     }
79
80     final public Emitter
81     get(String JavaDoc name)
82     throws org.omg.Components.InvalidName
83     {
84         Emitter[] emitters = _elements;
85         for (int i=0;i<emitters.length;i++) {
86             if (emitters[i].name.equals(name)) {
87                 return emitters[i];
88             }
89         }
90
91         throw new org.omg.Components.InvalidName();
92     }
93
94     final public Emitter
95     uncheckedGet(String JavaDoc name)
96     {
97         Emitter[] emitters = _elements;
98         for (int i=0;i<emitters.length;i++) {
99             if (emitters[i].name.equals(name)) {
100                 return emitters[i];
101             }
102         }
103
104         // should not happen
105
return null;
106     }
107 }
108
Popular Tags