@Override public Record attachments() { return connection.attachments(); }
@Override public String getConnectionAddress(Connection connection) { Record r = connection.attachments(); Address addr = r.get(CONNECTION_PEER_ADDRESS_KEY, Address.class); if (addr != null) { StringBuilder sb = new StringBuilder(addr.getHost()); if (addr.getPort() != null) sb.append(":" + addr.getPort()); return sb.toString(); } return null; }
@Override public void setConnectionHost(Connection connection, String host, int port) { Record r = connection.attachments(); // cannot set the address on an incoming connection if (r.get(AcceptorImpl.CONNECTION_ACCEPTOR_KEY, Acceptor.class) == null) { Address addr = new Address(); addr.setHost(host); if (port == 0) { port = 5672; } addr.setPort(Integer.toString(port)); r.set(CONNECTION_PEER_ADDRESS_KEY, Address.class, addr); } else { throw new IllegalStateException("Cannot set the host address on an incoming Connection"); } }
private void handleBound(Reactor reactor, Event event) { Connection connection = event.getConnection(); Record conn_recs = connection.attachments(); if (conn_recs.get(AcceptorImpl.CONNECTION_ACCEPTOR_KEY, Acceptor.class) != null) {
Record conn_recs = conn.attachments(); conn_recs.set(CONNECTION_ACCEPTOR_KEY, Acceptor.class, AcceptorImpl.this); InetSocketAddress peerAddr = (InetSocketAddress)socketChannel.getRemoteAddress();