@Test public void shouldCorrectlyBindTwoAddressesWithTcpBind() throws Exception { String uri1 = "http: HashMap<String, Object> options1 = new HashMap<>(); options1.put("tcp.bind", "7777"); String uri2 = "http: HashMap<String, Object> options2 = new HashMap<>(); ResourceAddress address1 = addressFactory.newResourceAddress(uri1, options1); ResourceAddress address2 = addressFactory.newResourceAddress(uri2, options2); Bindings.Binding binding1 = new Bindings.Binding(address1, handler, initializer); Bindings.Binding binding2 = new Bindings.Binding(address2, handler, initializer); Bindings.Binding oldBinding = httpBindings.addBinding(binding1); assertNull(oldBinding); oldBinding = httpBindings.addBinding(binding2); assertNull(oldBinding); }
@Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); HttpBinding httpBinding = getBinding0(bindAddress); if (httpBinding == null) { HttpBinding newHttpBinding = new HttpBinding(bindAddress); httpBinding = bindAdditionalAddressesIfNecessary(newHttpBinding); if (httpBinding == null) { httpBinding = newHttpBinding; } } URI location = bindAddress.getResource(); String path = location.getPath(); Binding binding = httpBinding.put(path, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; }
HttpBindings extends Bindings<HttpBinding> { @Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); HttpBinding httpBinding = getBinding0(bindAddress); if (httpBinding == null) { HttpBinding newHttpBinding = new HttpBinding(bindAddress); httpBinding = bindAdditionalAddressesIfNecessary(newHttpBinding); if (httpBinding == null) { httpBinding = newHttpBinding; } } URI location = bindAddress.getResource(); String path = location.getPath(); Binding binding = httpBinding.put(path, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; } }
HttpBindings extends Bindings<HttpBinding> { @Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); HttpBinding httpBinding = getBinding0(bindAddress); if (httpBinding == null) { HttpBinding newHttpBinding = new HttpBinding(bindAddress); httpBinding = bindAdditionalAddressesIfNecessary(newHttpBinding); if (httpBinding == null) { httpBinding = newHttpBinding; } } URI location = bindAddress.getResource(); String path = location.getPath(); Binding binding = httpBinding.put(path, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; } HttpBindings(); }
HttpBindings extends Bindings<HttpBinding> { @Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); HttpBinding httpBinding = getBinding0(bindAddress); if (httpBinding == null) { HttpBinding newHttpBinding = new HttpBinding(bindAddress); httpBinding = bindAdditionalAddressesIfNecessary(newHttpBinding); if (httpBinding == null) { httpBinding = newHttpBinding; } } URI location = bindAddress.getResource(); String path = location.getPath(); Binding binding = httpBinding.put(path, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; } HttpBindings(); @Override Binding addBinding(Binding newBinding); @Override Binding getBinding(ResourceAddress address); @Override boolean removeBinding(ResourceAddress address, Binding oldBinding); String toString(); }
HttpBindings extends Bindings<HttpBinding> { @Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); HttpBinding httpBinding = getBinding0(bindAddress); if (httpBinding == null) { HttpBinding newHttpBinding = new HttpBinding(bindAddress); httpBinding = bindAdditionalAddressesIfNecessary(newHttpBinding); if (httpBinding == null) { httpBinding = newHttpBinding; } } URI location = bindAddress.getResource(); String path = location.getPath(); Binding binding = httpBinding.put(path, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; } HttpBindings(); @Override Binding addBinding(Binding newBinding); @Override Binding getBinding(ResourceAddress address); @Override boolean removeBinding(ResourceAddress address, Binding oldBinding); String toString();  }