protected TcpConnectionSupport wrapConnection(TcpConnectionSupport connection) throws Exception {
   try {
     if (this.interceptorFactoryChain == null) {
       return connection;
     }
     TcpConnectionInterceptorFactory[] interceptorFactories =
         this.interceptorFactoryChain.getInterceptorFactories();
     if (interceptorFactories == null) {
       return connection;
     }
     for (TcpConnectionInterceptorFactory factory : interceptorFactories) {
       TcpConnectionInterceptorSupport wrapper = factory.getInterceptor();
       wrapper.setTheConnection(connection);
       // if no ultimate listener or sender, register each wrapper in turn
       if (this.listener == null) {
         connection.registerListener(wrapper);
       }
       if (this.sender == null) {
         connection.registerSender(wrapper);
       }
       connection = wrapper;
     }
     return connection;
   } finally {
     this.addConnection(connection);
   }
 }