@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); int mark = sb.length(); Binding nullNextProtocolSnapshot = nullNextProtocol.get(); if (nullNextProtocolSnapshot != null) { sb.append("null: "); ResourceAddress bindAddress = nullNextProtocolSnapshot.bindAddress(); sb.append(bindAddress); sb.append(", "); } for (Binding binding : nextProtocols.values()) { ResourceAddress bindAddress = binding.bindAddress(); sb.append(bindAddress); sb.append(", "); } if (sb.length() > mark) { // rewind last ", " sb.setLength(sb.length() - 2); } sb.append('}'); return sb.toString(); }
binding.bindAddress() + "\n***via candidate:\n" + candidate + return binding.bindAddress();
+ " because it collides with an already bound address " + oldBinding.bindAddress());
binding.bindAddress() + "\n***via candidate:\n" + candidate + return binding.bindAddress();
boolean removed = bindings.removeBinding(address, binding); if (removed) { ResourceAddress bindAddress = binding.bindAddress(); T socketAddress = socketAddressFactory.createSocketAddress(bindAddress); acceptor.unbind(socketAddress);
ResourceAddress localAddress = binding.bindAddress(); LOCAL_ADDRESS.set(session, localAddress);
ResourceAddress localAddress = binding.bindAddress(); LOCAL_ADDRESS.set(session, localAddress);
boolean removed = bindings.removeBinding(address, nioBinding); if (removed) { ResourceAddress bindAddress = nioBinding.bindAddress(); InetSocketAddress socketAddress = asSocketAddress(bindAddress); acceptor.unbind(socketAddress);
tcpBridgeProcessor, acceptor.getSessionDataStructureFactory()); newTcpBridgeSession.setLocalAddress(binding.bindAddress()); newTcpBridgeSession.setRemoteAddress(resourceAddressFactory.newResourceAddress(binding.bindAddress(), REMOTE_ADDRESS.get(session)));
public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); String nextProtocol = bindAddress.getOption(NEXT_PROTOCOL); if (nextProtocol == null) { if (nullNextProtocol.compareAndSet(null, newBinding)) { newBinding.incrementReferenceCount(); return null; } Binding oldBinding = nullNextProtocol.get(); if (equivalent(newBinding, oldBinding)) { oldBinding.incrementReferenceCount(); return null; } return oldBinding; } Binding oldBinding = nextProtocols.putIfAbsent(nextProtocol, newBinding); if (oldBinding == null) { newBinding.incrementReferenceCount(); } else if (equivalent(newBinding, oldBinding)) { oldBinding.incrementReferenceCount(); oldBinding = null; } return oldBinding; }
binding.bindAddress() + "\n***via candidate:\n" + candidate + return binding.bindAddress();
protected final B addBinding0(B newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); B oldBinding = bindings.get(bindAddress); if (oldBinding != null) { IoHandler newHandler = newBinding.handler(); IoHandler oldHandler = oldBinding.handler(); if (oldHandler != null && newHandler != oldHandler) { throw new RuntimeException("Tried to bind address "+bindAddress+" to a different handler (old,new) = ("+oldHandler+","+newHandler+")"); } oldBinding.incrementReferenceCount(); return null; } // bind address to handler B binding = bindings.putIfAbsent(bindAddress, newBinding); if (binding != null) { if (equivalent(newBinding, binding)) { binding.incrementReferenceCount(); binding = null; } } else { newBinding.incrementReferenceCount(); } return binding; }
@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; }
public boolean removeBinding(ResourceAddress address, Binding binding) { ResourceAddress bindAddress = binding.bindAddress(); String nextProtocol = bindAddress.getOption(NEXT_PROTOCOL); if (nextProtocol == null) { Binding oldBinding = nullNextProtocol.get(); if (equivalent(oldBinding, binding)) { binding = oldBinding; } if (binding.decrementReferenceCount() == 0) { return nullNextProtocol.compareAndSet(binding, null); } return false; } Binding oldBinding = nextProtocols.get(nextProtocol); if (equivalent(oldBinding, binding)) { binding = oldBinding; } if (binding.decrementReferenceCount() == 0) { return nextProtocols.remove(nextProtocol, binding); } return false; }
private ResourceAddress getSslSessionLocalAddress(IoSession session) { // note: bound address is unified in SSL options during bind to avoid conflicts like different cipher suites ResourceAddress boundAddress = SslAcceptor.SSL_RESOURCE_ADDRESS.remove(session); assert (boundAddress != null); // construct the candidate address with observed transport and next protocol String candidateURI = boundAddress.getExternalURI(); ResourceOptions candidateOptions = ResourceOptions.FACTORY.newResourceOptions(boundAddress); candidateOptions.setOption(NEXT_PROTOCOL, NEXT_PROTOCOL_KEY.get(session)); candidateOptions.setOption(TRANSPORT, LOCAL_ADDRESS.get(session)); ResourceAddress candidateAddress = resourceAddressFactory.newResourceAddress(candidateURI, candidateOptions); // lookup the binding for this candidate address Binding binding = bindings.getBinding(candidateAddress); return (binding != null) ? binding.bindAddress() : null; }
@Override public final Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); NextProtocolBinding nextBinding = super.getBinding0(bindAddress); if (nextBinding == null) { NextProtocolBinding newNextBinding = new NextProtocolBinding(bindAddress); nextBinding = addBinding1(newNextBinding); if (nextBinding == null) { nextBinding = newNextBinding; } } return nextBinding.addBinding(newBinding); }
protected final boolean equivalent(Binding newBinding, Binding binding) { return binding.bindAddress().equals(newBinding.bindAddress()) && binding.handler() == newBinding.handler(); }
@Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); WsrBinding wsrBinding = getBinding0(bindAddress); if (wsrBinding == null) { wsrBinding = new WsrBinding(newBinding.bindAddress(), newBinding.handler(), newBinding.initializer()); } return super.addBinding0(wsrBinding); }
private <T extends IoFuture> void addWsrRtmpBinding(ResourceAddress wsrRtmpAddress, IoHandler handler, BridgeSessionInitializer<T> initializer) { Bindings.Binding newBinding = new Bindings.Binding(wsrRtmpAddress, handler, initializer); Bindings.Binding oldBinding = bindings.addBinding(newBinding); if (oldBinding != null) { throw new RuntimeException("Unable to bind address " + wsrRtmpAddress + " because it collides with an already bound address " + oldBinding.bindAddress()); } }
@Override public Binding addBinding(Binding newBinding) { ResourceAddress bindAddress = newBinding.bindAddress(); WsnBinding wsnBinding = getBinding0(bindAddress); if (wsnBinding == null) { wsnBinding = new WsnBinding(newBinding.bindAddress(), newBinding.handler(), newBinding.initializer()); } return super.addBinding0(wsnBinding); }