1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io.remotecontrol;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.data.preferences.BooleanProperty;
|
---|
5 | import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Manager class for remote control operations.
|
---|
9 | *
|
---|
10 | * IMPORTANT! increment the minor version on compatible API extensions
|
---|
11 | * and increment the major version and set minor to 0 on incompatible changes.
|
---|
12 | */
|
---|
13 | public class RemoteControl
|
---|
14 | {
|
---|
15 | /**
|
---|
16 | * If the remote control feature is enabled or disabled. If disabled,
|
---|
17 | * it should not start the server.
|
---|
18 | */
|
---|
19 | public static final BooleanProperty PROP_REMOTECONTROL_ENABLED = new BooleanProperty("remotecontrol.enabled", false);
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * RemoteControl HTTP protocol version. Change minor number for compatible
|
---|
23 | * interface extensions. Change major number in case of incompatible
|
---|
24 | * changes.
|
---|
25 | */
|
---|
26 | static final int protocolMajorVersion = 1;
|
---|
27 | static final int protocolMinorVersion = 5;
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Starts the remote control server
|
---|
31 | */
|
---|
32 | public static void start() {
|
---|
33 | RemoteControlHttpServer.restartRemoteControlHttpServer();
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Stops the remote control server
|
---|
38 | * @since 5861
|
---|
39 | */
|
---|
40 | public static void stop() {
|
---|
41 | RemoteControlHttpServer.stopRemoteControlHttpServer();
|
---|
42 | }
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Adds external request handler.
|
---|
46 | * Can be used by plugins that want to use remote control.
|
---|
47 | *
|
---|
48 | * @param command The command name.
|
---|
49 | * @param handlerClass The additional request handler.
|
---|
50 | */
|
---|
51 | public void addRequestHandler(String command, Class<? extends RequestHandler> handlerClass) {
|
---|
52 | RequestProcessor.addRequestHandlerClass(command, handlerClass);
|
---|
53 | }
|
---|
54 | }
|
---|