private void doPublish(TcpConnectionEvent event) { if (this.listener instanceof ConnectionAwareTcpListener) { ConnectionAwareTcpListener<T> listener = (ConnectionAwareTcpListener<T>) this.listener; if (event.getType() == TcpConnectionEventType.OPEN) { listener.newConnection(this); } else if (event.getType() == TcpConnectionEventType.CLOSE) { listener.connectionClosed(this); } } try { // TODO Publish the event to a reactor logger.info("Publishing event {}", event); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Failed to publish " + event, e); } else if (logger.isWarnEnabled()) { logger.warn("Failed to publish " + event + ":" + e.getMessage()); } } }
/** * Allow interceptors etc to publish events, perhaps subclasses of TcpConnectionEvent. The event * source must be this connection. * * @param event the event to publish. */ public void publishEvent(TcpConnectionEvent event) { Assert.isTrue(event.getData() == this, "Can only publish events with this as the source"); this.doPublish(event); }