/**
  * Plug a middleware component to the middleware chain.
  *
  * @param middleware is a new middleware
  */
 public void add(final HttpSenderMiddleware middleware) {
   if (httpSenderMiddleware == null) {
     httpSenderMiddleware = middleware;
   } else {
     middleware.next = httpSenderMiddleware;
     httpSenderMiddleware = middleware;
   }
 }
 /**
  * Post http event collector data
  *
  * @param events list
  * @param sender is http sender
  * @param callback async callback
  */
 public void postEvents(
     final List<HttpEventCollectorEventInfo> events,
     IHttpSender sender,
     IHttpSenderCallback callback) {
   if (httpSenderMiddleware == null) {
     sender.postEvents(events, callback);
   } else {
     httpSenderMiddleware.postEvents(events, sender, callback);
   }
 }
 protected void callNext(
     final List<HttpEventCollectorEventInfo> events,
     IHttpSender sender,
     IHttpSenderCallback callback) {
   if (next != null) {
     next.postEvents(events, sender, callback);
   } else {
     sender.postEvents(events, callback);
   }
 }