altoslib: Allow launch site URL to be overridden at runtime
authorKeith Packard <keithp@keithp.com>
Sun, 7 Oct 2018 02:27:43 +0000 (19:27 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 7 Oct 2018 02:48:41 +0000 (19:48 -0700)
Expose a public variable, AltosLaunchSites.launch_sites_url, that will
be used in place of the environment variable or pre-defined value.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosLaunchSites.java

index b24cccbeb128b0d94d7988c874438d1d0839385b..2c04c90eeeb50a28d905a1b1233dbcc61e40a21a 100644 (file)
@@ -30,6 +30,8 @@ public class AltosLaunchSites extends Thread {
        LinkedList<AltosLaunchSite>     sites;
        AltosLaunchSiteListener         listener;
 
        LinkedList<AltosLaunchSite>     sites;
        AltosLaunchSiteListener         listener;
 
+       public static String            launch_sites_url;
+
        void notify_complete() {
                listener.notify_launch_sites(sites);
        }
        void notify_complete() {
                listener.notify_launch_sites(sites);
        }
@@ -50,9 +52,13 @@ public class AltosLaunchSites extends Thread {
                try {
                        String  path;
 
                try {
                        String  path;
 
-                       path = System.getenv(AltosLib.launch_sites_env);
-                       if (path == null)
-                               path = AltosLib.launch_sites_url;
+                       if (launch_sites_url != null)
+                               path = launch_sites_url;
+                       else {
+                               path = System.getenv(AltosLib.launch_sites_env);
+                               if (path == null)
+                                       path = AltosLib.launch_sites_url;
+                       }
                        url = new URL(path);
                        URLConnection uc = url.openConnection();
 
                        url = new URL(path);
                        URLConnection uc = url.openConnection();