Thrift: generate Processors not Servers

Summary: Because the gen'd code isn't actually a server

Reviewed By: aditya


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664794 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index ce93926..095dc47 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -834,7 +834,7 @@
 
   // Generate the header portion
   f_header_ <<
-    "class " << service_name_ << "Server : " <<
+    "class " << service_name_ << "Processor : " <<
     "public facebook::thrift::TProcessor {" << endl;
 
   // Protected data members
@@ -845,7 +845,7 @@
     indent() << "boost::shared_ptr<" << service_name_ << "If> _iface;" << endl <<
     indent() << "boost::shared_ptr<const facebook::thrift::protocol::TProtocol> _iprot;" << endl <<
     indent() << "boost::shared_ptr<const facebook::thrift::protocol::TProtocol> _oprot;" << endl <<
-    indent() << "std::map<std::string, void (" << service_name_ << "Server::*)(int32_t, boost::shared_ptr<facebook::thrift::transport::TTransport>, boost::shared_ptr<facebook::thrift::transport::TTransport>)> _processMap;" << endl;
+    indent() << "std::map<std::string, void (" << service_name_ << "Processor::*)(int32_t, boost::shared_ptr<facebook::thrift::transport::TTransport>, boost::shared_ptr<facebook::thrift::transport::TTransport>)> _processMap;" << endl;
   indent_down();
 
   // Process function declarations
@@ -868,7 +868,7 @@
     declare_map += (*f_iter)->get_name();
     declare_map += "\"] = &";
     declare_map += service_name_;
-    declare_map += "Server::process_";
+    declare_map += "Processor::process_";
     declare_map += (*f_iter)->get_name();
     declare_map += ";\n";
   }
@@ -876,17 +876,17 @@
 
   f_header_ << 
     " public: " << endl <<
-    indent() << service_name_ << "Server(boost::shared_ptr<" << service_name_ << "If> iface, boost::shared_ptr<const facebook::thrift::protocol::TProtocol> prot) : " <<
+    indent() << service_name_ << "Processor(boost::shared_ptr<" << service_name_ << "If> iface, boost::shared_ptr<const facebook::thrift::protocol::TProtocol> prot) : " <<
     "_iface(iface), _iprot(prot), _oprot(prot) {" << endl <<
     declare_map <<
     indent() << "}" << endl <<
-    indent() << service_name_ << "Server(boost::shared_ptr<" << service_name_ << "If> iface, boost::shared_ptr<const facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<const facebook::thrift::protocol::TProtocol> oprot) : " <<
+    indent() << service_name_ << "Processor(boost::shared_ptr<" << service_name_ << "If> iface, boost::shared_ptr<const facebook::thrift::protocol::TProtocol> iprot, boost::shared_ptr<const facebook::thrift::protocol::TProtocol> oprot) : " <<
     "_iface(iface), _iprot(iprot), _oprot(oprot) {" << endl <<
     declare_map <<
     indent() << "}" << endl <<
     endl <<
     indent() << "bool process(boost::shared_ptr<facebook::thrift::transport::TTransport> _itrans, boost::shared_ptr<facebook::thrift::transport::TTransport> _otrans);" << endl <<
-    indent() << "virtual ~" << service_name_ << "Server() {}" << endl;
+    indent() << "virtual ~" << service_name_ << "Processor() {}" << endl;
   indent_down();
   f_header_ <<
     "};" << endl << endl;
@@ -894,7 +894,7 @@
 
   // Generate the server implementation
   f_service_ <<
-    "bool " << service_name_ << "Server::" <<
+    "bool " << service_name_ << "Processor::" <<
     "process(boost::shared_ptr<facebook::thrift::transport::TTransport> itrans, boost::shared_ptr<facebook::thrift::transport::TTransport> otrans) {" << endl;
   indent_up();
 
@@ -913,7 +913,7 @@
 
   // HOT: member function pointer map
   f_service_ <<
-    indent() << "std::map<std::string, void (" << service_name_ << "Server::*)(int32_t, boost::shared_ptr<facebook::thrift::transport::TTransport>, boost::shared_ptr<facebook::thrift::transport::TTransport>)>::iterator pfn;" << endl <<
+    indent() << "std::map<std::string, void (" << service_name_ << "Processor::*)(int32_t, boost::shared_ptr<facebook::thrift::transport::TTransport>, boost::shared_ptr<facebook::thrift::transport::TTransport>)>::iterator pfn;" << endl <<
     indent() << "pfn = _processMap.find(fname);" << endl <<
     indent() << "if (pfn == _processMap.end()) {" << endl <<
     indent() << "  throw facebook::thrift::Exception(\"Unknown function name: '\"+fname+\"'\");" << endl <<
@@ -1003,7 +1003,7 @@
                                                 t_function* tfunction) {
   // Open function
   f_service_ <<
-    "void " << tservice->get_name() << "Server::" <<
+    "void " << tservice->get_name() << "Processor::" <<
     "process_" << tfunction->get_name() <<
     "(int32_t seqid, boost::shared_ptr<facebook::thrift::transport::TTransport> itrans, boost::shared_ptr<facebook::thrift::transport::TTransport> otrans)" << endl;
   scope_up(f_service_);
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 6d12dce..987a755 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -599,11 +599,11 @@
 
   // Generate the header portion
   f_service_ <<
-    "public static class Server implements TProcessor {" << endl;
+    "public static class Processor implements TProcessor {" << endl;
   indent_up();
 
   indent(f_service_) <<
-    "public Server(Iface iface, TProtocol prot)" << endl;
+    "public Processor(Iface iface, TProtocol prot)" << endl;
   scope_up(f_service_);
   indent(f_service_) << 
     "this(iface, prot, prot);" << endl;
@@ -611,7 +611,7 @@
   f_service_ << endl;
 
   indent(f_service_) <<
-    "public Server(Iface iface, TProtocol iprot, TProtocol oprot)" << endl;
+    "public Processor(Iface iface, TProtocol iprot, TProtocol oprot)" << endl;
   scope_up(f_service_);
   f_service_ <<
     indent() << "_iface = iface;" << endl <<
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index a8f66ad..f07af33 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -571,7 +571,7 @@
 
   // Generate the header portion
   f_service_ <<
-    "class Server(Iface, TProcessor):" << endl;
+    "class Processor(Iface, TProcessor):" << endl;
   indent_up();
 
   indent(f_service_) <<
@@ -587,7 +587,7 @@
     indent() << "self.__processMap = {" << endl;
   for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
     f_service_ <<
-      indent() << "  \"" << (*f_iter)->get_name() << "\" : Server.process_" << (*f_iter)->get_name() << "," << endl;
+      indent() << "  \"" << (*f_iter)->get_name() << "\" : Processor.process_" << (*f_iter)->get_name() << "," << endl;
   }
   f_service_ <<
     indent() << "}" << endl;
diff --git a/test/cpp/src/TestServer.cc b/test/cpp/src/TestServer.cc
index f743aea..f2f9eca 100644
--- a/test/cpp/src/TestServer.cc
+++ b/test/cpp/src/TestServer.cc
@@ -332,7 +332,7 @@
 
   shared_ptr<TestHandler> testHandler(new TestHandler());
 
-  shared_ptr<ThriftTestServer> testServer(new ThriftTestServer(testHandler, binaryProtocol));
+  shared_ptr<ThriftTestProcessor> testProcessor(new ThriftTestProcessor(testHandler, binaryProtocol));
 
   // Transport
   shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
@@ -346,7 +346,7 @@
   if (serverType == "simple") {
 
     // Server
-    TSimpleServer simpleServer(testServer,
+    TSimpleServer simpleServer(testProcessor,
 			       serverSocket,
                                transportFactory,
 			       serverOptions
@@ -367,7 +367,7 @@
 
     threadManager->start();
 
-    TThreadPoolServer threadPoolServer(testServer,
+    TThreadPoolServer threadPoolServer(testProcessor,
 				       serverSocket,
                                        transportFactory,
 				       threadManager,
diff --git a/test/java/src/TestServer.java b/test/java/src/TestServer.java
index b527777..ab8603a 100644
--- a/test/java/src/TestServer.java
+++ b/test/java/src/TestServer.java
@@ -241,8 +241,8 @@
         new TBinaryProtocol();
       TestHandler testHandler =
         new TestHandler();
-      ThriftTest.Server testServer =
-        new ThriftTest.Server(testHandler, binaryProtocol);
+      ThriftTest.Processor testProcessor =
+        new ThriftTest.Processor(testHandler, binaryProtocol);
 
       // Transport
       TServerSocket tServerSocket =
@@ -251,10 +251,10 @@
       TServer serverEngine;
 
       // Simple Server
-      // serverEngine = new TSimpleServer(testServer, tServerSocket);
+      // serverEngine = new TSimpleServer(testProcessor, tServerSocket);
 
       // ThreadPool Server
-      serverEngine =  new TThreadPoolServer(testServer, tServerSocket);
+      serverEngine =  new TThreadPoolServer(testProcessor, tServerSocket);
 
       // Run it
       System.out.println("Starting the server on port " + port + "...");
diff --git a/test/php/TestClient.php b/test/php/TestClient.php
index a92adcc..27a66ea 100644
--- a/test/php/TestClient.php
+++ b/test/php/TestClient.php
@@ -7,8 +7,11 @@
   $MODE = 'normal';
 }
 
+/** Set the Thrift root */
+$GLOBALS['THRIFT_ROOT'] = '../../lib/php/src';
+
 /** Include the Thrift base */
-require_once '/home/mcslee/code/projects/thrift/lib/php/src/Thrift.php';
+require_once $GLOBALS['THRIFT_ROOT'].'/Thrift.php';
 
 /** Include the binary protocol */
 require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
diff --git a/test/py/TestServer.py b/test/py/TestServer.py
index db2ad81..f0f9ba1 100755
--- a/test/py/TestServer.py
+++ b/test/py/TestServer.py
@@ -54,7 +54,7 @@
 transport = TSocket.TServerSocket(9090)
 protocol = TBinaryProtocol.TBinaryProtocol()
 handler = TestHandler()
-iface = ThriftTest.Server(handler, protocol)
+processor = ThriftTest.Processor(handler, protocol)
 factory = TTransport.TBufferedTransportFactory()
-server = TServer.TSimpleServer(iface, transport, factory)
+server = TServer.TSimpleServer(processor, transport, factory)
 server.run()