1 23 24 package com.rift.coad.lib.httpd; 25 26 import org.apache.log4j.Logger; 28 29 import com.rift.coad.lib.thread.CoadunationThreadGroup; 31 import com.rift.coad.lib.security.ThreadsPermissionContainer; 32 import com.rift.coad.lib.configuration.Configuration; 33 import com.rift.coad.lib.configuration.ConfigurationFactory; 34 35 36 41 public class HttpDaemon { 42 43 public final static String USERNAME_KEY = "daemon_username"; 45 public final static int DEFAULT_PORT = 8085; 46 47 protected Logger log = 49 Logger.getLogger(HttpDaemon.class.getName()); 50 51 52 private CoadunationThreadGroup threadGroup = null; 54 private Configuration configuration = null; 55 private HttpRequestManager httpRequestManager = null; 56 57 58 68 public HttpDaemon(CoadunationThreadGroup threadGroup) throws HttpdException { 69 try { 70 configuration = ConfigurationFactory.getInstance().getConfig( 72 this.getClass()); 73 74 this.threadGroup = threadGroup.createThreadGroup(); 76 77 httpRequestManager = new HttpRequestManager(threadGroup); 79 80 RequestListenerThread requestListenerThread = 82 new RequestListenerThread(httpRequestManager); 83 this.threadGroup.addThread(requestListenerThread, 84 configuration.getString(HttpDaemon.USERNAME_KEY)); 85 requestListenerThread.start(); 86 87 } catch (Exception ex) { 88 throw new HttpdException("Failed to instanciate the HttpDaemon :" + 89 ex.getMessage(),ex); 90 } 91 } 92 93 94 95 98 public void shutdown() { 99 log.info("Shutting down the web services interface."); 100 threadGroup.terminate(); 101 httpRequestManager.shutdown(); 102 } 103 } 104 | Popular Tags |