Package com.planet_ink.coffee_web.interfaces

Examples of com.planet_ink.coffee_web.interfaces.HTTPIOHandler


    {
      final ServerSocketChannel server = (ServerSocketChannel) key.channel();
      final SocketChannel channel = server.accept();
      if (channel != null)
      {
        HTTPIOHandler handler;
        if(servChannels.get(server).booleanValue())
          handler=new HTTPSReader(this, channel, sslContext);
        else
          handler=new HTTPReader(this, channel);
        channel.configureBlocking (false);
        channel.register (servSelector, SelectionKey.OP_READ, handler);
        synchronized(handlers) // synched because you can't iterate and modify, and because its a linkedlist
        {
          handlers.add(handler);
        }
      }
    }
    if(key.isReadable() // bytes were received on one of the channel .. so read!
    || (((key.interestOps() & SelectionKey.OP_WRITE)==SelectionKey.OP_WRITE) && key.isWritable()))
    {
      final HTTPIOHandler handler = (HTTPIOHandler)key.attachment();
      //config.getLogger().finer("Read/Write: "+handler.getName());
      if(!handler.isCloseable())
      {
        key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
        executor.execute(handler);
      }
    }
    else
    if(key.attachment() instanceof HTTPIOHandler)
    {
      final HTTPIOHandler handler = (HTTPIOHandler)key.attachment();
      config.getLogger().finer("Rejected handler key for "+handler.getName());
    }
  }
View Full Code Here


    synchronized(handlers)
    {
      // remove any stray handlers from time to time
      for(final Iterator<HTTPIOHandler> i = handlers.iterator(); i.hasNext(); )
      {
        final HTTPIOHandler handler=i.next();
        if(handler.isCloseable())
        {
          if(handlersToShutDown == null)
          {
            handlersToShutDown = new LinkedList<HTTPIOHandler>();
          }
          handlersToShutDown.add(handler);
          i.remove();
        }
      }
    }
    if(handlersToShutDown != null)
    {
      for(final HTTPIOHandler handler : handlersToShutDown)
      {
        handler.closeAndWait();
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.planet_ink.coffee_web.interfaces.HTTPIOHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.