Changeset 29231 in vbox for trunk/src/libs/xpcom18a4/java
- Timestamp:
- May 7, 2010 7:42:03 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 61312
- Location:
- trunk/src/libs/xpcom18a4/java
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/java/Makefile.kmk
r29216 r29231 256 256 $(VBOX_JXPCOM_JSRC)/internal/XPCOMJavaProxyBase.java \ 257 257 $(VBOX_JXPCOM_JSRC)/internal/XPCOMJavaProxy.java 258 VBOX_JXPCOM_MGR = $(VBOX_JXPCOM_SRC)/src/org/virtualbox/VirtualBoxManager.java 258 VBOX_JXPCOM_MGR = \ 259 $(VBOX_JXPCOM_SRC)/src/org/virtualbox/VirtualBoxManager.java \ 260 $(VBOX_JXPCOM_SRC)/src/org/virtualbox/VBoxObjectBase.java 259 261 260 262 $$(VBOX_JXPCOM_JAR): $(VBOX_JXPCOM_JAR_SRC) $(VBOX_JXPCOM_GEN)/jxpcomgen.list $(VBOX_JXPCOM_NSERROR) $(VBOX_JXPCOM_MGR) | $$(dir $$@) -
trunk/src/libs/xpcom18a4/java/tests/TestVBox.java
r29212 r29231 15 15 import org.virtualbox.*; 16 16 17 class VBoxCallbacks extends VBoxObjectBase implements IVirtualBoxCallback 18 { 19 public void onGuestPropertyChange(String machineId, String name, String value, String flags) 20 { 21 System.out.println("onGuestPropertyChange -- VM: " + machineId + ", " + name + "->" + value); 22 } 23 public void onSnapshotChange(String machineId, String snapshotId) 24 { 25 } 26 public void onSnapshotDeleted(String machineId, String snapshotId) 27 { 28 } 29 public void onSnapshotTaken(String machineId, String snapshotId) {} 30 public void onSessionStateChange(String machineId, long state) 31 { 32 System.out.println("onSessionStateChange -- VM: " + machineId + ", state: " + state); 33 } 34 public void onMachineRegistered(String machineId, boolean registered) {} 35 public void onMediumRegistered(String mediumId, long mediumType, boolean registered) {} 36 public void onExtraDataChange(String machineId, String key, String value) 37 { 38 System.out.println("onExtraDataChange -- VM: " + machineId + ": " + key+"->"+value); 39 } 40 public boolean onExtraDataCanChange(String machineId, String key, String value, String[] error) { return true; } 41 public void onMachineDataChange(String machineId) 42 {} 43 public void onMachineStateChange(String machineId, long state) 44 { 45 System.out.println("onMachineStateChange -- VM: " + machineId + ", state: " + state); 46 } 47 } 48 17 49 public class TestVBox 18 50 { 51 static void testCallbacks(VirtualBoxManager mgr, IVirtualBox vbox) 52 { 53 IVirtualBoxCallback cbs = new VBoxCallbacks(); 54 vbox.registerCallback(cbs); 55 for (int i=0; i<100; i++) 56 { 57 mgr.waitForEvents(500); 58 } 59 vbox.unregisterCallback(cbs); 60 } 19 61 20 public static class VBoxCallbacks implements IVirtualBoxCallback62 static void testEnumeration(VirtualBoxManager mgr, IVirtualBox vbox) 21 63 { 22 public void onGuestPropertyChange(String machineId, String name, String value, String flags) {} 23 public void onSnapshotChange(String machineId, String snapshotId) {} 24 public void onSnapshotDeleted(String machineId, String snapshotId) {} 25 public void onSnapshotTaken(String machineId, String snapshotId) {} 26 /** @todo is there a type SessionState instead of long? */ 27 public void onSessionStateChange(String machineId, long state) {} 28 public void onMachineRegistered(String machineId, boolean registered) {} 29 /** @todo long -> MediumType */ 30 public void onMediumRegistered(String mediumId, long mediumType, boolean registered) {} 31 public void onExtraDataChange(String machineId, String key, String value) {} 32 public boolean onExtraDataCanChange(String machineId, String key, String value, String[] error) { return true; } 33 public void onMachineDataChange(String machineId) {} 34 /** @todo long -> MachineState */ 35 public void onMachineStateChange(String machineId, long state) { System.out.println("onMachineStateChange -- VM: " + machineId + ", state: " + state); }; 64 IMachine[] machs = vbox.getMachines(null); 65 for (IMachine m : machs) 66 { 67 System.out.println("VM name: " + m.getName() + ", RAM size: " + m.getMemorySize() + "MB"); 68 System.out.println(" HWVirt: " + m.getHWVirtExProperty(HWVirtExPropertyType.Enabled) 69 + ", Nested Paging: " + m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging) 70 + ", PAE: " + m.getCPUProperty(CPUPropertyType.PAE) ); 71 } 72 } 36 73 37 /** @todo ugly reimplementation of queryInterface, should have base class to derive from */ 38 public nsISupports queryInterface(String iid) { return org.mozilla.xpcom.Mozilla.queryInterface(this, iid); } 39 }; 40 74 static void testStart(VirtualBoxManager mgr, IVirtualBox vbox) 75 { 76 String m = vbox.getMachines(null)[0].getName(); 77 System.out.println("\nAttempting to start VM '" + m + "'"); 78 mgr.startVm(m, null, 7000); 79 } 41 80 42 81 public static void main(String[] args) … … 50 89 IVirtualBox vbox = mgr.getVBox(); 51 90 System.out.println("VirtualBox version: " + vbox.getVersion() + "\n"); 91 testEnumeration(mgr, vbox); 92 testCallbacks(mgr, vbox); 52 93 53 /* list all VMs and print some info for each */ 54 IMachine[] machs = vbox.getMachines(null); 55 for (IMachine m : machs) 56 { 57 try 58 { 59 System.out.println("VM name: " + m.getName() + ", RAM size: " + m.getMemorySize() + "MB"); 60 System.out.println(" HWVirt: " + m.getHWVirtExProperty(HWVirtExPropertyType.Enabled) 61 + ", Nested Paging: " + m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging) 62 + ", PAE: " + m.getCPUProperty(CPUPropertyType.PAE) ); 63 } 64 catch (Throwable e) 65 { 66 e.printStackTrace(); 67 } 68 } 69 70 boolean withCallbacks = false; 71 VBoxCallbacks vboxCallbacks = null; 72 73 if (withCallbacks) 74 { 75 vboxCallbacks = new VBoxCallbacks(); 76 vbox.registerCallback(mgr.makeVirtualBoxCallback(vboxCallbacks)); 77 } 78 79 /* do something silly, start the first VM in the list */ 80 String m = machs[0].getName(); 81 System.out.println("\nAttempting to start VM '" + m + "'"); 82 if (false || mgr.startVm(m, 7000)) 83 { 84 if (!withCallbacks) 85 { 86 System.out.println("started, presss any key..."); 87 int ch = System.in.read(); 88 } else { 89 while (true) 90 { 91 mgr.waitForEvents(500); 92 } 93 } 94 } 95 else 96 { 97 System.out.println("cannot start machine "+m); 98 } 99 100 if (withCallbacks) 101 vbox.unregisterCallback(vboxCallbacks); 94 System.out.println("done, press Enter..."); 95 int ch = System.in.read(); 102 96 } 103 97 catch (Throwable e)
Note:
See TracChangeset
for help on using the changeset viewer.