Changeset 14140 in josm for trunk/src/org/openstreetmap/josm/spi/lifecycle
- Timestamp:
- 2018-08-12T13:08:27+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/spi/lifecycle/Lifecycle.java
r14139 r14140 9 9 import java.util.concurrent.Future; 10 10 11 import org.openstreetmap.josm.tools.JosmRuntimeException; 11 12 import org.openstreetmap.josm.tools.Logging; 12 13 import org.openstreetmap.josm.tools.Utils; … … 20 21 21 22 private static volatile InitStatusListener initStatusListener; 23 24 private static volatile Runnable shutdownSequence; 22 25 23 26 private Lifecycle() { … … 39 42 public static void setInitStatusListener(InitStatusListener listener) { 40 43 initStatusListener = Objects.requireNonNull(listener); 44 } 45 46 /** 47 * Gets shutdown sequence. 48 * @return shutdown sequence 49 * @since 14140 50 */ 51 public static Runnable getShutdownSequence() { 52 return shutdownSequence; 53 } 54 55 /** 56 * Sets shutdown sequence. 57 * @param sequence shutdown sequence. Must not be null 58 * @since 14140 59 */ 60 public static void setShutdownSequence(Runnable sequence) { 61 shutdownSequence = Objects.requireNonNull(sequence); 41 62 } 42 63 … … 66 87 } 67 88 } catch (InterruptedException | ExecutionException ex) { 68 throw new RuntimeException(ex); 89 throw new JosmRuntimeException(ex); 69 90 } 70 91 … … 77 98 try { 78 99 task.call(); 79 } catch (RuntimeException e) { 100 } catch (JosmRuntimeException e) { 80 101 // Can happen if the current projection needs NTV2 grid which is not available 81 102 // In this case we want the user be able to change his projection … … 84 105 } 85 106 } 107 108 /** 109 * Closes JOSM and optionally terminates the Java Virtual Machine (JVM). 110 * @param exit If {@code true}, the JVM is terminated by running {@link System#exit} with a given return code. 111 * @param exitCode The return code 112 * @return {@code true} 113 * @since 14140 114 */ 115 public static boolean exitJosm(boolean exit, int exitCode) { 116 if (shutdownSequence != null) { 117 shutdownSequence.run(); 118 } 119 120 if (exit) { 121 System.exit(exitCode); 122 } 123 return true; 124 } 86 125 }
Note:
See TracChangeset
for help on using the changeset viewer.