| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 import dartino.*; | |
| 6 | |
| 7 import java.io.FileInputStream; | |
| 8 import java.io.FileNotFoundException; | |
| 9 import java.io.IOException; | |
| 10 | |
| 11 class SimpleTodo { | |
| 12 | |
| 13 public static void main(String args[]) { | |
| 14 // Expecting a snapshot of the dart service code on the command line. | |
| 15 if (args.length != 1) { | |
| 16 System.out.println("Usage: java SimpleTodo <snapshot>"); | |
| 17 System.exit(1); | |
| 18 } | |
| 19 | |
| 20 // Load libdartino.so. | |
| 21 System.loadLibrary("dartino"); | |
| 22 | |
| 23 // Setup Dartino. | |
| 24 DartinoApi.Setup(); | |
| 25 DartinoServiceApi.Setup(); | |
| 26 DartinoApi.AddDefaultSharedLibrary("libdartino.so"); | |
| 27 | |
| 28 try { | |
| 29 // Load snapshot and start dart code on a separate thread. | |
| 30 FileInputStream snapshotStream = new FileInputStream(args[0]); | |
| 31 int available = snapshotStream.available(); | |
| 32 byte[] snapshot = new byte[available]; | |
| 33 snapshotStream.read(snapshot); | |
| 34 Thread dartThread = new Thread(new SnapshotRunner(snapshot)); | |
| 35 dartThread.start(); | |
| 36 } catch (FileNotFoundException e) { | |
| 37 System.err.println("Failed loading snapshot: file not found."); | |
| 38 System.exit(1); | |
| 39 } catch (IOException e) { | |
| 40 System.err.println("Failed loading snapshot: unknown error."); | |
| 41 System.exit(1); | |
| 42 } | |
| 43 | |
| 44 TodoController.InteractWithService(); | |
| 45 } | |
| 46 } | |
| OLD | NEW |