David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 19 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 20 | #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ |
| 21 | #define _THRIFT_SERVER_TSIMPLESERVER_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 22 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 23 | #include <thrift/server/TServerFramework.h> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 24 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 25 | namespace apache { |
| 26 | namespace thrift { |
| 27 | namespace server { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 28 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 29 | /** |
| 30 | * This is the most basic simple server. It is single-threaded and runs a |
| 31 | * continuous loop of accepting a single connection, processing requests on |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 32 | * that connection until it closes, and then repeating. |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 33 | */ |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 34 | class TSimpleServer : public TServerFramework { |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 35 | public: |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 36 | TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, |
| 37 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 38 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, |
| 39 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame] | 40 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 41 | TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor, |
| 42 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 43 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, |
| 44 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 45 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 46 | TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, |
| 47 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 48 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, |
| 49 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, |
| 50 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, |
| 51 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame] | 52 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 53 | TSimpleServer(const boost::shared_ptr<apache::thrift::TProcessor>& processor, |
| 54 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 55 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, |
| 56 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, |
| 57 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, |
| 58 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 59 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 60 | virtual ~TSimpleServer(); |
Mark Slee | 6e3f637 | 2007-03-01 22:05:46 +0000 | [diff] [blame] | 61 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 62 | protected: |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 63 | virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; |
| 64 | virtual void onClientDisconnected(TConnectedClient *pClient) /* override */; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 65 | }; |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame^] | 66 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | } // apache::thrift::server |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 70 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 71 | #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ |