Thrift TTransportFactory model for servers

Summary: Servers need to create bufferedtransports etc. around the transports they get in a user-definable way. So use a factory pattern to allow the user to supply an object to the server that defines this behavior.


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664792 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TServer.h b/lib/cpp/src/server/TServer.h
index d53223f..c19302f 100644
--- a/lib/cpp/src/server/TServer.h
+++ b/lib/cpp/src/server/TServer.h
@@ -1,7 +1,9 @@
-#ifndef T_SERVER_H
-#define T_SERVER_H
+#ifndef _THRIFT_SERVER_TSERVER_H_
+#define _THRIFT_SERVER_TSERVER_H_ 1
 
 #include <TProcessor.h>
+#include <transport/TServerTransport.h>
+#include <transport/TTransportFactory.h>
 #include <concurrency/Thread.h>
 
 #include <boost/shared_ptr.hpp>
@@ -9,6 +11,7 @@
 namespace facebook { namespace thrift { namespace server { 
 
 using namespace facebook::thrift;
+using namespace facebook::thrift::transport;
 using namespace boost;
 
 class TServerOptions;
@@ -24,10 +27,22 @@
   virtual void run() = 0;
   
 protected:
-  TServer(shared_ptr<TProcessor> processor, shared_ptr<TServerOptions> options) :
+  TServer(shared_ptr<TProcessor> processor,
+          shared_ptr<TServerTransport> serverTransport,
+          shared_ptr<TTransportFactory> transportFactory,
+          shared_ptr<TServerOptions> options) :
+    processor_(processor),
+    serverTransport_(serverTransport),
+    transportFactory_(transportFactory),
+    options_(options) {}
+
+  TServer(shared_ptr<TProcessor> processor,
+          shared_ptr<TServerOptions> options) :
     processor_(processor), options_(options) {}
-  
+ 
   shared_ptr<TProcessor> processor_;
+  shared_ptr<TServerTransport> serverTransport_;
+  shared_ptr<TTransportFactory> transportFactory_;
   shared_ptr<TServerOptions> options_;
 };
   
@@ -35,12 +50,12 @@
  * Class to encapsulate all generic server options.
  */
 class TServerOptions {
-public:
+ public:
   // TODO(mcslee): Fill in getters/setters here
-protected:
+ protected:
   // TODO(mcslee): Fill data members in here
 };
 
 }}} // facebook::thrift::server
 
-#endif
+#endif // #ifndef _THRIFT_SERVER_TSERVER_H_