1 package org.jacorb.trading.impl; 2 3 import org.omg.CORBA.*; 4 import org.omg.CosTrading.LinkPackage.*; 5 import org.omg.CosTrading.*; 6 import java.util.*; 7 8 14 15 public class LinkImpl 16 extends org.omg.CosTrading.LinkPOA 17 implements LinkOperations 18 { 19 20 private TraderComp m_traderComp; 21 private SupportAttrib m_support; 22 private LinkAttrib m_link; 23 24 private Hashtable m_current_links; private boolean m_links_changed = true; 27 28 35 public LinkImpl (TraderComp trader_comp, SupportAttrib support, LinkAttrib link){ 36 m_traderComp = trader_comp; 37 m_support = support; 38 m_link = link; 39 m_current_links = new Hashtable(); 40 } 41 42 44 49 public Lookup lookup_if() 50 { 51 return m_traderComp.getLookupInterface(); 52 } 53 54 59 public Register register_if() 60 { 61 return m_traderComp.getRegisterInterface(); 62 } 63 64 69 public Link link_if() 70 { 71 return m_traderComp.getLinkInterface(); 72 } 73 74 79 public Proxy proxy_if() 80 { 81 return m_traderComp.getProxyInterface(); 82 } 83 84 89 public Admin admin_if() 90 { 91 return m_traderComp.getAdminInterface(); 92 } 93 94 96 101 public boolean supports_modifiable_properties() 102 { 103 return m_support.getModifiableProperties(); 104 } 105 106 107 112 public boolean supports_dynamic_properties() 113 { 114 return m_support.getDynamicProperties(); 115 } 116 117 118 123 public boolean supports_proxy_offers() 124 { 125 return m_support.getProxyOffers(); 126 } 127 128 129 134 public org.omg.CORBA.Object type_repos() 135 { 136 return m_support.getTypeRepos(); 137 } 138 139 140 146 public FollowOption max_link_follow_policy() 147 { 148 return m_link.getMaxLinkFollowPolicy(); 149 } 150 151 168 public void add_link(String name, 169 Lookup target, 170 FollowOption default_follow_rule, 171 FollowOption limiting_follow_rule) 172 throws IllegalLinkName, 173 DuplicateLinkName, 174 InvalidLookupRef, 175 DefaultFollowTooPermissive, 176 LimitingFollowTooPermissive { 177 178 180 if (name == null || name.length() == 0) 184 throw new IllegalLinkName(name); 185 186 if (m_current_links.containsKey(name)) 188 throw new DuplicateLinkName(name); 189 190 Register _reg = null; 192 try { 193 org.omg.CORBA.Object _obj = target.register_if(); 194 _reg = RegisterHelper.narrow(_obj); 195 } 196 catch (Exception e){ 197 throw new InvalidLookupRef(target); 201 } 202 203 if (default_follow_rule.value() > limiting_follow_rule.value()) 205 throw new DefaultFollowTooPermissive(default_follow_rule, limiting_follow_rule); 206 207 if (limiting_follow_rule.value() > max_link_follow_policy().value()) 209 throw new LimitingFollowTooPermissive(default_follow_rule, limiting_follow_rule); 210 211 LinkInfo _info = new LinkInfo(target, _reg, default_follow_rule, limiting_follow_rule); 213 m_current_links.put(name, _info); 214 215 m_links_changed = true; 217 } 218 219 226 public LinkInfo describe_link(String name) throws IllegalLinkName, UnknownLinkName { 227 if (name == null || name.length() == 0) 229 throw new IllegalLinkName(name); 230 231 LinkInfo _result = (LinkInfo) m_current_links.get(name); 233 234 if (_result == null) 236 throw new UnknownLinkName(name); 237 238 return _result; 239 } 240 241 245 public String [] list_links() { 246 String [] _links_array = new String [m_current_links.size()]; 247 Enumeration _links = m_current_links.keys(); 248 int _i = 0; 249 250 while (_links.hasMoreElements()) 251 _links_array[_i++] = (String ) _links.nextElement(); 252 253 return _links_array; 254 } 255 256 268 public void modify_link(String name, 269 FollowOption default_follow_rule, 270 FollowOption limiting_follow_rule) 271 throws IllegalLinkName, UnknownLinkName, 272 DefaultFollowTooPermissive, LimitingFollowTooPermissive { 273 275 if (name == null || name.length() == 0) 279 throw new IllegalLinkName(name); 280 281 if (! m_current_links.containsKey(name)) 283 throw new UnknownLinkName(name); 284 285 if (default_follow_rule.value() > limiting_follow_rule.value()) 287 throw new DefaultFollowTooPermissive(default_follow_rule, limiting_follow_rule); 288 289 if (limiting_follow_rule.value() > max_link_follow_policy().value()) 291 throw new LimitingFollowTooPermissive(default_follow_rule, limiting_follow_rule); 292 293 LinkInfo _link = (LinkInfo) m_current_links.get(name); 295 _link.def_pass_on_follow_rule = default_follow_rule; 296 _link.limiting_follow_rule = limiting_follow_rule; 297 298 m_links_changed = true; 300 } 301 302 308 public void remove_link(String name) throws IllegalLinkName, UnknownLinkName { 309 311 if (name == null || name.length() == 0) 315 throw new IllegalLinkName(name); 316 317 if (! m_current_links.containsKey(name)) 319 throw new UnknownLinkName(name); 320 321 m_current_links.remove(name); 323 324 m_links_changed = true; 326 } 327 328 333 public boolean linksChanged(){ 334 return m_links_changed; 335 } 336 337 342 public LinkInfo[] getLinks(){ 343 LinkInfo[] _links_array = new LinkInfo[m_current_links.size()]; 344 Enumeration _links = m_current_links.elements(); 345 int _i = 0; 346 347 while (_links.hasMoreElements()) 348 _links_array[_i++] = (LinkInfo) _links.nextElement(); 349 350 m_links_changed = false; 352 353 return _links_array; 354 } 355 356 } 358 359 360 | Popular Tags |