Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / apps / JAWS / server / HTTP_Server.h
blobae212c2bef6cef8bc7df1d44f9a16a692fdb7f2e
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file HTTP_Server.h
7 * @author James Hu
8 */
9 //=============================================================================
12 #ifndef HTTP_SERVER_H
13 #define HTTP_SERVER_H
15 #if !defined (ACE_LACKS_PRAGMA_ONCE)
16 # pragma once
17 #endif /* ACE_LACKS_PRAGMA_ONCE */
19 #include "ace/Service_Config.h"
20 #include "ace/Service_Object.h"
21 #include "ace/Thread_Manager.h"
22 #include "ace/Acceptor.h"
23 #include "ace/LOCK_SOCK_Acceptor.h"
24 #include "ace/Task_T.h"
25 #include "ace/Asynch_IO.h"
26 #include "ace/svc_export.h"
27 #include "HTTP_Handler.h"
28 #include "ace/Synch_Traits.h"
29 #include "ace/Thread_Mutex.h"
30 #include "ace/Null_Mutex.h"
31 #include "ace/Global_Macros.h"
33 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
34 // Forward declaration.
35 class ACE_Proactor;
36 ACE_END_VERSIONED_NAMESPACE_DECL
38 #if defined (ACE_HAS_THREAD_SAFE_ACCEPT)
39 typedef ACE_LOCK_SOCK_Acceptor<ACE_SYNCH_NULL_MUTEX> HTTP_SOCK_Acceptor;
40 #else
41 typedef ACE_LOCK_SOCK_Acceptor<ACE_SYNCH_MUTEX> HTTP_SOCK_Acceptor;
42 #endif /* ACE_HAS_THREAD_SAFE_ACCEPT */
44 typedef HTTP_SOCK_Acceptor HTTP_Acceptor;
46 /**
47 * @class HTTP_Server
49 * @brief This server is used to create HTTP Handlers for the Web
50 * server
52 class ACE_Svc_Export HTTP_Server : public ACE_Service_Object
54 public:
55 /// Initialization
56 virtual int init (int argc, ACE_TCHAR *argv[]);
58 /// Exit hooks
59 virtual int fini ();
61 protected:
62 /// Thread Per Request implementation
63 virtual int thread_per_request (HTTP_Handler_Factory &factory);
65 /// Asynch Thread Pool implementation
66 virtual int asynch_thread_pool ();
68 /// Synch Thread Pool implementation
69 virtual int synch_thread_pool (HTTP_Handler_Factory &factory);
71 private:
72 // James, comment these data members.
73 void parse_args (int argc, ACE_TCHAR **argv);
74 int port_;
75 int threads_;
76 int strategy_;
77 int backlog_;
78 int throttle_;
79 bool caching_;
80 ACE_Thread_Manager tm_;
81 HTTP_Acceptor acceptor_;
84 /**
85 * @class Synch_Thread_Pool_Task
87 * @brief Used to implement Synch Thread Pool
89 * Describe this and the others below.
90 * NOTE: this class was modified to make caching disabling possible
92 class Synch_Thread_Pool_Task : public ACE_Task<ACE_NULL_SYNCH>
94 public:
95 Synch_Thread_Pool_Task (HTTP_Acceptor &acceptor,
96 ACE_Thread_Manager &tm,
97 int threads,
98 HTTP_Handler_Factory &factory);
99 virtual int svc ();
101 private:
102 HTTP_Acceptor &acceptor_;
103 HTTP_Handler_Factory &factory_;
107 * @class Thread_Per_Request_Task
109 * @brief Used to implement Thread Per Request.
111 * Spawns a new thread for every new incoming connection. The
112 * handle below is the socket stream of the incoming connection.
113 * NOTE: this class was modified to make caching disabling possible
115 class Thread_Per_Request_Task : public ACE_Task<ACE_NULL_SYNCH>
117 public:
118 Thread_Per_Request_Task (ACE_HANDLE handle,
119 ACE_Thread_Manager &tm,
120 int &grp_id,
121 HTTP_Handler_Factory &factory);
122 virtual int open (void *args = 0);
123 virtual int close (u_long);
124 virtual int svc ();
126 private:
127 ACE_HANDLE handle_;
128 int &grp_id_;
129 HTTP_Handler_Factory &factory_;
132 // This only works on Win32
133 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
135 * @class Asynch_Thread_Pool_Task
137 * @brief Used to implement Asynch Thread Pool
139 * The proactor below utilizes WaitForMultipleObjects.
141 class Asynch_Thread_Pool_Task : public ACE_Task<ACE_NULL_SYNCH>
143 public:
144 Asynch_Thread_Pool_Task (ACE_Proactor &proactor,
145 ACE_Thread_Manager &tm);
146 virtual int svc ();
148 private:
149 ACE_Proactor &proactor_;
151 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
153 ACE_SVC_FACTORY_DECLARE (HTTP_Server)
155 ACE_STATIC_SVC_DECLARE_EXPORT (ACE_Svc, HTTP_Server)
157 #endif /* HTTP_SERVER_H */