1 26 27 28 29 package org.objectweb.openccm.OpenCCM_DCI.cif; 30 31 import org.objectweb.openccm.OpenCCM_DCI.*; 32 import org.ist.coach.DCI.HomeInfo; 33 import org.objectweb.openccm.corba.*; 34 43 public class HomeManagementSegImpl 44 extends org.objectweb.openccm.OpenCCM_DCI. 45 DCIManagerSessionComposition.HomeManagementSeg 46 { 47 48 65 66 69 private org.objectweb.ccm.util.Table by_cookies_; 70 71 74 private org.objectweb.ccm.util.Table by_home_repids_; 75 76 79 private org.objectweb.ccm.util.Table by_component_repids_; 80 81 84 private org.objectweb.ccm.util.Table by_home_names_; 85 86 89 private org.objectweb.openccm.OpenCCM_DCI.DCIManagerCCM DCI; 90 91 92 98 101 public 102 HomeManagementSegImpl() 103 { 104 by_cookies_ = new org.objectweb.ccm.util.Table(); 105 by_home_repids_ = new org.objectweb.ccm.util.Table(); 106 by_component_repids_ = new org.objectweb.ccm.util.Table(); 107 by_home_names_ = new org.objectweb.ccm.util.Table(); 108 } 109 110 116 public void setupDCI(){ 122 DCI=(org.objectweb.openccm.OpenCCM_DCI.DCIManagerCCM)get_context(); 123 } 124 125 126 132 146 public org.omg.Components.CCMHome 147 find_home_by_component_type(String comp_repid) 148 throws org.omg.Components.HomeNotFound 149 { 150 Object result = by_component_repids_.get(comp_repid); 152 153 if(result == null) 155 { 156 throw new org.omg.Components.HomeNotFound(); 157 } 158 159 return (org.omg.Components.CCMHome)result; 161 } 162 163 176 public org.omg.Components.CCMHome 177 find_home_by_home_type(String home_repid) 178 throws org.omg.Components.HomeNotFound 179 { 180 Object result = by_home_repids_.get(home_repid); 182 183 if(result == null) 185 { 186 throw new org.omg.Components.HomeNotFound(); 187 } 188 189 return (org.omg.Components.CCMHome)result; 191 } 192 193 206 public org.omg.Components.CCMHome 207 find_home_by_name(String home_name) 208 throws org.omg.Components.HomeNotFound 209 { 210 Object result = by_home_names_.get(home_name); 212 213 if(result == null) 215 { 216 throw new org.omg.Components.HomeNotFound(); 217 } 218 219 return (org.omg.Components.CCMHome)result; 221 } 222 223 224 public HomeInfo [] 225 get_all_homes() 226 { 227 java.util.Collection cc= 228 by_cookies_.values(); 229 230 return 231 (HomeInfo []) 232 cc.toArray(new HomeInfo[cc.size()]); 233 234 } 235 241 254 public org.omg.Components.Cookie 255 register_home(org.omg.Components.CCMHome home, 256 String home_repid, 257 String component_repid, 258 String name) 259 { 260 261 262 try{ 263 org.omg.Components.Cookie cookie = DCI.connect_homes(home); 265 by_cookies_.put(cookie, 267 new org.ist.coach.DCI.HomeInfo( 268 home_repid, 269 component_repid, 270 home, 271 name, 272 "Unknown")); 273 by_home_repids_.put(home_repid, home); 275 276 by_component_repids_.put(component_repid, home); 278 279 by_home_names_.put(name, home); 281 282 return cookie; 284 } 285 catch(Exception e){ 286 System.err.println("Cannot connect home to the DCI"); 287 return null; 288 } 289 } 290 291 302 public void 303 unregister_home(org.omg.Components.Cookie ck) 304 throws org.omg.Components.CookieRequired 305 { 306 if(ck==null) 307 throw new org.omg.Components.CookieRequired(); 308 HomeInfo home_info = (HomeInfo)by_cookies_.remove(ck); 310 311 if(home_info == null) 313 { 314 throw new org.omg.Components.CookieRequired(); 315 } 316 317 by_home_repids_.remove(home_info.home_repid); 319 320 by_component_repids_.remove(home_info.component_repid); 322 323 by_home_names_.remove(home_info.uid); 325 try{ 326 DCI.disconnect_homes(ck); 328 } 329 catch(Exception e){ 330 System.err.println("Cannot disconnect home from the DCI"); 331 } 332 } 333 334 335 } 336 | Popular Tags |