Example #1
0
  public boolean delegateRequest(IRequestHandler request, String delegationTopic, Object args) {

    try {
      Iterator<RequestHandlerFactory> itr = handlerFactories.iterator();

      while (itr.hasNext()) {
        RequestHandlerFactory hFactory = itr.next();

        if (hFactory.canHandle(delegationTopic)) {
          IRequestHandler handler =
              hFactory.createOnDelegationRequest(
                  request.getClient(), request.getSocketEventEngine(), this, args);

          handler.setId(counter++);
          requests.add(handler);

          this.echo("New HTTPS Request Handler created for a delegated Request.", handler);

          setChanged();
          notifyObservers(handler);

          handler.handleDelegatedRequest();

          return true;
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    return false;
  }
Example #2
0
  public void run() {
    // TODO Auto-generated method stub
    ServerSocketChannel server = null;
    try {
      server = ServerSocketChannel.open();
      logger.debug("Trying to bind on port - " + port);
      server.socket().bind(new InetSocketAddress(port));
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      return;
    }
    while (true) {
      SocketChannel client = null;
      try {
        client = server.accept();

        IRequestHandler handler = factory.create(client, LoadBalancer.getInstance().get(), this);

        handler.setId(counter++);
        requests.add(handler);

        setChanged();
        notifyObservers(handler);

      } catch (IOException e) {
        try {
          if (client != null) client.close();
        } catch (IOException ee) {
          logger.error(ee.getMessage(), ee);
        }
        logger.error(e.getMessage(), e);
      }
    }
  }
 /** {@inheritDoc} */
 @Override
 public ServerConnection<Integer> handleAccept(final C clientContext) throws LdapException {
   return adaptRequestHandler(factory.handleAccept(clientContext));
 }