PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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 */
 5package com.razie.pub.http.sample;
 6
 7import com.razie.pub.comms.AgentHandle;
 8import com.razie.pub.http.LightContentServer;
 9import com.razie.pub.http.LightServer;
10import com.razie.pub.http.SocketCmdHandler;
11import com.razie.pub.http.SocketReceiver;
12
13/**
14 * this is a server that doesn't want to use threads, will handle one request at a time...not sure
15 * why you'd do that, but hey...
16 *
17 * @author razvanc99
18 */
19public class SimpleNoThreadsServer extends LightServer {
20
21    public SimpleNoThreadsServer(AgentHandle h, SocketCmdHandler... handlers) {
22        super(Integer.parseInt(h.port), 10, null, new LightContentServer(null));
23        for (SocketCmdHandler cmd : handlers)  registerHandler(cmd);
24    }
25
26    /** if you have a special thread handling, overload this and use your own threads */
27    @Override
28    public void runReceiver(SocketReceiver conn_c) {
29        conn_c.run();
30    }
31}