Exemplo n.º 1
0
 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());
     }
   }
 }
Exemplo n.º 2
0
 /**
  * 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);
 }