/** * Enables or disables the native layer. * @param tokens tokenized command line tokens[0] is the command itself */ private void doNative(String[] tokens) { String what = tokens[1]; if (what.startsWith("e")) { SystemInfoFactory.enableNativeSystemInfo(); System.out.println("Native layer enabled."); } else if (what.startsWith("d")) { SystemInfoFactory.disableNativeSystemInfo(); System.out.println("Native layer disabled."); } else if (what.startsWith("s")) { System.out.println("Native layer is:"); System.out.println(SystemInfoFactory.isNativeSystemInfoDisabled() ? "Disabled" : "Enabled"); if (!SystemInfoFactory.isNativeSystemInfoDisabled()) { System.out.println(SystemInfoFactory.isNativeSystemInfoAvailable() ? "Available" : "Not Available"); System.out.println(SystemInfoFactory.isNativeSystemInfoInitialized() ? "Initialized" : "Not initialized"); } } else { System.err.println("Unknown option. Only 'e', 'd' and 's' are applicable (enable/disable/status)"); return; } }
public static boolean isSigarAvailable() { if (!SystemInfoFactory.isNativeSystemInfoDisabled() && SystemInfoFactory.isNativeSystemInfoAvailable()) { // its available, but it may not yet have been initialized. If it has not been initialized, // make a call that forces it to be initialized and loaded. 99% of the time, the native layer // will already be initialized and this check will be very fast. if (!SystemInfoFactory.isNativeSystemInfoInitialized()) { SystemInfoFactory.getNativeSystemInfoVersion(); } return true; } else { return false; } }
public static boolean isSigarAvailable() { if (!SystemInfoFactory.isNativeSystemInfoDisabled() && SystemInfoFactory.isNativeSystemInfoAvailable()) { // its available, but it may not yet have been initialized. If it has not been initialized, // make a call that forces it to be initialized and loaded. 99% of the time, the native layer // will already be initialized and this check will be very fast. if (!SystemInfoFactory.isNativeSystemInfoInitialized()) { SystemInfoFactory.getNativeSystemInfoVersion(); } return true; } else { return false; } }