rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java
1.1 --- a/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Fri Mar 01 14:10:57 2013 +0100
1.2 +++ b/rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Wed Mar 13 16:20:03 2013 +0100
1.3 @@ -56,7 +56,7 @@
1.4 * Supports execution in native browser as well as Java's internal
1.5 * execution engine.
1.6 */
1.7 -final class Bck2BrwsrLauncher extends Launcher implements Closeable {
1.8 +class Bck2BrwsrLauncher extends Launcher implements Closeable {
1.9 private static final Logger LOG = Logger.getLogger(Bck2BrwsrLauncher.class.getName());
1.10 private static final InvocationContext END = new InvocationContext(null, null, null);
1.11 private final Set<ClassLoader> loaders = new LinkedHashSet<>();
1.12 @@ -333,31 +333,7 @@
1.13 int port = listener.getPort();
1.14
1.15 URI uri = new URI("http://localhost:" + port + page);
1.16 - LOG.log(Level.INFO, "Showing {0}", uri);
1.17 - if (cmd == null) {
1.18 - try {
1.19 - LOG.log(Level.INFO, "Trying Desktop.browse on {0} {2} by {1}", new Object[] {
1.20 - System.getProperty("java.vm.name"),
1.21 - System.getProperty("java.vm.vendor"),
1.22 - System.getProperty("java.vm.version"),
1.23 - });
1.24 - java.awt.Desktop.getDesktop().browse(uri);
1.25 - LOG.log(Level.INFO, "Desktop.browse successfully finished");
1.26 - return null;
1.27 - } catch (UnsupportedOperationException ex) {
1.28 - LOG.log(Level.INFO, "Desktop.browse not supported: {0}", ex.getMessage());
1.29 - LOG.log(Level.FINE, null, ex);
1.30 - }
1.31 - }
1.32 - {
1.33 - String cmdName = cmd == null ? "xdg-open" : cmd;
1.34 - String[] cmdArr = {
1.35 - cmdName, uri.toString()
1.36 - };
1.37 - LOG.log(Level.INFO, "Launching {0}", Arrays.toString(cmdArr));
1.38 - final Process process = Runtime.getRuntime().exec(cmdArr);
1.39 - return new Object[] { process, null };
1.40 - }
1.41 + return showBrwsr(uri);
1.42 }
1.43 private static String toUTF8(String value) throws UnsupportedEncodingException {
1.44 byte[] arr = new byte[value.length()];
1.45 @@ -432,6 +408,34 @@
1.46 shutdown();
1.47 }
1.48
1.49 + protected Object[] showBrwsr(URI uri) throws IOException {
1.50 + LOG.log(Level.INFO, "Showing {0}", uri);
1.51 + if (cmd == null) {
1.52 + try {
1.53 + LOG.log(Level.INFO, "Trying Desktop.browse on {0} {2} by {1}", new Object[] {
1.54 + System.getProperty("java.vm.name"),
1.55 + System.getProperty("java.vm.vendor"),
1.56 + System.getProperty("java.vm.version"),
1.57 + });
1.58 + java.awt.Desktop.getDesktop().browse(uri);
1.59 + LOG.log(Level.INFO, "Desktop.browse successfully finished");
1.60 + return null;
1.61 + } catch (UnsupportedOperationException ex) {
1.62 + LOG.log(Level.INFO, "Desktop.browse not supported: {0}", ex.getMessage());
1.63 + LOG.log(Level.FINE, null, ex);
1.64 + }
1.65 + }
1.66 + {
1.67 + String cmdName = cmd == null ? "xdg-open" : cmd;
1.68 + String[] cmdArr = {
1.69 + cmdName, uri.toString()
1.70 + };
1.71 + LOG.log(Level.INFO, "Launching {0}", Arrays.toString(cmdArr));
1.72 + final Process process = Runtime.getRuntime().exec(cmdArr);
1.73 + return new Object[] { process, null };
1.74 + }
1.75 + }
1.76 +
1.77 private class Res implements Bck2Brwsr.Resources {
1.78 @Override
1.79 public InputStream get(String resource) throws IOException {