/razweb/src/com/razie/pub/http/sample/SimpleNoThreadsServer.java

http://razpub.googlecode.com/ · Java · 31 lines · 16 code · 4 blank · 11 comment · 1 complexity · 1ddb9af4107158dea90c44e41ebeaa08 MD5 · raw file

  1. /**
  2. * Razvan's public code. Copyright 2008 based on Apache license (share alike) see LICENSE.txt for
  3. * details. No warranty implied nor any liability assumed for this code.
  4. */
  5. package com.razie.pub.http.sample;
  6. import com.razie.pub.comms.AgentHandle;
  7. import com.razie.pub.http.LightContentServer;
  8. import com.razie.pub.http.LightServer;
  9. import com.razie.pub.http.SocketCmdHandler;
  10. import com.razie.pub.http.SocketReceiver;
  11. /**
  12. * this is a server that doesn't want to use threads, will handle one request at a time...not sure
  13. * why you'd do that, but hey...
  14. *
  15. * @author razvanc99
  16. */
  17. public class SimpleNoThreadsServer extends LightServer {
  18. public SimpleNoThreadsServer(AgentHandle h, SocketCmdHandler... handlers) {
  19. super(Integer.parseInt(h.port), 10, null, new LightContentServer(null));
  20. for (SocketCmdHandler cmd : handlers) registerHandler(cmd);
  21. }
  22. /** if you have a special thread handling, overload this and use your own threads */
  23. @Override
  24. public void runReceiver(SocketReceiver conn_c) {
  25. conn_c.run();
  26. }
  27. }