KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_q816Components > ContainmentServiceProviderComposition > adminSegImpl


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

28
29 package ist.coach.itut_q816Components.ContainmentServiceProviderComposition;
30
31 import ist.coach.coachEmfCommon.Utils;
32 import ist.coach.coachEmfCommon.ExceptionMessages;
33 import ist.coach.coachEmfCommon.DeleteErrorInfoTypeImpl;
34 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl;
35 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
36
37 import intt.itu.itut_x780.UIDType;
38 import intt.itu.itut_x780.ApplicationError;
39 import intt.itu.itut_x780.CreateError;
40 import intt.itu.itut_x780.DeleteError;
41 /**
42  * This is the CIDL-based implementation of the
43  * OMG IDL3 CIDL:coach.ist/itut_q816Components/ContainmentServiceProviderComposition/ContainmentServiceProviderHome_impl/ContainmentServiceProvider_impl/adminSeg:1.0 segment type.
44  *
45  * @author OpenCCM CIF_Jimpl Compiler.
46  */

47 public class adminSegImpl
48      extends ist.coach.itut_q816Components.ContainmentServiceProviderComposition.adminSeg
49 {
50     // ==================================================================
51
//
52
// Internal states.
53
//
54
// ==================================================================
55

56     // ==================================================================
57
//
58
// Constructors.
59
//
60
// ==================================================================
61

62     public adminSegImpl()
63     {
64     }
65
66     // ==================================================================
67
//
68
// Methods.
69
//
70
// ==================================================================
71

72     /**
73      * Implementation of the ::itut_q816::ContainmentComponent::registerLocalRoot operation.
74      */

75     public void
76     registerLocalRoot(org.omg.CosNaming.NameComponent JavaDoc[] name, org.omg.CosNaming.NamingContext JavaDoc localRoot)
77     throws intt.itu.itut_x780.ApplicationError
78     {
79         //
80
// DONE : implement
81
//
82
ContainmentServiceProviderImpl._local_root = Utils.name2string(name);
83         if (! ContainmentServiceProviderImpl.tree.contains(
84                   ContainmentServiceProviderImpl._local_root))
85             synchronized(ContainmentServiceProviderImpl.tree) {
86               ContainmentServiceProviderImpl.tree.put(
87                 ContainmentServiceProviderImpl._local_root, new java.util.Vector JavaDoc());
88             }
89     }
90
91     /**
92      * Implementation of the ::itut_q816::ContainmentComponent::unregisterLocalRoot operation.
93      */

94     public void
95     unregisterLocalRoot(org.omg.CosNaming.NameComponent JavaDoc[] name)
96     throws intt.itu.itut_x780.ApplicationError
97     {
98         //
99
// TODO : Implement
100
//
101
}
102
103     /**
104      * Implementation of the ::itut_q816::ContainmentComponent::addName operation.
105      */

106     public void
107     addName(org.omg.CosNaming.NameComponent JavaDoc[] name, org.omg.CosNaming.NameComponent JavaDoc[] superior)
108     throws intt.itu.itut_x780.ApplicationError,
109
110            intt.itu.itut_x780.CreateError
111     {
112               //
113
// DONE : implement
114
//
115
java.util.Vector JavaDoc children = new java.util.Vector JavaDoc();
116
117         String JavaDoc name_str = Utils.name2string(name);
118         //System.err.println("ContainmentService called to add : " + name_str);
119

120         String JavaDoc superior_str = Utils.name2string(superior);
121
122         if (ContainmentServiceProviderImpl.tree.containsKey(superior_str)) {
123             children = (java.util.Vector JavaDoc) ContainmentServiceProviderImpl.tree.get(superior_str);
124         }
125         else {
126             CreateErrorInfoTypeImpl error_code = new CreateErrorInfoTypeImpl();
127             error_code.error = new UIDType(
128                 intt.itu.itut_x780.CreateErrorConst.moduleName.value,
129                 intt.itu.itut_x780.CreateErrorConst.badName.value);
130             error_code.details = ExceptionMessages.parent_object_error;
131             throw new ApplicationError(error_code);
132         }
133
134         if (ContainmentServiceProviderImpl.tree.containsKey(name_str)) {
135             CreateErrorInfoTypeImpl error_code = new CreateErrorInfoTypeImpl();
136             error_code.error = new UIDType(
137                 intt.itu.itut_x780.CreateErrorConst.moduleName.value,
138                 intt.itu.itut_x780.CreateErrorConst.duplicateName.value);
139
140             error_code.details = name_str + ExceptionMessages.not_exists_error;
141             throw new CreateError(error_code);
142
143         }
144         else {
145           synchronized(ContainmentServiceProviderImpl.tree) {
146             ContainmentServiceProviderImpl.tree.put(name_str, new java.util.Vector JavaDoc());
147             //System.err.println("ContainmentService added : " + name_str);
148
}
149       }
150
151         if (! children.contains(name_str)) {
152             children.add(name_str);
153             synchronized(ContainmentServiceProviderImpl.tree) {
154               ContainmentServiceProviderImpl.tree.put(superior_str, children);
155             }
156             synchronized(ContainmentServiceProviderImpl.reverse_tree) {
157               ContainmentServiceProviderImpl.reverse_tree.put(name_str, superior_str);
158             }
159         }
160     }
161
162     /**
163      * Implementation of the ::itut_q816::ContainmentComponent::removeName operation.
164      */

165     public void
166     removeName(org.omg.CosNaming.NameComponent JavaDoc[] name)
167     throws intt.itu.itut_x780.ApplicationError,
168
169            intt.itu.itut_x780.DeleteError
170     {
171                 //
172
// DONE : implement
173
//
174
if (name.length <= 1) {
175             ApplicationErrorInfoTypeImpl error_code =
176                     new ApplicationErrorInfoTypeImpl();
177             error_code.error = new UIDType(
178                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
179                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
180             error_code.details = ExceptionMessages.root_delete_error;
181
182             throw new ApplicationError(error_code);
183         }
184
185         String JavaDoc name_str = Utils.name2string(name);
186
187         if (!ContainmentServiceProviderImpl.tree.containsKey(name_str)) {
188
189             //System.err.println("CS has " +
190
//ContainmentServiceProviderImpl.tree.size() + " objects ");
191

192             ApplicationErrorInfoTypeImpl error_code =
193                 new ApplicationErrorInfoTypeImpl();
194             error_code.error = new UIDType(
195                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
196                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
197             error_code.details = name_str + ExceptionMessages.not_exists_error;
198
199             throw new ApplicationError(error_code);
200         }
201
202         java.util.Vector JavaDoc children =
203           (java.util.Vector JavaDoc) ContainmentServiceProviderImpl.tree.get(name_str);
204
205          // There must be no contained names registered with
206
// the Containment service when a name is removed.
207

208         if (children != null && children.size() > 0) {
209             DeleteErrorInfoTypeImpl error_code =
210                 new DeleteErrorInfoTypeImpl();
211             error_code.error = new UIDType(
212                 intt.itu.itut_x780.DeleteErrorConst.moduleName.value,
213                 intt.itu.itut_x780.DeleteErrorConst.containsObjects.value);
214             error_code.details = name_str + ExceptionMessages.contains_object_error;
215
216             throw new DeleteError(error_code);
217         }
218
219         synchronized(ContainmentServiceProviderImpl.tree) {
220           ContainmentServiceProviderImpl.tree.remove(name_str);
221             //System.err.println("CS has removed " + name_str);
222
}
223         String JavaDoc superior = null;
224         synchronized(ContainmentServiceProviderImpl.reverse_tree) {
225           superior = (String JavaDoc) ContainmentServiceProviderImpl.reverse_tree.remove(name_str);
226         }
227         if (superior == null)
228             return;
229
230         java.util.Vector JavaDoc superior_children =
231           (java.util.Vector JavaDoc) ContainmentServiceProviderImpl.tree.get(superior);
232         if (superior_children.contains(name_str)) {
233             superior_children.remove(name_str);
234             synchronized(ContainmentServiceProviderImpl.tree) {
235                 ContainmentServiceProviderImpl.tree.put(superior, superior_children);
236             }
237             //System.err.println("\tProceeding to remove from " + name_str
238
// + " from " + superior);
239
}
240
241     }
242
243 }
244
Popular Tags