@Override public IoHandler getHandler(ResourceAddress address) { Binding binding = bindings.getBinding(address); if (binding != null) { return binding.handler(); } System.out.println(String.format("ERROR in getHandler: bindings: %s\naddress: %s", bindings, address)); return null; }
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; }
final IoHandler sseHandler = binding.handler();
REMOTE_ADDRESS.get(session))); newTcpBridgeSession.setHandler(binding.handler());
IoHandler handler = binding.handler(); DELEGATE_KEY.set(session, handler);
@Override public final UnbindFuture unbind(ResourceAddress address) { UnbindFuture future = null; boolean unbindAlternate; do { //System.out.println(getClass().getSimpleName()+"@"+hashCode()+" unbinding: "+address.getExternalURI()+" -- "+address.getOption(NEXT_PROTOCOL)); unbindAlternate = address.getOption(BIND_ALTERNATE); Binding binding = bindings.getBinding(address); bindings.removeBinding(address, binding); // Using address (instead of binding.bindAddress()) as two different addresses may have the same binding // due to alternates. For example: sse (with http transport) has alternate sse(with httpxe transport) // Say, they are A and its alternate B. A and B share the same binding as alternates comparator consider // A and B are equal. Unbinding A happens fine. While unbinding B, the binding.bindAddress() would be A // with alternate B and this would cause problems(as A is already used for unbinding). UnbindFuture newFuture = unbindInternal(address, binding.handler(), binding.initializer()); if (future != null) { future = DefaultUnbindFuture.combineFutures(future, newFuture); } else { future = newFuture; } address = address.getOption(ALTERNATE); } while (address != null && unbindAlternate); return future; }
IoHandler handler = binding.handler(); DELEGATE_KEY.set(session, handler);
@Override public IoHandler getHandler(ResourceAddress address) { Binding binding = bindings.getBinding(address); return (binding != null) ? binding.handler() : null; }
@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); }
@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); }
@Override public IoHandler getHandler(ResourceAddress address) { Binding binding = bindings.getBinding(address); return (binding != null) ? binding.handler() : null; }