@Override protected Bindings<NextProtocolBinding> initBindings() { return new NextProtocolBindings(); }
@Override public IoHandler getHandler(ResourceAddress address) { Binding binding = bindings.getBinding(address); return (binding != null) ? binding.handler() : null; }
public boolean emptyBindings() { return bindings.isEmpty(); }
ResourceAddress transport = address.getTransport(); if (transport != null) { Binding nioBinding = bindings.getBinding(address); if (nioBinding != null) { bindings.removeBinding(address, nioBinding); Binding nioBinding = bindings.getBinding(address); if (nioBinding != null) { boolean removed = bindings.removeBinding(address, nioBinding); if (removed) { ResourceAddress bindAddress = nioBinding.bindAddress();
NextProtocolBinding nextBinding = bindings.getProtocolBinding(address); boolean needsAcceptorBind = (nextBinding == null); Binding binding = bindings.addBinding(newBinding); if (binding != null) { failedAddress = address;
@Override protected void doSessionCreated(IoSessionEx session) throws Exception { LoggingFilter.addIfNeeded(logger, session, transportName); ResourceAddress candidateAddress = getCandidateResourceAddress(session); NextProtocolBindings.NextProtocolBinding nextBinding = bindings.getBinding0(candidateAddress); if (nextBinding == null) { // next-protocol not currently bound for this address session.close(true); return; } SortedSet<String> nextProtocolNames = nextBinding.getNextProtocolNames(); if (nextProtocolNames == null || nextProtocolNames.isEmpty()) { NEXT_PROTOCOL_KEY.set(session, null); } else if (nextProtocolNames.size() == 1) { NEXT_PROTOCOL_KEY.set(session, nextProtocolNames.first()); } else { Collection<ProtocolDispatcher> dispatchers = bridgeServiceFactory.getTransportFactory().getProtocolDispatchers().values(); // sessionCreated will be sent down pipeline again when next-protocol has been determined NextProtocolFilter nextProtocol = new NextProtocolFilter(dispatchers); IoFilterChain filterChain = session.getFilterChain(); filterChain.addLast(AbstractNioAcceptor.NEXT_PROTOCOL_FILTER, nextProtocol); } }
if (transport != null) { // Udp over Socks over Tcp might get us here Binding newBinding = new Binding(currentAddress, handler, initializer); Binding binding = bindings.addBinding(newBinding); if (binding != null) { failedAddress = currentAddress; Binding binding = bindings.addBinding(newBinding); if (binding != null) { failedAddress = currentAddress;
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; }
public String toString() { Set<Entry<ResourceAddress, NextProtocolBinding>> entries = entrySet(); if (entries.isEmpty()) { return "{}"; } StringBuilder sb = new StringBuilder(); sb.append("{\n"); if (!entries.isEmpty()) { for (Entry<ResourceAddress, NextProtocolBinding> entry : entries) { ResourceAddress key = entry.getKey(); NextProtocolBinding value = entry.getValue(); URI location = key.getResource(); sb.append(" ").append('[').append(location.resolve("/")).append(']'); sb.append(" = "); sb.append(value); sb.append(',').append('\n'); } sb.setLength(sb.length() - 2); } return sb.append("\n}").toString(); }
@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); }
Binding binding = bindings.getBinding(address); if (binding != null) { boolean removed = bindings.removeBinding(address, binding); if (removed) { ResourceAddress bindAddress = binding.bindAddress();
@Override public void sessionCreated(IoSession session) throws Exception { ResourceAddress localAddress = asResourceAddress(session.getLocalAddress()); NextProtocolBinding nioBinding = bindings.getBinding0(localAddress); if (nioBinding == null) {
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; }
public AbstractBioAcceptor() { bindings = new NextProtocolBindings(); started = new AtomicBoolean(false); }
@Override public IoHandler getHandler(ResourceAddress address) { Binding binding = bindings.getBinding(address); return (binding != null) ? binding.handler() : null; }
NextProtocolBindings.NextProtocolBinding nioBinding = bindings.getBinding0(localAddress); if (nioBinding == null) {
public boolean emptyBindings() { return bindings.isEmpty(); }
public AbstractNioAcceptor(Properties configuration, Logger logger) { if (configuration == null) { throw new NullPointerException("configuration"); } if (logger == null) { throw new NullPointerException("logger"); } this.configuration = configuration; this.logger = logger; started = new AtomicBoolean(false); bindings = new NextProtocolBindings(); boundAuthorities = new ConcurrentSkipListSet<>(Comparators.compareResourceOrigin()); String preferIPv4NetworkStack = System.getProperty("java.net.preferIPv4Stack"); if ("true".equalsIgnoreCase(preferIPv4NetworkStack)) { skipIPv6Addresses = true; } idleTimeout = TCP_IDLE_TIMEOUT.getIntProperty(configuration); }
ResourceAddress candidateAddress = resourceAddressFactory.newResourceAddress(candidateURI, candidateOptions); Binding binding = bindings.getBinding(candidateAddress); if (binding == null) {
ResourceAddress candidateAddress = resourceAddressFactory.newResourceAddress(candidateURI, candidateOptions); Bindings.Binding binding = bindings.getBinding(candidateAddress); if (binding == null) {