commit | author | age
|
929228
|
1 |
/* |
U |
2 |
Calypso - Media Player Remote Control via HTTP for Raspberry Pi |
|
3 |
Copyright (C) 2021-2023 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
e27ab1
|
19 |
package de.uhilger.calypso.actor; |
929228
|
20 |
|
U |
21 |
import com.sun.net.httpserver.HttpContext; |
|
22 |
import java.util.Timer; |
|
23 |
import java.util.TimerTask; |
|
24 |
import java.util.logging.Logger; |
|
25 |
|
|
26 |
/** |
|
27 |
* Ein HTTP-Handler zum Stoppen der Anwendung |
|
28 |
* |
|
29 |
* @author Ulrich Hilger |
|
30 |
*/ |
|
31 |
public class StopServerActor { |
|
32 |
|
|
33 |
public void run(HttpContext thisContext) { |
|
34 |
Logger.getLogger(StopServerActor.class.getName()).info("Server wird gestoppt.."); |
|
35 |
thisContext.getServer().stop(1); // diesen Server stoppen |
|
36 |
Timer timer = new Timer(); |
|
37 |
timer.schedule(new AppStopper(), 1500); // die App auch beenden |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* Die Klasse AppStopper ermöglicht das asnychrone bzw. |
|
42 |
* zeitgesteuerte Stoppen der Anwendung. |
|
43 |
*/ |
|
44 |
class AppStopper extends TimerTask { |
|
45 |
|
|
46 |
@Override |
|
47 |
public void run() { |
|
48 |
Logger.getLogger(StopServerActor.class.getName()).info("Calypso beendet."); |
|
49 |
System.exit(0); |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
} |