source: josm/trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java@ 3707

Last change on this file since 3707 was 3707, checked in by bastiK, 13 years ago

Added remotecontrol plugin to josm core. This plugin was initially written by Frederik Ramm (frederik) and incorporates code taken from YWMS plugin by frsantos. Major contributions by Bodo Meissner (bomm) and stephankn. Note: The code has been added, but is not "active" yet (RemoteControl.on == false). This is because wmsplugin and imagery plugin has not been adapted to this change. They are about to be integrated as well, so this adaption is not necessary.

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io.remotecontrol;
3
4import org.openstreetmap.josm.data.preferences.BooleanProperty;
5import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
6
7/**
8 * Manager class for remote control operations.
9 *
10 * To allow API there is a @see getVersion() method.
11 *
12 * IMPORTANT! increment the minor version on compatible API extensions
13 * and increment the major version and set minor to 0 on incompatible changes.
14 */
15public class RemoteControl
16{
17 // deactivate the remote control code for now. FIXME: Remove this completely if it gets turned on.
18 static final public boolean on = false;
19
20 /**
21 * If the remote cotrol feature is enabled or disabled. If disabled,
22 * it should not start the server.
23 */
24 public static final BooleanProperty PROP_REMOTECONTROL_ENABLED = new BooleanProperty("remotecontrol.enabled", false);
25
26 /** API version
27 * IMPORTANT! update the version number on API changes.
28 */
29 static final int apiMajorVersion = 1;
30 static final int apiMinorVersion = 0;
31
32 /**
33 * RemoteControl HTTP protocol version. Change minor number for compatible
34 * interface extensions. Change major number in case of incompatible
35 * changes.
36 */
37 static final int protocolMajorVersion = 1;
38 static final int protocolMinorVersion = 2;
39
40 /**
41 * Returns an array of int values with major and minor API version
42 * and major and minor HTTP protocol version.
43 *
44 * The function returns an int[4] instead of an object with fields
45 * to avoid ClassNotFound errors with old versions of remotecontrol.
46 *
47 * @return array of integer version numbers:
48 * apiMajorVersion, apiMinorVersion, protocolMajorVersion, protocolMajorVersion
49 */
50 public int[] getVersion()
51 {
52 int versions[] = {apiMajorVersion, apiMinorVersion, protocolMajorVersion, protocolMajorVersion};
53 return versions;
54 }
55
56 /**
57 * Start the remote control server
58 */
59 public static void start() {
60 RemoteControlHttpServer.restartRemoteControlHttpServer();
61 }
62
63 /**
64 * Add external external request handler.
65 * Can be used by plugins that want to use remote control.
66 *
67 * @param handler The additional request handler.
68 */
69 public void addRequestHandler(String command, Class<? extends RequestHandler> handlerClass)
70 {
71 RequestProcessor.addRequestHandlerClass(command, handlerClass);
72 }
73}
Note: See TracBrowser for help on using the repository browser.