Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 1 | package com.facebook.thrift.server; |
| 2 | |
| 3 | import com.facebook.thrift.TProcessor; |
| 4 | |
| 5 | /** |
| 6 | * Generic interface for a Thrift server. |
| 7 | * |
| 8 | * @author Mark Slee <mcslee@facebook.com> |
| 9 | */ |
| 10 | public abstract class TServer { |
| 11 | |
| 12 | /** |
| 13 | * The options class should be subclassed by particular servers which have |
| 14 | * specific options needs, while the general options should live here. |
| 15 | */ |
| 16 | public static class Options { |
| 17 | public Options() {} |
| 18 | } |
| 19 | |
| 20 | /** Core processor */ |
| 21 | protected TProcessor processor_; |
| 22 | |
| 23 | /** Server options */ |
| 24 | protected Options options_; |
| 25 | |
| 26 | /** |
Mark Slee | ffcddd6 | 2006-09-06 20:37:03 +0000 | [diff] [blame^] | 27 | * Default options constructor |
| 28 | */ |
| 29 | protected TServer(TProcessor processor) { |
| 30 | this(processor, new Options()); |
| 31 | } |
| 32 | |
| 33 | /** |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 34 | * Default constructor, all servers take a processor and some options. |
| 35 | */ |
| 36 | protected TServer(TProcessor processor, Options options) { |
| 37 | processor_ = processor; |
| 38 | options_ = options; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * The run method fires up the server and gets things going. |
| 43 | */ |
| 44 | public abstract void run(); |
| 45 | } |