THRIFT-1316. cpp: update server classes to accept
TProcessorFactory objects

Patch: Adam Simpkins

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1164201 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h
index 5cda2c5..a26fcc5 100644
--- a/lib/cpp/src/server/TNonblockingServer.h
+++ b/lib/cpp/src/server/TNonblockingServer.h
@@ -252,18 +252,48 @@
   }
 
  public:
-  TNonblockingServer(const boost::shared_ptr<TProcessor>& processor,
-                     int port) :
+  template<typename ProcessorFactory>
+  TNonblockingServer(
+      const boost::shared_ptr<ProcessorFactory>& processorFactory,
+      int port,
+      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
+    TServer(processorFactory) {
+    init(port);
+  }
+
+  template<typename Processor>
+  TNonblockingServer(const boost::shared_ptr<Processor>& processor,
+                     int port,
+                     THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
     TServer(processor) {
     init(port);
   }
 
+  template<typename ProcessorFactory>
   TNonblockingServer(
-      const boost::shared_ptr<TProcessor>& processor,
+      const boost::shared_ptr<ProcessorFactory>& processorFactory,
       const boost::shared_ptr<TProtocolFactory>& protocolFactory,
       int port,
       const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>()) :
+        boost::shared_ptr<ThreadManager>(),
+      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
+    TServer(processorFactory) {
+
+    init(port);
+
+    setInputProtocolFactory(protocolFactory);
+    setOutputProtocolFactory(protocolFactory);
+    setThreadManager(threadManager);
+  }
+
+  template<typename Processor>
+  TNonblockingServer(
+      const boost::shared_ptr<Processor>& processor,
+      const boost::shared_ptr<TProtocolFactory>& protocolFactory,
+      int port,
+      const boost::shared_ptr<ThreadManager>& threadManager =
+        boost::shared_ptr<ThreadManager>(),
+      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
     TServer(processor) {
 
     init(port);
@@ -273,15 +303,39 @@
     setThreadManager(threadManager);
   }
 
+  template<typename ProcessorFactory>
   TNonblockingServer(
-      const boost::shared_ptr<TProcessor>& processor,
+      const boost::shared_ptr<ProcessorFactory>& processorFactory,
       const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
       const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
       const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
       const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
       int port,
       const boost::shared_ptr<ThreadManager>& threadManager =
-        boost::shared_ptr<ThreadManager>()) :
+        boost::shared_ptr<ThreadManager>(),
+      THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)) :
+    TServer(processorFactory) {
+
+    init(port);
+
+    setInputTransportFactory(inputTransportFactory);
+    setOutputTransportFactory(outputTransportFactory);
+    setInputProtocolFactory(inputProtocolFactory);
+    setOutputProtocolFactory(outputProtocolFactory);
+    setThreadManager(threadManager);
+  }
+
+  template<typename Processor>
+  TNonblockingServer(
+      const boost::shared_ptr<Processor>& processor,
+      const boost::shared_ptr<TTransportFactory>& inputTransportFactory,
+      const boost::shared_ptr<TTransportFactory>& outputTransportFactory,
+      const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory,
+      const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory,
+      int port,
+      const boost::shared_ptr<ThreadManager>& threadManager =
+        boost::shared_ptr<ThreadManager>(),
+      THRIFT_OVERLOAD_IF(Processor, TProcessor)) :
     TServer(processor) {
 
     init(port);