KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > server > transport > http > UbikHttpHandler


1 package org.sapia.ubik.rmi.server.transport.http;
2
3 import org.sapia.ubik.net.PooledThread;
4 import org.sapia.ubik.net.Uri;
5
6 import simple.http.Request;
7 import simple.http.Response;
8 import simple.http.load.ActiveService;
9 import simple.http.serve.Context;
10
11
12 /**
13  * An instance of this class handles incoming requests and delegates them to
14  * <code>HttpRmiServerThread</code>s internally kept in a pool.
15  *
16  * @author Yanick Duchesne
17  * <dl>
18  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
19  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
20  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
21  * </dl>
22  */

23 public class UbikHttpHandler extends ActiveService {
24   private HttpAddress _addr;
25   private HttpRmiServerThreadPool _pool;
26
27   public UbikHttpHandler(Uri localHostUri, Context ctx, int maxThreads) {
28     super(ctx);
29     _addr = new HttpAddress(localHostUri);
30     _pool = new HttpRmiServerThreadPool(true, maxThreads);
31   }
32
33   /**
34    * @see simple.http.serve.BasicResource#process(simple.http.Request, simple.http.Response)
35    */

36   protected void process(Request req, Response res) throws Exception JavaDoc {
37     HttpRmiServerConnection conn = new HttpRmiServerConnection(_addr, req, res);
38     PooledThread th = (PooledThread) _pool.acquire();
39     th.exec(new org.sapia.ubik.net.Request(conn, _addr));
40   }
41 }
42
Popular Tags