forked from zamronypj/fano
/
SimpleDispatcherFactoryImpl.pas
68 lines (56 loc) · 1.68 KB
/
SimpleDispatcherFactoryImpl.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{*!
* Fano Web Framework (https://fanoframework.github.io)
*
* @link https://github.com/fanoframework/fano
* @copyright Copyright (c) 2018 Zamrony P. Juhara
* @license https://github.com/fanoframework/fano/blob/master/LICENSE (MIT)
*}
unit SimpleDispatcherFactoryImpl;
interface
{$MODE OBJFPC}
uses
DependencyIntf,
DependencyContainerIntf,
FactoryImpl,
RouteMatcherIntf;
type
(*!--------------------------------------------------
* factory class for TSimpleDispatcher,
* route dispatcher implementation which does not support
* middleware
*
* @author Zamrony P. Juhara <zamronypj@yahoo.com>
*---------------------------------------------------*)
TSimpleDispatcherFactory = class(TFactory, IDependencyFactory)
private
routeMatcher : IRouteMatcher;
public
constructor create (const routeMatcherInst : IRouteMatcher);
destructor destroy(); override;
function build(const container : IDependencyContainer) : IDependency; override;
end;
implementation
uses
SimpleDispatcherImpl,
RequestFactoryImpl,
ResponseFactoryImpl;
constructor TSimpleDispatcherFactory.create(
const routeMatcherInst : IRouteMatcher
);
begin
routeMatcher := routeMatcherInst;
end;
destructor TSimpleDispatcherFactory.destroy();
begin
inherited destroy();
routeMatcher := nil;
end;
function TSimpleDispatcherFactory.build(const container : IDependencyContainer) : IDependency;
begin
result := TSimpleDispatcher.create(
routeMatcher,
TResponseFactory.create(),
TRequestFactory.create()
);
end;
end.