-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSAPUI5ServerDaemon.dpr
130 lines (106 loc) · 2.59 KB
/
SAPUI5ServerDaemon.dpr
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// RESTful ORM server for OpenUI5 demo
// does not server static content
// static content is done by a standard webserver like apache or its likes
program SAPUI5ServerDaemon;
{$IFDEF LINUX}
{$IFDEF CPUX86_64}
{$IFDEF FPC_CROSSCOMPILING}
{$linklib libc_nonshared.a}
{$ENDIF}
{$ENDIF}
{$ENDIF}
uses
{$ifdef Linux}
cthreads,
{$endif}
Classes,
SysUtils,
SampleData,
dataserver,
daemonapp;
type
TTestDaemon = Class(TCustomDaemon)
Private
mORMotServer: TmORMotODataServer;
public
Function Start : Boolean; override;
Function Stop : Boolean; override;
Function Pause : Boolean; override;
Function Continue : Boolean; override;
Function Execute : Boolean; override;
Function ShutDown : Boolean; override;
Function Install : Boolean; override;
Function UnInstall: boolean; override;
end;
Procedure AWriteln(MSg : String; B : Boolean);
begin
Application.Log(etcustom,Msg+BoolToStr(B));
end;
{ TTestDaemon }
function TTestDaemon.Start: Boolean;
begin
Result:=inherited Start;
AWriteln('Daemon Start',Result);
mORMotServer:=TmORMotODataServer.Create;
AWriteln('Server Start',Result);
end;
function TTestDaemon.Stop: Boolean;
begin
Result:=inherited Stop;
AWriteln('Daemon Stop: ',Result);
FreeAndNil(mORMotServer);
end;
function TTestDaemon.Pause: Boolean;
begin
Result:=inherited Pause;
AWriteln('Daemon pause: ',Result);
end;
function TTestDaemon.Continue: Boolean;
begin
Result:=inherited Continue;
AWriteln('Daemon continue: ',Result);
end;
function TTestDaemon.Execute: Boolean;
begin
Result:=inherited Execute;
AWriteln('Daemon execute: ',Result);
end;
function TTestDaemon.ShutDown: Boolean;
begin
Result:=inherited ShutDown;
AWriteln('Daemon Shutdown: ',Result);
FreeAndNil(mORMotServer);
AWriteln('Server Shutdown: ',Result);
end;
function TTestDaemon.Install: Boolean;
begin
Result:=inherited Install;
AWriteln('Daemon Install: ',Result);
end;
function TTestDaemon.UnInstall: boolean;
begin
Result:=inherited UnInstall;
AWriteln('Daemon UnInstall: ',Result);
end;
Type
{ TTestDaemonMapper }
TTestDaemonMapper = Class(TCustomDaemonMapper)
Constructor Create(AOwner : TComponent); override;
end;
{ TTestDaemonMapper }
constructor TTestDaemonMapper.Create(AOwner: TComponent);
Var
D : TDaemonDef;
begin
inherited Create(AOwner);
D:=DaemonDefs.Add as TDaemonDef;
D.DisplayName:='Test daemon';
D.Name:='TestDaemon';
D.DaemonClassName:='TTestDaemon';
//D.WinBindings.ServiceType:=stWin32;
end;
begin
RegisterDaemonClass(TTestDaemon);
RegisterDaemonMapper(TTestDaemonMapper);
Application.Run;
end.