blob: 23aef22e5ebed7298970f6ea3d6bb6b7f313f173 [file] [log] [blame]
Christopher Piro094823a2007-07-18 00:26:12 +00001%%% Copyright (c) 2007- Facebook
2%%% Distributed under the Thrift Software License
3%%%
4%%% See accompanying file LICENSE or visit the Thrift site at:
5%%% http://developers.facebook.com/thrift/
6
7-module(tServer).
8
9-include("oop.hrl").
10
11-include("thrift.hrl").
12-include("server/tServer.hrl").
13-include("transport/tTransportFactory.hrl").
14-include("protocol/tBinaryProtocolFactory.hrl").
15
16-behavior(oop).
17
18-export([attr/4, super/0, inspect/1]).
19
20-export([new/5, new/4, new/3, serve/1]).
21
22%%%
23%%% define attributes
24%%% 'super' is required unless ?MODULE is a base class
25%%%
26
27?DEFINE_ATTR(handler);
28?DEFINE_ATTR(processor);
29?DEFINE_ATTR(serverTransport);
30?DEFINE_ATTR(transportFactory);
31?DEFINE_ATTR(protocolFactory).
32
33%%%
34%%% behavior callbacks
35%%%
36
37%%% super() -> SuperModule = atom()
38%%% | none
39
40super() ->
41 none.
42
43%%% inspect(This) -> string()
44
45inspect(This) ->
46 ?FORMAT_ATTR(handler) ++ ", " ++
47 ?FORMAT_ATTR(processor) ++ ", " ++
48 ?FORMAT_ATTR(serverTransport) ++ ", " ++
49 ?FORMAT_ATTR(transportFactory) ++ ", " ++
50 ?FORMAT_ATTR(protocolFactory).
51
52%%%
53%%% class methods
54%%%
55
56new(Handler, Processor, ServerTransport, TransportFactory, ProtocolFactory) ->
57 #?MODULE{handler=Handler, processor=Processor, serverTransport=ServerTransport,
58
59 %% much ado about nothing but
60 %% subclasses pass nil too
61 transportFactory =
62 case TransportFactory of
63 nil -> tTransportFactory:new();
64 _ -> TransportFactory
65 end,
66
67 protocolFactory =
68 case ProtocolFactory of
69 nil -> tBinaryProtocolFactory:new();
70 _ -> ProtocolFactory
71 end
72}.
73
74new(Handler, Processor, ServerTransport) ->
75 new(Handler, Processor, ServerTransport, nil, nil).
76
77new(Handler, Processor, ServerTransport, TransportFactory) ->
78 new(Handler, Processor, ServerTransport, TransportFactory, nil).
79
80serve(_This) ->
81 ok.