-- Change concept of protocol and transport factory

Summary:
- Transport factories now wrap around one transport
- Protocol factories now wrap around one transport (as opposed to a pair of input/output
   transports)
- TServer now takes input/output transport and protocol factories

The motivation for this change is that you could concievably want to use a different protocol or
transport for input and output. An example is that incoming data is encoded using binary protocol
but outgoing data is encrypted XML (with encryption being done on the transport level).

This change should be mostly backwards compatible because the TServer classes have constructors
that take a transport factory and use that for both the input and transport factories. The only
change might be for anyone who is using the C++ client code directly i.e. instantiating
TBinaryProtocol() directly because the constructor now only accepts one transport.

Reviewed By: Slee

Test Plan: Everything compiles (for both thrift and search).

Notes:
I am going to make the same changes in all the supported languages after this...


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664940 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TNonblockingServer.cpp b/lib/cpp/src/server/TNonblockingServer.cpp
index 5755514..25cd7b5 100644
--- a/lib/cpp/src/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/server/TNonblockingServer.cpp
@@ -28,17 +28,13 @@
   // Set flags, which also registers the event
   setFlags(eventFlags);
 
-  // TODO: this needs to be replaced by the new version of TTransportFactory
-  factoryInputTransport_ = (s->getTransportFactory()->getIOTransports(inputTransport_)).first;
-  //  factoryOutputTransport_ = (transportFactory->getIOTransports(outputTransport_)).first;
+  // get input/transports
+  factoryInputTransport_ = s->getInputTransportFactory()->getTransport(inputTransport_);
+  factoryOutputTransport_ = s->getOutputTransportFactory()->getTransport(outputTransport_);
 
   // Create protocol
-  std::pair<shared_ptr<TProtocol>,shared_ptr<TProtocol> > iop;
-  iop = s->getProtocolFactory()->getIOProtocols(factoryInputTransport_ ,
-                                                outputTransport_);
-  inputProtocol_ = iop.first;
-  outputProtocol_ = iop.second;
-
+  inputProtocol_ = s->getInputProtocolFactory()->getProtocol(factoryInputTransport_);
+  outputProtocol_ = s->getOutputProtocolFactory()->getProtocol(factoryOutputTransport_);
 }
 
 void TConnection::workSocket() {
@@ -353,7 +349,7 @@
 
   // close any factory produced transports
   factoryInputTransport_->close();
-  //  factoryOutputTransport_->close();
+  factoryOutputTransport_->close();
 
   // Give this object back to the server that owns it
   server_->returnConnection(this);
@@ -366,7 +362,7 @@
 TConnection* TNonblockingServer::createConnection(int socket, short flags) {
   // Check the stack
   if (connectionStack_.empty()) {
-    return new TConnection(socket, flags, this, this->getTransportFactory());
+    return new TConnection(socket, flags, this);
   } else {
     TConnection* result = connectionStack_.top();
     connectionStack_.pop();