From 0f290a28864fef56b62544472d54226e54318472 Mon Sep 17 00:00:00 2001 From: Tyler Cook Date: Fri, 2 Aug 2019 12:22:00 -0500 Subject: [PATCH 1/4] Initial commit --- reference/definitions-full.json | 925 ++++++++++++++++++ reference/definitions.json | 396 ++++++++ .../gen/main/java/oshi/api/FreeBsdSystem.java | 15 + .../gen/main/java/oshi/api/LinuxSystem.java | 15 + .../gen/main/java/oshi/api/MacSystem.java | 15 + .../gen/main/java/oshi/api/MultiSystem.java | 15 + .../gen/main/java/oshi/api/SolarisSystem.java | 15 + .../gen/main/java/oshi/api/WindowsSystem.java | 15 + .../java/oshi/api/hardware/disk/Disk.java | 118 +++ .../oshi/api/hardware/disk/DiskContainer.java | 478 +++++++++ .../hardware/disk/DiskContainerFreeBsd.java | 17 + .../api/hardware/disk/DiskContainerLinux.java | 17 + .../api/hardware/disk/DiskContainerMac.java | 17 + .../hardware/disk/DiskContainerSolaris.java | 17 + .../hardware/disk/DiskContainerWindows.java | 17 + .../oshi/api/hardware/disk/DiskFreeBsd.java | 5 + .../oshi/api/hardware/disk/DiskLinux.java | 5 + .../java/oshi/api/hardware/disk/DiskMac.java | 5 + .../oshi/api/hardware/disk/DiskSolaris.java | 5 + .../oshi/api/hardware/disk/DiskWindows.java | 5 + .../hardware/disk/internal/DiskAttribute.java | 64 ++ .../api/hardware/disk/internal/DiskQuery.java | 13 + .../oshi/api/hardware/firmware/Firmware.java | 16 + .../hardware/firmware/FirmwareContainer.java | 81 ++ .../firmware/FirmwareContainerFreeBsd.java | 17 + .../firmware/FirmwareContainerLinux.java | 30 + .../firmware/FirmwareContainerMac.java | 17 + .../firmware/FirmwareContainerSolaris.java | 17 + .../firmware/FirmwareContainerWindows.java | 17 + .../hardware/firmware/FirmwareFreeBsd.java | 5 + .../api/hardware/firmware/FirmwareLinux.java | 6 + .../api/hardware/firmware/FirmwareMac.java | 5 + .../hardware/firmware/FirmwareSolaris.java | 5 + .../hardware/firmware/FirmwareWindows.java | 5 + .../firmware/internal/FirmwareAttribute.java | 18 + .../firmware/internal/FirmwareQuery.java | 13 + .../main/java/oshi/api/hardware/nic/Nic.java | 96 ++ .../oshi/api/hardware/nic/NicContainer.java | 435 ++++++++ .../api/hardware/nic/NicContainerFreeBsd.java | 17 + .../api/hardware/nic/NicContainerLinux.java | 17 + .../api/hardware/nic/NicContainerMac.java | 17 + .../api/hardware/nic/NicContainerSolaris.java | 17 + .../api/hardware/nic/NicContainerWindows.java | 96 ++ .../oshi/api/hardware/nic/NicFreeBsd.java | 5 + .../java/oshi/api/hardware/nic/NicLinux.java | 5 + .../java/oshi/api/hardware/nic/NicMac.java | 5 + .../oshi/api/hardware/nic/NicSolaris.java | 5 + .../oshi/api/hardware/nic/NicWindows.java | 20 + .../hardware/nic/internal/NicAttribute.java | 60 ++ .../api/hardware/nic/internal/NicQuery.java | 13 + .../src/main/java/oshi/ApiGenerator.java | 320 ++++++ .../oshi/api/DetachedContainerException.java | 14 + .../oshi/api/NoSuchQueryMethodException.java | 5 + reference/src/main/java/oshi/api/OSHI.java | 78 ++ .../src/main/java/oshi/api/PlatformEnum.java | 51 + .../java/oshi/driver/ComponentDriver.java | 169 ++++ .../java/oshi/driver/ExtensionDriver.java | 12 + .../src/main/java/oshi/driver/Fallback.java | 13 + .../main/java/oshi/driver/RequiresRoot.java | 12 + .../main/java/oshi/driver/SystemDriver.java | 65 ++ .../java/oshi/driver/SystemDriverFreeBsd.java | 30 + .../java/oshi/driver/SystemDriverLinux.java | 93 ++ .../java/oshi/driver/SystemDriverMac.java | 30 + .../java/oshi/driver/SystemDriverSolaris.java | 30 + .../java/oshi/driver/SystemDriverWindows.java | 30 + .../driver/hardware/disk/DiskDriverLinux.java | 81 ++ .../hardware/disk/DiskDriverLinuxSMART.java | 45 + .../firmware/FirmwareDriverLinux.java | 78 ++ .../driver/hardware/nic/NicDriverJava.java | 61 ++ .../driver/hardware/nic/NicDriverLinux.java | 150 +++ .../main/java/oshi/example/DiskExample.java | 17 + .../java/oshi/example/FirmwareExample.java | 21 + .../main/java/oshi/example/NicExample.java | 22 + .../main/java/oshi/old/ExecutingCommand.java | 136 +++ .../src/main/java/oshi/old/FileUtil.java | 202 ++++ .../src/main/java/oshi/old/ParseUtil.java | 766 +++++++++++++++ reference/src/main/java/oshi/old/Udev.java | 120 +++ reference/src/main/java/oshi/old/WmiUtil.java | 296 ++++++ 78 files changed, 6201 insertions(+) create mode 100644 reference/definitions-full.json create mode 100644 reference/definitions.json create mode 100644 reference/gen/main/java/oshi/api/FreeBsdSystem.java create mode 100644 reference/gen/main/java/oshi/api/LinuxSystem.java create mode 100644 reference/gen/main/java/oshi/api/MacSystem.java create mode 100644 reference/gen/main/java/oshi/api/MultiSystem.java create mode 100644 reference/gen/main/java/oshi/api/SolarisSystem.java create mode 100644 reference/gen/main/java/oshi/api/WindowsSystem.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/Disk.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java create mode 100644 reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java create mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/Nic.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicMac.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java create mode 100644 reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java create mode 100644 reference/src/main/java/oshi/ApiGenerator.java create mode 100644 reference/src/main/java/oshi/api/DetachedContainerException.java create mode 100644 reference/src/main/java/oshi/api/NoSuchQueryMethodException.java create mode 100644 reference/src/main/java/oshi/api/OSHI.java create mode 100644 reference/src/main/java/oshi/api/PlatformEnum.java create mode 100644 reference/src/main/java/oshi/driver/ComponentDriver.java create mode 100644 reference/src/main/java/oshi/driver/ExtensionDriver.java create mode 100644 reference/src/main/java/oshi/driver/Fallback.java create mode 100644 reference/src/main/java/oshi/driver/RequiresRoot.java create mode 100644 reference/src/main/java/oshi/driver/SystemDriver.java create mode 100644 reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java create mode 100644 reference/src/main/java/oshi/driver/SystemDriverLinux.java create mode 100644 reference/src/main/java/oshi/driver/SystemDriverMac.java create mode 100644 reference/src/main/java/oshi/driver/SystemDriverSolaris.java create mode 100644 reference/src/main/java/oshi/driver/SystemDriverWindows.java create mode 100644 reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java create mode 100644 reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java create mode 100644 reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java create mode 100644 reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java create mode 100644 reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java create mode 100644 reference/src/main/java/oshi/example/DiskExample.java create mode 100644 reference/src/main/java/oshi/example/FirmwareExample.java create mode 100644 reference/src/main/java/oshi/example/NicExample.java create mode 100644 reference/src/main/java/oshi/old/ExecutingCommand.java create mode 100644 reference/src/main/java/oshi/old/FileUtil.java create mode 100644 reference/src/main/java/oshi/old/ParseUtil.java create mode 100644 reference/src/main/java/oshi/old/Udev.java create mode 100644 reference/src/main/java/oshi/old/WmiUtil.java diff --git a/reference/definitions-full.json b/reference/definitions-full.json new file mode 100644 index 0000000..22ad436 --- /dev/null +++ b/reference/definitions-full.json @@ -0,0 +1,925 @@ +[ + { + "name": "hardware.Nic", + "root": true, + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": "The interface's name" + }, + { + "name": "description", + "type": "String", + "constant": true, + "desc": "The interface's description" + }, + { + "name": "mtu", + "type": "Integer", + "desc": "The maximum transmission unit" + }, + { + "name": "mac", + "type": "String", + "desc": null + }, + { + "name": "virtual", + "type": "Boolean", + "desc": null + }, + { + "name": "ipv4", + "type": "String[]", + "desc": "The interface's IPv4 addresses" + }, + { + "name": "ipv6", + "type": "String[]", + "desc": "The interface's IPv6 addresses" + }, + { + "name": "broadcast", + "type": "String", + "desc": null + }, + { + "name": "netmask", + "type": "String", + "desc": "The interface's subnet mask" + }, + { + "name": "read_bytes", + "type": "Long", + "desc": "The number of bytes read from the interface" + }, + { + "name": "write_bytes", + "type": "Long", + "desc": "The number of bytes written to the interface" + }, + { + "name": "read_packets", + "type": "Long", + "desc": "The number of packets read from the interface" + }, + { + "name": "write_packets", + "type": "Long", + "desc": "The number of packets written to the interface" + }, + { + "name": "read_errors", + "type": "Long", + "desc": "The number of read errors" + }, + { + "name": "write_errors", + "type": "Long", + "desc": "The number of write errors" + }, + { + "name": "read_drops", + "type": "Long", + "desc": "The number of read drops" + }, + { + "name": "write_drops", + "type": "Long", + "desc": "The number of write drops" + }, + { + "name": "write_collisions", + "type": "Long", + "desc": "The number of write collisions" + }, + { + "name": "link_speed", + "type": "Long", + "desc": "The interface's maximum speed in bytes" + }, + { + "name": "default_gateway", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_up", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_running", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_loopback", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_multicast", + "type": "Boolean", + "desc": null + }, + { + "name": "luid", + "type": "Long", + "desc": "The interface's locally unique identifier", + "compatible": [ + "windows" + ] + }, + { + "name": "guid", + "type": "String", + "desc": "The interface's globally unique identifier", + "compatible": [ + "windows" + ] + }, + { + "name": "paused", + "type": "Boolean", + "desc": "Whether the interface is in a paused state", + "compatible": [ + "windows" + ] + }, + { + "name": "lowPower", + "type": "Boolean", + "desc": "Whether the interface is in a low-power state", + "compatible": [ + "windows" + ] + } + ] + }, + { + "name": "hardware.Disk", + "root": true, + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "model", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "serial", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "size", + "type": "Long", + "desc": "The disk's total size in bytes" + }, + { + "name": "reads", + "type": "Long", + "desc": null + }, + { + "name": "read_bytes", + "type": "Long", + "desc": null + }, + { + "name": "writes", + "type": "Long", + "desc": null + }, + { + "name": "write_bytes", + "type": "Long", + "desc": null + }, + { + "name": "queue_length", + "type": "Long", + "desc": null + }, + { + "name": "transfer_time", + "type": "Long", + "desc": null + }, + { + "name": "model_family", + "type": "String", + "desc": null + }, + { + "name": "firmware_version", + "type": "String", + "desc": null + }, + { + "name": "rotation_rate", + "type": "Long", + "desc": null + }, + { + "name": "read_error_rate", + "type": "Long", + "desc": null + }, + { + "name": "spin_up_time", + "type": "Long", + "desc": null + }, + { + "name": "start_stop_cycles", + "type": "Long", + "desc": null + }, + { + "name": "reallocated_sectors", + "type": "Long", + "desc": null + }, + { + "name": "seek_error_rate", + "type": "Long", + "desc": null + }, + { + "name": "power_on_time", + "type": "Long", + "desc": null + }, + { + "name": "spin_retries", + "type": "Long", + "desc": null + }, + { + "name": "calibration_retries", + "type": "Long", + "desc": null + }, + { + "name": "power_cycles", + "type": "Long", + "desc": null + }, + { + "name": "poweroff_retracts", + "type": "Long", + "desc": null + }, + { + "name": "load_cycles", + "type": "Long", + "desc": null + }, + { + "name": "temperature", + "type": "Long", + "desc": null + }, + { + "name": "reallocated_events", + "type": "Long", + "desc": null + }, + { + "name": "current_pending_sector", + "type": "Long", + "desc": null + }, + { + "name": "offline_uncorrectable", + "type": "Long", + "desc": null + }, + { + "name": "crc_errors", + "type": "Long", + "desc": null + }, + { + "name": "multizone_error_rate", + "type": "Long", + "desc": null + } + ] + }, + { + "name": "hardware.Partition", + "attributes": [ + { + "name": "identification", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "desc", + "type": "String", + "desc": null + }, + { + "name": "uuid", + "type": "String", + "desc": "The partition's UUID" + }, + { + "name": "size", + "type": "Long", + "desc": "The partition's total size in bytes" + }, + { + "name": "major", + "type": "Integer", + "desc": null + }, + { + "name": "minor", + "type": "Integer", + "desc": null + }, + { + "name": "mount", + "type": "String", + "desc": "The partition's mount point" + } + ] + }, + { + "name": "hardware.Cpu", + "root": true, + "attributes": [ + { + "name": "model", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "vendor", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "frequency_spec", + "type": "Integer", + "desc": "The specified frequency in Hertz" + }, + { + "name": "l1_cache", + "type": "Integer", + "desc": "The size of the L1 cache in bytes" + }, + { + "name": "l2_cache", + "type": "Integer", + "desc": "The size of the L2 cache in bytes" + }, + { + "name": "l3_cache", + "type": "Integer", + "desc": "The size of the L3 cache in bytes" + }, + { + "name": "l4_cache", + "type": "Integer", + "desc": "The size of the L4 cache in bytes" + } + ] + }, + { + "name": "hardware.CpuCore", + "attributes": [ + { + "name": "usage", + "type": "Double", + "desc": "The core's usage between 0.0 and 1.0" + }, + { + "name": "temperature", + "type": "Double", + "desc": "The core's temperature in Celsius" + } + ] + }, + { + "name": "hardware.CpuThread", + "attributes": [ + { + "name": "id", + "type": "Integer", + "constant": true, + "desc": "The thread's ID" + } + ] + }, + { + "name": "hardware.Gpu", + "root": true, + "attributes": [ + { + "name": "model", + "type": "String", + "constant": true, + "desc": "The GPU's model string" + }, + { + "name": "vendor", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "memory_size", + "type": "Long", + "desc": null + } + ] + }, + { + "name": "hardware.Memory", + "root": true, + "singular": true, + "attributes": [ + { + "name": "total", + "type": "Long", + "desc": null + }, + { + "name": "free", + "type": "Long" + }, + { + "name": "page_size", + "type": "Long" + }, + { + "name": "swap_size", + "type": "Long" + }, + { + "name": "swap_used", + "type": "Long" + }, + { + "name": "pages_in", + "type": "Long", + "desc": "The number of pages read from swap" + }, + { + "name": "pages_out", + "type": "Long", + "desc": "The number of pages in swap" + } + ] + }, + { + "name": "hardware.Power", + "root": true, + "attributes": [ + { + "name": "name", + "type": "String", + "desc": null + }, + { + "name": "remaining_capacity", + "type": "Double", + "desc": null + }, + { + "name": "remaining_time", + "type": "Double", + "desc": null + } + ] + }, + { + "name": "hardware.Firmware", + "root": true, + "singular": true, + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "manufacturer", + "type": "String", + "constant": true, + "desc": "The BIOS manufacturer title" + }, + { + "name": "description", + "type": "String", + "constant": true, + "desc": "The BIOS description" + }, + { + "name": "version", + "type": "String", + "constant": true, + "desc": "The BIOS version number" + }, + { + "name": "revision", + "type": "String", + "constant": true, + "desc": "The BIOS revision number" + }, + { + "name": "release_date", + "type": "String", + "constant": true, + "desc": "The BIOS release date" + }, + { + "name": "uefi", + "type": "Boolean", + "constant": true, + "desc": "Whether the BIOS supports UEFI mode", + "compatible": [ + "linux" + ] + } + ] + }, + { + "name": "hardware.Mainboard", + "root": true, + "singular": true, + "attributes": [ + { + "name": "model", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "manufacturer", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "version", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "serial_number", + "type": "String", + "constant": true, + "desc": null + } + ] + }, + { + "name": "hardware.Sensor", + "root": true, + "attributes": [ + { + "name": "fan_speed", + "type": "Integer", + "desc": null + }, + { + "name": "temperature", + "type": "Double", + "desc": null + }, + { + "name": "voltage", + "type": "Double", + "desc": null + } + ] + }, + { + "name": "hardware.SoundCard", + "root": true, + "attributes": [ + { + "name": "driver_version", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "codec", + "type": "String", + "desc": null + } + ] + }, + { + "name": "hardware.Display", + "root": true, + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": "The display's name" + }, + { + "name": "edid", + "type": "String", + "desc": null + }, + { + "name": "resolution", + "type": "String", + "desc": "The display's resolution" + }, + { + "name": "size", + "type": "String", + "constant": true, + "desc": "The display's physical size in pixels" + }, + { + "name": "refresh_frequency", + "type": "Integer", + "desc": "Refresh frequency in Hertz" + }, + { + "name": "bit_depth", + "type": "Integer", + "desc": null + } + ] + }, + { + "name": "hardware.UsbDevice", + "root": true, + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "vendor", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "vendor_id", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "product_id", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "serial_number", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "children", + "type": "UsbDevice[]", + "desc": null + } + ] + }, + { + "name": "software.User", + "root": true, + "attributes": [ + { + "name": "id", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "username", + "type": "String", + "desc": "The user's username" + }, + { + "name": "home", + "type": "String", + "desc": "The user's home directory path" + } + ] + }, + { + "name": "software.Process", + "root": true, + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "path", + "type": "String", + "desc": null + }, + { + "name": "command", + "type": "String", + "desc": null + }, + { + "name": "working_directory", + "type": "String", + "desc": null + }, + { + "name": "user", + "type": "String", + "desc": null + }, + { + "name": "user_id", + "type": "String", + "desc": null + }, + { + "name": "group", + "type": "String", + "desc": null + }, + { + "name": "group_id", + "type": "String", + "desc": null + }, + { + "name": "state", + "type": "String", + "desc": null + }, + { + "name": "pid", + "type": "Integer", + "constant": true, + "desc": "The process's process ID" + }, + { + "name": "parent_pid", + "type": "Integer", + "desc": null + }, + { + "name": "thread_count", + "type": "Integer", + "desc": null + }, + { + "name": "priority", + "type": "Integer", + "desc": null + }, + { + "name": "virtual_size", + "type": "Long", + "desc": null + }, + { + "name": "resident_set_size", + "type": "Long", + "desc": "The resident memory size in bytes" + }, + { + "name": "kernel_time", + "type": "Long", + "desc": "The number of milliseconds the process has executed in kernel mode" + }, + { + "name": "user_time", + "type": "Long", + "desc": "The number of milliseconds the process has executed in user mode" + }, + { + "name": "start_time", + "type": "Long", + "desc": "The epoch timestamp of the process start time" + }, + { + "name": "bytes_read", + "type": "Long", + "desc": "The number of bytes the process has read from disk" + }, + { + "name": "bytes_written", + "type": "Long", + "desc": "The number of bytes the process has written to disk" + }, + { + "name": "handle_count", + "type": "Long", + "desc": "The number of file handles that the process owns" + } + ] + }, + { + "name": "software.OS", + "root": true, + "singular": true, + "attributes": [ + { + "name": "family", + "type": "String", + "constant": true, + "desc": "The operating system's family" + }, + { + "name": "manufacturer", + "type": "String", + "constant": true, + "desc": "The operating system's manufacturer" + }, + { + "name": "bitness", + "type": "Integer", + "constant": true, + "desc": "The operating system's register width in bits" + }, + { + "name": "version", + "type": "String", + "constant": true, + "desc": "The operating system's primary version" + }, + { + "name": "codename", + "type": "String", + "constant": true, + "desc": "The operating system's code name" + }, + { + "name": "build_number", + "type": "String", + "constant": true, + "desc": "The operating system's build number" + } + ] + }, + { + "name": "software.Network", + "root": true, + "singular": true, + "attributes": [ + { + "name": "hostname", + "type": "String", + "desc": "The host's hostname" + }, + { + "name": "fqdn", + "type": "String", + "desc": "The host's fully-qualified domain name" + }, + { + "name": "dns", + "type": "String[]", + "desc": "The host's DNS servers" + } + ] + } +] \ No newline at end of file diff --git a/reference/definitions.json b/reference/definitions.json new file mode 100644 index 0000000..13b0726 --- /dev/null +++ b/reference/definitions.json @@ -0,0 +1,396 @@ +[ + { + "name": "hardware.Nic", + "root": true, + "desc": "A network interface", + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": "The interface's name" + }, + { + "name": "description", + "type": "String", + "constant": true, + "desc": "The interface's description" + }, + { + "name": "mtu", + "type": "Integer", + "desc": "The maximum transmission unit" + }, + { + "name": "mac", + "type": "String", + "desc": null + }, + { + "name": "virtual", + "type": "Boolean", + "desc": null + }, + { + "name": "ipv4", + "type": "String[]", + "desc": "The interface's IPv4 addresses" + }, + { + "name": "ipv6", + "type": "String[]", + "desc": "The interface's IPv6 addresses" + }, + { + "name": "broadcast", + "type": "String", + "desc": null + }, + { + "name": "netmask", + "type": "String", + "desc": "The interface's subnet mask" + }, + { + "name": "read_bytes", + "type": "Long", + "desc": "The number of bytes read from the interface" + }, + { + "name": "write_bytes", + "type": "Long", + "desc": "The number of bytes written to the interface" + }, + { + "name": "read_packets", + "type": "Long", + "desc": "The number of packets read from the interface" + }, + { + "name": "write_packets", + "type": "Long", + "desc": "The number of packets written to the interface" + }, + { + "name": "read_errors", + "type": "Long", + "desc": "The number of read errors" + }, + { + "name": "write_errors", + "type": "Long", + "desc": "The number of write errors" + }, + { + "name": "read_drops", + "type": "Long", + "desc": "The number of read drops" + }, + { + "name": "write_drops", + "type": "Long", + "desc": "The number of write drops" + }, + { + "name": "write_collisions", + "type": "Long", + "desc": "The number of write collisions" + }, + { + "name": "link_speed", + "type": "Long", + "desc": "The interface's maximum speed in bytes" + }, + { + "name": "default_gateway", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_up", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_running", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_loopback", + "type": "Boolean", + "desc": null + }, + { + "name": "flag_multicast", + "type": "Boolean", + "desc": null + }, + { + "name": "luid", + "type": "Long", + "desc": "The interface's locally unique identifier", + "compatible": [ + "windows" + ] + }, + { + "name": "guid", + "type": "String", + "desc": "The interface's globally unique identifier", + "compatible": [ + "windows" + ] + }, + { + "name": "paused", + "type": "Boolean", + "desc": "Whether the interface is in a paused state", + "compatible": [ + "windows" + ] + }, + { + "name": "lowPower", + "type": "Boolean", + "desc": "Whether the interface is in a low-power state", + "compatible": [ + "windows" + ] + } + ] + }, + { + "name": "hardware.Disk", + "root": true, + "desc": "A storage device", + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "model", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "serial", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "size", + "type": "Long", + "desc": "The disk's total size in bytes" + }, + { + "name": "reads", + "type": "Long", + "desc": null + }, + { + "name": "read_bytes", + "type": "Long", + "desc": null + }, + { + "name": "writes", + "type": "Long", + "desc": null + }, + { + "name": "write_bytes", + "type": "Long", + "desc": null + }, + { + "name": "queue_length", + "type": "Long", + "desc": null + }, + { + "name": "transfer_time", + "type": "Long", + "desc": null + }, + { + "name": "model_family", + "type": "String", + "extension": "smartmontools", + "desc": null + }, + { + "name": "firmware_version", + "type": "String", + "extension": "smartmontools", + "desc": null + }, + { + "name": "rotation_rate", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "read_error_rate", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "spin_up_time", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "start_stop_cycles", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "reallocated_sectors", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "seek_error_rate", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "power_on_time", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "spin_retries", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "calibration_retries", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "power_cycles", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "poweroff_retracts", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "load_cycles", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "temperature", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "reallocated_events", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "current_pending_sector", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "offline_uncorrectable", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "crc_errors", + "type": "Long", + "extension": "smartmontools", + "desc": null + }, + { + "name": "multizone_error_rate", + "type": "Long", + "extension": "smartmontools", + "desc": null + } + ] + }, + { + "name": "hardware.Firmware", + "root": true, + "singular": true, + "desc": "The system's firmware", + "attributes": [ + { + "name": "name", + "type": "String", + "constant": true, + "desc": null + }, + { + "name": "manufacturer", + "type": "String", + "constant": true, + "desc": "The BIOS manufacturer title" + }, + { + "name": "description", + "type": "String", + "constant": true, + "desc": "The BIOS description" + }, + { + "name": "version", + "type": "String", + "constant": true, + "desc": "The BIOS version number" + }, + { + "name": "revision", + "type": "String", + "constant": true, + "desc": "The BIOS revision number" + }, + { + "name": "release_date", + "type": "String", + "constant": true, + "desc": "The BIOS release date" + }, + { + "name": "uefi", + "type": "Boolean", + "constant": true, + "desc": "Whether the BIOS supports UEFI mode", + "compatible": [ + "linux" + ] + } + ] + } +] \ No newline at end of file diff --git a/reference/gen/main/java/oshi/api/FreeBsdSystem.java b/reference/gen/main/java/oshi/api/FreeBsdSystem.java new file mode 100644 index 0000000..14f29d8 --- /dev/null +++ b/reference/gen/main/java/oshi/api/FreeBsdSystem.java @@ -0,0 +1,15 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.api.hardware.nic.NicFreeBsd; + +public interface FreeBsdSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareFreeBsd getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/LinuxSystem.java b/reference/gen/main/java/oshi/api/LinuxSystem.java new file mode 100644 index 0000000..620a4a4 --- /dev/null +++ b/reference/gen/main/java/oshi/api/LinuxSystem.java @@ -0,0 +1,15 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import oshi.api.hardware.disk.DiskLinux; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.api.hardware.nic.NicLinux; + +public interface LinuxSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareLinux getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/MacSystem.java b/reference/gen/main/java/oshi/api/MacSystem.java new file mode 100644 index 0000000..57ba458 --- /dev/null +++ b/reference/gen/main/java/oshi/api/MacSystem.java @@ -0,0 +1,15 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import oshi.api.hardware.disk.DiskMac; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.api.hardware.nic.NicMac; + +public interface MacSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareMac getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/MultiSystem.java b/reference/gen/main/java/oshi/api/MultiSystem.java new file mode 100644 index 0000000..858d717 --- /dev/null +++ b/reference/gen/main/java/oshi/api/MultiSystem.java @@ -0,0 +1,15 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import oshi.api.hardware.disk.Disk; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.nic.Nic; + +public interface MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + Firmware getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/SolarisSystem.java b/reference/gen/main/java/oshi/api/SolarisSystem.java new file mode 100644 index 0000000..5c3e9b7 --- /dev/null +++ b/reference/gen/main/java/oshi/api/SolarisSystem.java @@ -0,0 +1,15 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.api.hardware.nic.NicSolaris; + +public interface SolarisSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareSolaris getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/WindowsSystem.java b/reference/gen/main/java/oshi/api/WindowsSystem.java new file mode 100644 index 0000000..4a809ab --- /dev/null +++ b/reference/gen/main/java/oshi/api/WindowsSystem.java @@ -0,0 +1,15 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import oshi.api.hardware.disk.DiskWindows; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.api.hardware.nic.NicWindows; + +public interface WindowsSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareWindows getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/Disk.java b/reference/gen/main/java/oshi/api/hardware/disk/Disk.java new file mode 100644 index 0000000..464e3b3 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/Disk.java @@ -0,0 +1,118 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +public interface Disk { + String getName(); + + String getModel(); + + String getSerial(); + + Long getSize(); + + Long querySize(); + + Long getReads(); + + Long queryReads(); + + Long getReadBytes(); + + Long queryReadBytes(); + + Long getWrites(); + + Long queryWrites(); + + Long getWriteBytes(); + + Long queryWriteBytes(); + + Long getQueueLength(); + + Long queryQueueLength(); + + Long getTransferTime(); + + Long queryTransferTime(); + + String getModelFamily(); + + String queryModelFamily(); + + String getFirmwareVersion(); + + String queryFirmwareVersion(); + + Long getRotationRate(); + + Long queryRotationRate(); + + Long getReadErrorRate(); + + Long queryReadErrorRate(); + + Long getSpinUpTime(); + + Long querySpinUpTime(); + + Long getStartStopCycles(); + + Long queryStartStopCycles(); + + Long getReallocatedSectors(); + + Long queryReallocatedSectors(); + + Long getSeekErrorRate(); + + Long querySeekErrorRate(); + + Long getPowerOnTime(); + + Long queryPowerOnTime(); + + Long getSpinRetries(); + + Long querySpinRetries(); + + Long getCalibrationRetries(); + + Long queryCalibrationRetries(); + + Long getPowerCycles(); + + Long queryPowerCycles(); + + Long getPoweroffRetracts(); + + Long queryPoweroffRetracts(); + + Long getLoadCycles(); + + Long queryLoadCycles(); + + Long getTemperature(); + + Long queryTemperature(); + + Long getReallocatedEvents(); + + Long queryReallocatedEvents(); + + Long getCurrentPendingSector(); + + Long queryCurrentPendingSector(); + + Long getOfflineUncorrectable(); + + Long queryOfflineUncorrectable(); + + Long getCrcErrors(); + + Long queryCrcErrors(); + + Long getMultizoneErrorRate(); + + Long queryMultizoneErrorRate(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java new file mode 100644 index 0000000..96dbd3d --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java @@ -0,0 +1,478 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import java.lang.Override; +import oshi.api.DetachedContainerException; +import oshi.api.hardware.disk.internal.DiskAttribute; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +public abstract class DiskContainer implements Disk { + private transient ComponentDriver driver; + + public String name; + + public String model; + + public String serial; + + /** + * The disk's total size in bytes + */ + public Long size; + + public Long reads; + + public Long readBytes; + + public Long writes; + + public Long writeBytes; + + public Long queueLength; + + public Long transferTime; + + public String modelFamily; + + public String firmwareVersion; + + public Long rotationRate; + + public Long readErrorRate; + + public Long spinUpTime; + + public Long startStopCycles; + + public Long reallocatedSectors; + + public Long seekErrorRate; + + public Long powerOnTime; + + public Long spinRetries; + + public Long calibrationRetries; + + public Long powerCycles; + + public Long poweroffRetracts; + + public Long loadCycles; + + public Long temperature; + + public Long reallocatedEvents; + + public Long currentPendingSector; + + public Long offlineUncorrectable; + + public Long crcErrors; + + public Long multizoneErrorRate; + + @Override + public String getName() { + return name; + } + + @Override + public String getModel() { + return model; + } + + @Override + public String getSerial() { + return serial; + } + + @Override + public Long getSize() { + return size; + } + + @Override + public Long querySize() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.SIZE); + return size; + } + + @Override + public Long getReads() { + return reads; + } + + @Override + public Long queryReads() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.READS); + return reads; + } + + @Override + public Long getReadBytes() { + return readBytes; + } + + @Override + public Long queryReadBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.READ_BYTES); + return readBytes; + } + + @Override + public Long getWrites() { + return writes; + } + + @Override + public Long queryWrites() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.WRITES); + return writes; + } + + @Override + public Long getWriteBytes() { + return writeBytes; + } + + @Override + public Long queryWriteBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.WRITE_BYTES); + return writeBytes; + } + + @Override + public Long getQueueLength() { + return queueLength; + } + + @Override + public Long queryQueueLength() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.QUEUE_LENGTH); + return queueLength; + } + + @Override + public Long getTransferTime() { + return transferTime; + } + + @Override + public Long queryTransferTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.TRANSFER_TIME); + return transferTime; + } + + @Override + public String getModelFamily() { + return modelFamily; + } + + @Override + public String queryModelFamily() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.MODEL_FAMILY); + return modelFamily; + } + + @Override + public String getFirmwareVersion() { + return firmwareVersion; + } + + @Override + public String queryFirmwareVersion() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.FIRMWARE_VERSION); + return firmwareVersion; + } + + @Override + public Long getRotationRate() { + return rotationRate; + } + + @Override + public Long queryRotationRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.ROTATION_RATE); + return rotationRate; + } + + @Override + public Long getReadErrorRate() { + return readErrorRate; + } + + @Override + public Long queryReadErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.READ_ERROR_RATE); + return readErrorRate; + } + + @Override + public Long getSpinUpTime() { + return spinUpTime; + } + + @Override + public Long querySpinUpTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.SPIN_UP_TIME); + return spinUpTime; + } + + @Override + public Long getStartStopCycles() { + return startStopCycles; + } + + @Override + public Long queryStartStopCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.START_STOP_CYCLES); + return startStopCycles; + } + + @Override + public Long getReallocatedSectors() { + return reallocatedSectors; + } + + @Override + public Long queryReallocatedSectors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.REALLOCATED_SECTORS); + return reallocatedSectors; + } + + @Override + public Long getSeekErrorRate() { + return seekErrorRate; + } + + @Override + public Long querySeekErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.SEEK_ERROR_RATE); + return seekErrorRate; + } + + @Override + public Long getPowerOnTime() { + return powerOnTime; + } + + @Override + public Long queryPowerOnTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.POWER_ON_TIME); + return powerOnTime; + } + + @Override + public Long getSpinRetries() { + return spinRetries; + } + + @Override + public Long querySpinRetries() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.SPIN_RETRIES); + return spinRetries; + } + + @Override + public Long getCalibrationRetries() { + return calibrationRetries; + } + + @Override + public Long queryCalibrationRetries() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.CALIBRATION_RETRIES); + return calibrationRetries; + } + + @Override + public Long getPowerCycles() { + return powerCycles; + } + + @Override + public Long queryPowerCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.POWER_CYCLES); + return powerCycles; + } + + @Override + public Long getPoweroffRetracts() { + return poweroffRetracts; + } + + @Override + public Long queryPoweroffRetracts() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.POWEROFF_RETRACTS); + return poweroffRetracts; + } + + @Override + public Long getLoadCycles() { + return loadCycles; + } + + @Override + public Long queryLoadCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.LOAD_CYCLES); + return loadCycles; + } + + @Override + public Long getTemperature() { + return temperature; + } + + @Override + public Long queryTemperature() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.TEMPERATURE); + return temperature; + } + + @Override + public Long getReallocatedEvents() { + return reallocatedEvents; + } + + @Override + public Long queryReallocatedEvents() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.REALLOCATED_EVENTS); + return reallocatedEvents; + } + + @Override + public Long getCurrentPendingSector() { + return currentPendingSector; + } + + @Override + public Long queryCurrentPendingSector() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.CURRENT_PENDING_SECTOR); + return currentPendingSector; + } + + @Override + public Long getOfflineUncorrectable() { + return offlineUncorrectable; + } + + @Override + public Long queryOfflineUncorrectable() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.OFFLINE_UNCORRECTABLE); + return offlineUncorrectable; + } + + @Override + public Long getCrcErrors() { + return crcErrors; + } + + @Override + public Long queryCrcErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.CRC_ERRORS); + return crcErrors; + } + + @Override + public Long getMultizoneErrorRate() { + return multizoneErrorRate; + } + + @Override + public Long queryMultizoneErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttribute.MULTIZONE_ERROR_RATE); + return multizoneErrorRate; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(DiskAttribute.NAME); + driver.query(DiskAttribute.MODEL); + driver.query(DiskAttribute.SERIAL); + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java new file mode 100644 index 0000000..b331e05 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +public class DiskContainerFreeBsd extends DiskContainer implements DiskFreeBsd { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java new file mode 100644 index 0000000..955bf93 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +public class DiskContainerLinux extends DiskContainer implements DiskLinux { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java new file mode 100644 index 0000000..f27d692 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +public class DiskContainerMac extends DiskContainer implements DiskMac { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java new file mode 100644 index 0000000..fce8a4d --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +public class DiskContainerSolaris extends DiskContainer implements DiskSolaris { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java new file mode 100644 index 0000000..8874f85 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +public class DiskContainerWindows extends DiskContainer implements DiskWindows { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java new file mode 100644 index 0000000..b3168eb --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +public interface DiskFreeBsd extends Disk { +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java new file mode 100644 index 0000000..4b8bd34 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +public interface DiskLinux extends Disk { +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java new file mode 100644 index 0000000..4b1c42b --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +public interface DiskMac extends Disk { +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java new file mode 100644 index 0000000..7ad5bf4 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +public interface DiskSolaris extends Disk { +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java new file mode 100644 index 0000000..0757b11 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +public interface DiskWindows extends Disk { +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java b/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java new file mode 100644 index 0000000..4384ae2 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java @@ -0,0 +1,64 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +public enum DiskAttribute { + NAME, + + MODEL, + + SERIAL, + + SIZE, + + READS, + + READ_BYTES, + + WRITES, + + WRITE_BYTES, + + QUEUE_LENGTH, + + TRANSFER_TIME, + + MODEL_FAMILY, + + FIRMWARE_VERSION, + + ROTATION_RATE, + + READ_ERROR_RATE, + + SPIN_UP_TIME, + + START_STOP_CYCLES, + + REALLOCATED_SECTORS, + + SEEK_ERROR_RATE, + + POWER_ON_TIME, + + SPIN_RETRIES, + + CALIBRATION_RETRIES, + + POWER_CYCLES, + + POWEROFF_RETRACTS, + + LOAD_CYCLES, + + TEMPERATURE, + + REALLOCATED_EVENTS, + + CURRENT_PENDING_SECTOR, + + OFFLINE_UNCORRECTABLE, + + CRC_ERRORS, + + MULTIZONE_ERROR_RATE +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java b/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java new file mode 100644 index 0000000..9f95867 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java @@ -0,0 +1,13 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface DiskQuery { + DiskAttribute[] value(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java b/reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java new file mode 100644 index 0000000..c825053 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java @@ -0,0 +1,16 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +public interface Firmware { + String getName(); + + String getManufacturer(); + + String getDescription(); + + String getVersion(); + + String getRevision(); + + String getReleaseDate(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java new file mode 100644 index 0000000..bd11f04 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java @@ -0,0 +1,81 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import java.lang.Override; +import oshi.api.hardware.firmware.internal.FirmwareAttribute; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +public abstract class FirmwareContainer implements Firmware { + private transient ComponentDriver driver; + + public String name; + + /** + * The BIOS manufacturer title + */ + public String manufacturer; + + /** + * The BIOS description + */ + public String description; + + /** + * The BIOS version number + */ + public String version; + + /** + * The BIOS revision number + */ + public String revision; + + /** + * The BIOS release date + */ + public String releaseDate; + + @Override + public String getName() { + return name; + } + + @Override + public String getManufacturer() { + return manufacturer; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public String getVersion() { + return version; + } + + @Override + public String getRevision() { + return revision; + } + + @Override + public String getReleaseDate() { + return releaseDate; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(FirmwareAttribute.NAME); + driver.query(FirmwareAttribute.MANUFACTURER); + driver.query(FirmwareAttribute.DESCRIPTION); + driver.query(FirmwareAttribute.VERSION); + driver.query(FirmwareAttribute.REVISION); + driver.query(FirmwareAttribute.RELEASE_DATE); + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java new file mode 100644 index 0000000..d72564a --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +public class FirmwareContainerFreeBsd extends FirmwareContainer implements FirmwareFreeBsd { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java new file mode 100644 index 0000000..c6143db --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java @@ -0,0 +1,30 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import java.lang.Override; +import oshi.api.hardware.firmware.internal.FirmwareAttribute; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +public class FirmwareContainerLinux extends FirmwareContainer implements FirmwareLinux { + private transient ComponentDriver driver; + + /** + * Whether the BIOS supports UEFI mode + */ + public Boolean uefi; + + @Override + public Boolean getUefi() { + return uefi; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + driver.query(FirmwareAttribute.UEFI); + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java new file mode 100644 index 0000000..21ebc75 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +public class FirmwareContainerMac extends FirmwareContainer implements FirmwareMac { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java new file mode 100644 index 0000000..28efd67 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +public class FirmwareContainerSolaris extends FirmwareContainer implements FirmwareSolaris { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java new file mode 100644 index 0000000..30ce95b --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +public class FirmwareContainerWindows extends FirmwareContainer implements FirmwareWindows { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java new file mode 100644 index 0000000..84e1a8f --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +public interface FirmwareFreeBsd extends Firmware { +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java new file mode 100644 index 0000000..54ca90f --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java @@ -0,0 +1,6 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +public interface FirmwareLinux extends Firmware { + Boolean getUefi(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java new file mode 100644 index 0000000..4194db3 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +public interface FirmwareMac extends Firmware { +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java new file mode 100644 index 0000000..547614f --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +public interface FirmwareSolaris extends Firmware { +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java new file mode 100644 index 0000000..dae0073 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +public interface FirmwareWindows extends Firmware { +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java b/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java new file mode 100644 index 0000000..444fcce --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java @@ -0,0 +1,18 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +public enum FirmwareAttribute { + NAME, + + MANUFACTURER, + + DESCRIPTION, + + VERSION, + + REVISION, + + RELEASE_DATE, + + UEFI +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java b/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java new file mode 100644 index 0000000..c09df96 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java @@ -0,0 +1,13 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface FirmwareQuery { + FirmwareAttribute[] value(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/Nic.java b/reference/gen/main/java/oshi/api/hardware/nic/Nic.java new file mode 100644 index 0000000..063390b --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/Nic.java @@ -0,0 +1,96 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +public interface Nic { + String getName(); + + String getDescription(); + + Integer getMtu(); + + Integer queryMtu(); + + String getMac(); + + String queryMac(); + + Boolean getVirtual(); + + Boolean queryVirtual(); + + String[] getIpv4(); + + String[] queryIpv4(); + + String[] getIpv6(); + + String[] queryIpv6(); + + String getBroadcast(); + + String queryBroadcast(); + + String getNetmask(); + + String queryNetmask(); + + Long getReadBytes(); + + Long queryReadBytes(); + + Long getWriteBytes(); + + Long queryWriteBytes(); + + Long getReadPackets(); + + Long queryReadPackets(); + + Long getWritePackets(); + + Long queryWritePackets(); + + Long getReadErrors(); + + Long queryReadErrors(); + + Long getWriteErrors(); + + Long queryWriteErrors(); + + Long getReadDrops(); + + Long queryReadDrops(); + + Long getWriteDrops(); + + Long queryWriteDrops(); + + Long getWriteCollisions(); + + Long queryWriteCollisions(); + + Long getLinkSpeed(); + + Long queryLinkSpeed(); + + Boolean getDefaultGateway(); + + Boolean queryDefaultGateway(); + + Boolean getFlagUp(); + + Boolean queryFlagUp(); + + Boolean getFlagRunning(); + + Boolean queryFlagRunning(); + + Boolean getFlagLoopback(); + + Boolean queryFlagLoopback(); + + Boolean getFlagMulticast(); + + Boolean queryFlagMulticast(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java new file mode 100644 index 0000000..3ed6658 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java @@ -0,0 +1,435 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import java.lang.Override; +import oshi.api.DetachedContainerException; +import oshi.api.hardware.nic.internal.NicAttribute; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +public abstract class NicContainer implements Nic { + private transient ComponentDriver driver; + + /** + * The interface's name + */ + public String name; + + /** + * The interface's description + */ + public String description; + + /** + * The maximum transmission unit + */ + public Integer mtu; + + public String mac; + + public Boolean virtual; + + /** + * The interface's IPv4 addresses + */ + public String[] ipv4; + + /** + * The interface's IPv6 addresses + */ + public String[] ipv6; + + public String broadcast; + + /** + * The interface's subnet mask + */ + public String netmask; + + /** + * The number of bytes read from the interface + */ + public Long readBytes; + + /** + * The number of bytes written to the interface + */ + public Long writeBytes; + + /** + * The number of packets read from the interface + */ + public Long readPackets; + + /** + * The number of packets written to the interface + */ + public Long writePackets; + + /** + * The number of read errors + */ + public Long readErrors; + + /** + * The number of write errors + */ + public Long writeErrors; + + /** + * The number of read drops + */ + public Long readDrops; + + /** + * The number of write drops + */ + public Long writeDrops; + + /** + * The number of write collisions + */ + public Long writeCollisions; + + /** + * The interface's maximum speed in bytes + */ + public Long linkSpeed; + + public Boolean defaultGateway; + + public Boolean flagUp; + + public Boolean flagRunning; + + public Boolean flagLoopback; + + public Boolean flagMulticast; + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public Integer getMtu() { + return mtu; + } + + @Override + public Integer queryMtu() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.MTU); + return mtu; + } + + @Override + public String getMac() { + return mac; + } + + @Override + public String queryMac() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.MAC); + return mac; + } + + @Override + public Boolean getVirtual() { + return virtual; + } + + @Override + public Boolean queryVirtual() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.VIRTUAL); + return virtual; + } + + @Override + public String[] getIpv4() { + return ipv4; + } + + @Override + public String[] queryIpv4() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.IPV4); + return ipv4; + } + + @Override + public String[] getIpv6() { + return ipv6; + } + + @Override + public String[] queryIpv6() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.IPV6); + return ipv6; + } + + @Override + public String getBroadcast() { + return broadcast; + } + + @Override + public String queryBroadcast() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.BROADCAST); + return broadcast; + } + + @Override + public String getNetmask() { + return netmask; + } + + @Override + public String queryNetmask() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.NETMASK); + return netmask; + } + + @Override + public Long getReadBytes() { + return readBytes; + } + + @Override + public Long queryReadBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.READ_BYTES); + return readBytes; + } + + @Override + public Long getWriteBytes() { + return writeBytes; + } + + @Override + public Long queryWriteBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.WRITE_BYTES); + return writeBytes; + } + + @Override + public Long getReadPackets() { + return readPackets; + } + + @Override + public Long queryReadPackets() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.READ_PACKETS); + return readPackets; + } + + @Override + public Long getWritePackets() { + return writePackets; + } + + @Override + public Long queryWritePackets() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.WRITE_PACKETS); + return writePackets; + } + + @Override + public Long getReadErrors() { + return readErrors; + } + + @Override + public Long queryReadErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.READ_ERRORS); + return readErrors; + } + + @Override + public Long getWriteErrors() { + return writeErrors; + } + + @Override + public Long queryWriteErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.WRITE_ERRORS); + return writeErrors; + } + + @Override + public Long getReadDrops() { + return readDrops; + } + + @Override + public Long queryReadDrops() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.READ_DROPS); + return readDrops; + } + + @Override + public Long getWriteDrops() { + return writeDrops; + } + + @Override + public Long queryWriteDrops() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.WRITE_DROPS); + return writeDrops; + } + + @Override + public Long getWriteCollisions() { + return writeCollisions; + } + + @Override + public Long queryWriteCollisions() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.WRITE_COLLISIONS); + return writeCollisions; + } + + @Override + public Long getLinkSpeed() { + return linkSpeed; + } + + @Override + public Long queryLinkSpeed() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.LINK_SPEED); + return linkSpeed; + } + + @Override + public Boolean getDefaultGateway() { + return defaultGateway; + } + + @Override + public Boolean queryDefaultGateway() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.DEFAULT_GATEWAY); + return defaultGateway; + } + + @Override + public Boolean getFlagUp() { + return flagUp; + } + + @Override + public Boolean queryFlagUp() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.FLAG_UP); + return flagUp; + } + + @Override + public Boolean getFlagRunning() { + return flagRunning; + } + + @Override + public Boolean queryFlagRunning() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.FLAG_RUNNING); + return flagRunning; + } + + @Override + public Boolean getFlagLoopback() { + return flagLoopback; + } + + @Override + public Boolean queryFlagLoopback() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.FLAG_LOOPBACK); + return flagLoopback; + } + + @Override + public Boolean getFlagMulticast() { + return flagMulticast; + } + + @Override + public Boolean queryFlagMulticast() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.FLAG_MULTICAST); + return flagMulticast; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(NicAttribute.NAME); + driver.query(NicAttribute.DESCRIPTION); + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java new file mode 100644 index 0000000..6d13bc1 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +public class NicContainerFreeBsd extends NicContainer implements NicFreeBsd { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java new file mode 100644 index 0000000..42db77a --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +public class NicContainerLinux extends NicContainer implements NicLinux { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java new file mode 100644 index 0000000..15e1305 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +public class NicContainerMac extends NicContainer implements NicMac { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java new file mode 100644 index 0000000..2bae89b --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java @@ -0,0 +1,17 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +public class NicContainerSolaris extends NicContainer implements NicSolaris { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java new file mode 100644 index 0000000..4184866 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java @@ -0,0 +1,96 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import java.lang.Override; +import oshi.api.DetachedContainerException; +import oshi.api.hardware.nic.internal.NicAttribute; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +public class NicContainerWindows extends NicContainer implements NicWindows { + private transient ComponentDriver driver; + + /** + * The interface's locally unique identifier + */ + public Long luid; + + /** + * The interface's globally unique identifier + */ + public String guid; + + /** + * Whether the interface is in a paused state + */ + public Boolean paused; + + /** + * Whether the interface is in a low-power state + */ + public Boolean lowpower; + + @Override + public Long getLuid() { + return luid; + } + + @Override + public Long queryLuid() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.LUID); + return luid; + } + + @Override + public String getGuid() { + return guid; + } + + @Override + public String queryGuid() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.GUID); + return guid; + } + + @Override + public Boolean getPaused() { + return paused; + } + + @Override + public Boolean queryPaused() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.PAUSED); + return paused; + } + + @Override + public Boolean getLowpower() { + return lowpower; + } + + @Override + public Boolean queryLowpower() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttribute.LOWPOWER); + return lowpower; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java new file mode 100644 index 0000000..c994c3b --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +public interface NicFreeBsd extends Nic { +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java b/reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java new file mode 100644 index 0000000..4d2ccd9 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +public interface NicLinux extends Nic { +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicMac.java b/reference/gen/main/java/oshi/api/hardware/nic/NicMac.java new file mode 100644 index 0000000..e4e7c88 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicMac.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +public interface NicMac extends Nic { +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java b/reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java new file mode 100644 index 0000000..8bd21f8 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java @@ -0,0 +1,5 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +public interface NicSolaris extends Nic { +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java b/reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java new file mode 100644 index 0000000..4a39d8f --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java @@ -0,0 +1,20 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +public interface NicWindows extends Nic { + Long getLuid(); + + Long queryLuid(); + + String getGuid(); + + String queryGuid(); + + Boolean getPaused(); + + Boolean queryPaused(); + + Boolean getLowpower(); + + Boolean queryLowpower(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java b/reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java new file mode 100644 index 0000000..958b187 --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java @@ -0,0 +1,60 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +public enum NicAttribute { + NAME, + + DESCRIPTION, + + MTU, + + MAC, + + VIRTUAL, + + IPV4, + + IPV6, + + BROADCAST, + + NETMASK, + + READ_BYTES, + + WRITE_BYTES, + + READ_PACKETS, + + WRITE_PACKETS, + + READ_ERRORS, + + WRITE_ERRORS, + + READ_DROPS, + + WRITE_DROPS, + + WRITE_COLLISIONS, + + LINK_SPEED, + + DEFAULT_GATEWAY, + + FLAG_UP, + + FLAG_RUNNING, + + FLAG_LOOPBACK, + + FLAG_MULTICAST, + + LUID, + + GUID, + + PAUSED, + + LOWPOWER +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java b/reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java new file mode 100644 index 0000000..b298d0c --- /dev/null +++ b/reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java @@ -0,0 +1,13 @@ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface NicQuery { + NicAttribute[] value(); +} diff --git a/reference/src/main/java/oshi/ApiGenerator.java b/reference/src/main/java/oshi/ApiGenerator.java new file mode 100644 index 0000000..ac2475f --- /dev/null +++ b/reference/src/main/java/oshi/ApiGenerator.java @@ -0,0 +1,320 @@ +package oshi; + +import static javax.lang.model.element.Modifier.ABSTRACT; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.TRANSIENT; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.squareup.javapoet.AnnotationSpec; +import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.CodeBlock; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.JavaFile; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeSpec; + +import oshi.api.DetachedContainerException; + +/** + * This class generates most of the API layer according to a global + * {@code definitions.json} file in the root project directory. + * + * @author cilki + * @since 5.0.0 + */ +public final class ApiGenerator { + + /** + * Represents a system attribute in the definitions file. + */ + private static class AttributeJson { + /** + * The attribute's name in lowercase underscore format. + */ + public String name; + /** + * The attribute's data type. + */ + public String type; + /** + * The attribute's short description. + */ + public String desc; + /** + * Whether the attribute's value can change over the lifetime of the system. + */ + public boolean constant; + /** + * The attribute's extension type. + */ + public String extension; + /** + * A platform compatibility whitelist. + */ + public List compatible; + } + + /** + * Represents a system component in the definitions file. + */ + private static class ComponentJson { + /** + * The component's name in dot-path notation. + */ + public String name; + /** + * Whether the component is accessible from the root of the API. + */ + public boolean root; + /** + * Whether the system can contain only one or more than one of the component. + */ + public boolean singular; + + /** + * The component's short description. + */ + public String desc; + /** + * The component's attributes. + */ + public List attributes; + + /** + * Parse the last element of the component's dot-path. + * + * @return The component's base name + */ + public String getBaseName() { + return name.substring(name.lastIndexOf('.') + 1); + } + + /** + * Parse the package elements from the component's dot-path. + * + * @return The component's package + */ + public String getPkgName() { + return "oshi.api." + name.substring(0, name.lastIndexOf('.')) + "." + getBaseName().toLowerCase(); + } + } + + /** + * The output source folder. + */ + private static final Path OUTPUT = Paths.get("gen/main/java"); + + private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; + + /** + * The generator's full output which is collected and written at the end. + */ + private static List files = new ArrayList<>(); + + public static void main(String[] argv) throws Exception { + try (var in = Files.newInputStream(Paths.get("definitions.json"))) { + List json = new ObjectMapper().readValue(in, new TypeReference>() { + // The age old anonymous class trick + }); + + for (var component : json) { + generateAttributeEnums(component); + for (var platform : List.of("", "Windows", "Mac", "Linux", "Solaris", "FreeBsd")) { + generate(component, platform); + } + } + + for (var platform : List.of("", "Windows", "Mac", "Linux", "Solaris", "FreeBsd")) + generateSystemInterface(json, platform); + } + + // Output files if there were no errors + for (var type : files) + type.writeTo(OUTPUT); + } + + private static void generateAttributeEnums(ComponentJson component) throws Exception { + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + var attributeEnum = TypeSpec.enumBuilder(baseName + "Attribute").addModifiers(PUBLIC); + + for (var attribute : component.attributes) { + // Generate enum constant + attributeEnum.addEnumConstant(attribute.name.toUpperCase()); + } + + files.add(JavaFile.builder(pkgName + ".internal", attributeEnum.build()).addFileComment(GENERATOR_COMMENT) + .build()); + } + + private static void generate(ComponentJson component, String platform) throws Exception { + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + // Build classes for component + var container = TypeSpec.classBuilder(baseName + "Container" + platform).addModifiers(PUBLIC); + var containerInterface = TypeSpec.interfaceBuilder(baseName + platform).addModifiers(PUBLIC); + var queryAnnotation = TypeSpec.annotationBuilder(baseName + "Query").addModifiers(PUBLIC) + .addAnnotation( + AnnotationSpec.builder(Retention.class) + .addMember("value", "$T.RUNTIME", + ClassName.get("java.lang.annotation", "RetentionPolicy")) + .build()) + .addAnnotation(AnnotationSpec.builder(Target.class) + .addMember("value", "$T.METHOD", ClassName.get("java.lang.annotation", "ElementType")).build()); + queryAnnotation.addMethod(MethodSpec.methodBuilder("value") + .returns(ClassName.get(pkgName + ".internal", baseName + "Attribute[]")).addModifiers(PUBLIC, ABSTRACT) + .build()); + + // Setup inheritance + container.addSuperinterface(ClassName.get(pkgName, baseName + platform)); + if (!platform.isEmpty()) { + container.superclass(ClassName.get(pkgName, baseName + "Container")); + containerInterface.addSuperinterface(ClassName.get(pkgName, baseName)); + } else { + container.addModifiers(ABSTRACT); + } + + if (component.desc != null) + container.addJavadoc(component.desc + "\n"); + + // Add driver field + container.addField(FieldSpec + .builder(ClassName.get("oshi.driver", "ComponentDriver"), "driver", PRIVATE, TRANSIENT).build()); + + // Create attach method + var attach = MethodSpec.methodBuilder("attach") + .addParameter(ClassName.get("oshi.driver", "ComponentDriver"), "driver") + .addStatement("this.driver = driver").addModifiers(PUBLIC); + if (!platform.isEmpty()) + attach.addStatement("super.attach(driver)"); + attach.addComment("Query all constant attributes:"); + + // Process attributes + for (var attribute : component.attributes) { + var type = ClassName.bestGuess(attribute.type); + + if (platform.isEmpty() && attribute.compatible == null + || attribute.compatible != null && attribute.compatible.contains(platform.toLowerCase())) { + + if (attribute.constant) + attach.addStatement("driver.query($T.$L)", + ClassName.get(pkgName + ".internal", baseName + "Attribute"), attribute.name.toUpperCase()); + + // Generate container field + var containerField = FieldSpec.builder(type, camel(attribute.name), PUBLIC); + if (attribute.desc != null) + containerField.addJavadoc(attribute.desc + "\n"); + container.addField(containerField.build()); + + // Generate container getter + var containerGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) + .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) + .addAnnotation(Override.class); + container.addMethod(containerGetter.build()); + + // Generate container interface getter + var containerInterfaceGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) + .addModifiers(PUBLIC, ABSTRACT); + containerInterface.addMethod(containerInterfaceGetter.build()); + + // Generate container interface query + var containerInterfaceQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) + .addModifiers(PUBLIC, ABSTRACT); + if (!attribute.constant) + containerInterface.addMethod(containerInterfaceQuery.build()); + + // Generate container query delegate + var containerQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) + .addCode(CodeBlock.builder().beginControlFlow("if (driver == null)") + .addStatement("throw new $T()", DetachedContainerException.class).endControlFlow() + .build()) + .addStatement("driver.query($T.$L)", + ClassName.get(pkgName + ".internal", baseName + "Attribute"), + attribute.name.toUpperCase()) + .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) + .addAnnotation(Override.class); + + if (!attribute.constant) + container.addMethod(containerQuery.build()); + } + } + + container.addMethod(attach.build()); + + files.add(JavaFile.builder(pkgName, container.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName, containerInterface.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName + ".internal", queryAnnotation.build()).addFileComment(GENERATOR_COMMENT) + .build()); + + } + + /** + * Generate an interface for top-level System classes for the given components + * and platform. + * + * @param components + * @param platform + */ + private static void generateSystemInterface(List components, String platform) { + var system = TypeSpec.interfaceBuilder((platform.isEmpty() ? "Multi" : platform) + "System") + .addModifiers(PUBLIC); + + for (var component : components) { + if (!component.root) + continue; + + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + var type = ClassName.get(pkgName, baseName + platform).box(); + + if (component.singular) { + var get = MethodSpec.methodBuilder(camel("get", baseName)).returns(type).addModifiers(PUBLIC, ABSTRACT); + + system.addMethod(get.build()); + } else { + type = ParameterizedTypeName.get(ClassName.get(Stream.class), type); + var get = MethodSpec.methodBuilder(camel("get", baseName, "stream")).returns(type).addModifiers(PUBLIC, + ABSTRACT); + + system.addMethod(get.build()); + } + } + + files.add(JavaFile.builder("oshi.api", system.build()).addFileComment(GENERATOR_COMMENT).build()); + } + + /** + * Convert the given Strings in underscore format into CamelCase format. The + * first character of the first String will always be unchanged. + * + * @param strings + * @return A CamelCase {@code String} + */ + private static String camel(String... strings) { + if (strings.length == 0) + return ""; + if (strings[0].isEmpty()) + throw new IllegalArgumentException("First component is empty"); + + return strings[0].charAt(0) + Stream.of(strings).map(String::toLowerCase) + .flatMap(s -> Arrays.stream(s.split("_"))).map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)) + .collect(Collectors.joining()).substring(1); + } +} \ No newline at end of file diff --git a/reference/src/main/java/oshi/api/DetachedContainerException.java b/reference/src/main/java/oshi/api/DetachedContainerException.java new file mode 100644 index 0000000..5e8983f --- /dev/null +++ b/reference/src/main/java/oshi/api/DetachedContainerException.java @@ -0,0 +1,14 @@ +package oshi.api; + +/** + * Indicates that the attempted operation requires the container to be attached, + * but the container was detached. + * + * @author cilki + * @since 5.0.0 + */ +public class DetachedContainerException extends RuntimeException { + + private static final long serialVersionUID = 979546852734821377L; + +} diff --git a/reference/src/main/java/oshi/api/NoSuchQueryMethodException.java b/reference/src/main/java/oshi/api/NoSuchQueryMethodException.java new file mode 100644 index 0000000..da231fc --- /dev/null +++ b/reference/src/main/java/oshi/api/NoSuchQueryMethodException.java @@ -0,0 +1,5 @@ +package oshi.api; + +public class NoSuchQueryMethodException extends RuntimeException { + +} diff --git a/reference/src/main/java/oshi/api/OSHI.java b/reference/src/main/java/oshi/api/OSHI.java new file mode 100644 index 0000000..6729f96 --- /dev/null +++ b/reference/src/main/java/oshi/api/OSHI.java @@ -0,0 +1,78 @@ +package oshi.api; + +import com.sun.jna.Platform; + +import oshi.driver.SystemDriver; +import oshi.driver.SystemDriverFreeBsd; +import oshi.driver.SystemDriverLinux; +import oshi.driver.SystemDriverMac; +import oshi.driver.SystemDriverSolaris; +import oshi.driver.SystemDriverWindows; + +public final class OSHI { + + private static final PlatformEnum platform; + + static { + if (Platform.isWindows()) { + platform = PlatformEnum.WINDOWS; + } else if (Platform.isLinux()) { + platform = PlatformEnum.LINUX; + } else if (Platform.isMac()) { + platform = PlatformEnum.MACOSX; + } else if (Platform.isSolaris()) { + platform = PlatformEnum.SOLARIS; + } else if (Platform.isFreeBSD()) { + platform = PlatformEnum.FREEBSD; + } else { + platform = PlatformEnum.UNKNOWN; + throw new RuntimeException("Unsupported platform"); + } + } + + /** + * Get the system's platform type. + * + * @return The platform type + */ + public static PlatformEnum getPlatform() { + return platform; + } + + public static MultiSystem getSystem() { + if (platform == PlatformEnum.UNKNOWN) + throw new UnsupportedOperationException(); + return new SystemDriver(platform); + } + + public static WindowsSystem getWindowsSystem() { + if (platform != PlatformEnum.WINDOWS) + throw new UnsupportedOperationException(); + return new SystemDriverWindows(); + } + + public static LinuxSystem getLinuxSystem() { + if (platform != PlatformEnum.LINUX) + throw new UnsupportedOperationException(); + return new SystemDriverLinux(); + } + + public static MacSystem getMacSystem() { + if (platform != PlatformEnum.MACOSX) + throw new UnsupportedOperationException(); + return new SystemDriverMac(); + } + + public static SolarisSystem getSolarisSystem() { + if (platform != PlatformEnum.SOLARIS) + throw new UnsupportedOperationException(); + return new SystemDriverSolaris(); + } + + public static FreeBsdSystem getFreebsdSystem() { + if (platform != PlatformEnum.FREEBSD) + throw new UnsupportedOperationException(); + return new SystemDriverFreeBsd(); + } + +} diff --git a/reference/src/main/java/oshi/api/PlatformEnum.java b/reference/src/main/java/oshi/api/PlatformEnum.java new file mode 100644 index 0000000..c54b6a1 --- /dev/null +++ b/reference/src/main/java/oshi/api/PlatformEnum.java @@ -0,0 +1,51 @@ +/** + * Oshi (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2018 The Oshi Project Team + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Maintainers: + * dblock[at]dblock[dot]org + * widdis[at]gmail[dot]com + * enrico.bianchi[at]gmail[dot]com + * + * Contributors: + * https://github.com/oshi/oshi/graphs/contributors + */ +package oshi.api; + +/** + * Enum of supported operating systems. + * + * @author alessandro[at]perucchi[dot]org + */ +public enum PlatformEnum { + /** + * Microsoft Windows + */ + WINDOWS, + /** + * A flavor of Linux + */ + LINUX, + /** + * macOS (OS X) + */ + MACOSX, + /** + * Solaris (SunOS) + */ + SOLARIS, + /** + * FreeBSD + */ + FREEBSD, + /** + * OpenBSD, WindowsCE, or an unspecified system + */ + UNKNOWN; +} diff --git a/reference/src/main/java/oshi/driver/ComponentDriver.java b/reference/src/main/java/oshi/driver/ComponentDriver.java new file mode 100644 index 0000000..25c5069 --- /dev/null +++ b/reference/src/main/java/oshi/driver/ComponentDriver.java @@ -0,0 +1,169 @@ +package oshi.driver; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import oshi.api.NoSuchQueryMethodException; + +/** + * A {@link ComponentDriver} is the root of the driver hierarchy. Containers can + * call {@link #query(Enum)} or {@link #queryAll()} to have this class update + * their state. There is a one-to-one correspondence between + * {@link ComponentDriver}s and container objects.
+ *
+ * This class automatically registers all query methods in its subclasses. Query + * methods in {@link ExtensionDriver}s can also be registered with + * {@link #register(ExtensionDriver)}. + * + * @author cilki + * @since 5.0.0 + */ +public class ComponentDriver { + + private static final class QueryHandle implements Comparable { + public MethodHandle handle; + public Fallback fallback; + public Class cls; + + public QueryHandle(MethodHandle handle, Fallback fallback, Class cls) { + this.handle = handle; + this.fallback = fallback; + this.cls = cls; + } + + @Override + public int compareTo(QueryHandle o) { + // TODO implement query ordering with fallbacks + return 0; + } + } + + /** + * An association between attribute enums and lists of query handles in + * descending priority order. A particular query handle can exist in multiple + * lists, but not more than once in each list. + */ + private Map, List> handles; + + /** + * A list of extensions in case they are needed in the future. + */ + private List extensions; + + public ComponentDriver() { + this.handles = new HashMap<>(); + this.extensions = new LinkedList<>(); + + registerDriver(this); + } + + /** + * Query the driver hierarchy for the value of the attribute corresponding to + * the given enum. + * + * @param attribute The attribute enum of the attribute to query + */ + public void query(Enum attribute) { + + var h = handles.get(attribute); + if (h == null) { + throw new NoSuchQueryMethodException(); + } + + for (var t : h) { + try { + t.handle.invoke(); + return; + } catch (Throwable e) { + // TODO log exception and continue + continue; + } + } + } + + /** + * Query every attribute in the driver hierarchy. + */ + public void queryAll() { + // Keep track of the handles that have been queried to prevent repeats + var queried = new HashSet(); + for (var handleList : handles.values()) { + for (var h : handleList) { + if (queried.contains(h.handle)) + break; + + queried.add(h.handle); + try { + h.handle.invoke(); + break; + } catch (Throwable e) { + // TODO log exception and continue + continue; + } + } + } + } + + public void register(ExtensionDriver driver) { + registerDriver(driver); + extensions.add(driver); + } + + /** + * Iterate through the methods of the given object and build a + * {@link QueryHandle} for each one containing a query annotation. + * + * @param driver The driver instance + */ + private void registerDriver(Object driver) { + Class driverClass = driver.getClass(); + while (driverClass != Object.class) { + for (Method m : driverClass.getDeclaredMethods()) { + + // Build a list of attributes defined in the annotations + var attributes = Arrays.stream(m.getDeclaredAnnotations()).flatMap(annotation -> { + try { + return Arrays.stream((Enum[]) annotation.getClass().getMethod("value").invoke(annotation)); + } catch (NoSuchMethodException e) { + // Not the annotation we're looking for + return Arrays.stream(new Enum[0]); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + + if (attributes.size() > 0) { + // Build method handle + try { + m.setAccessible(true); + var handle = MethodHandles.lookup().unreflect(m).bindTo(driver); + + for (var attribute : attributes) { + if (!handles.containsKey(attribute)) { + handles.put(attribute, new LinkedList<>()); + } + handles.get(attribute) + .add(new QueryHandle(handle, m.getAnnotation(Fallback.class), driverClass)); + } + } catch (IllegalAccessException e) { + throw new RuntimeException("Cannot access query method: " + m.getName()); + } + } + } + + driverClass = driverClass.getSuperclass(); + } + + // Reorder each stack + handles.values().forEach(Collections::sort); + } +} diff --git a/reference/src/main/java/oshi/driver/ExtensionDriver.java b/reference/src/main/java/oshi/driver/ExtensionDriver.java new file mode 100644 index 0000000..b237275 --- /dev/null +++ b/reference/src/main/java/oshi/driver/ExtensionDriver.java @@ -0,0 +1,12 @@ +package oshi.driver; + +/** + * A marker class for a driver that provides additional query methods to a + * {@link ComponentDriver}. + * + * @author cilki + * @since 5.0.0 + */ +public class ExtensionDriver { + +} diff --git a/reference/src/main/java/oshi/driver/Fallback.java b/reference/src/main/java/oshi/driver/Fallback.java new file mode 100644 index 0000000..d547643 --- /dev/null +++ b/reference/src/main/java/oshi/driver/Fallback.java @@ -0,0 +1,13 @@ +package oshi.driver; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface Fallback { + public Class value(); +} diff --git a/reference/src/main/java/oshi/driver/RequiresRoot.java b/reference/src/main/java/oshi/driver/RequiresRoot.java new file mode 100644 index 0000000..ed22113 --- /dev/null +++ b/reference/src/main/java/oshi/driver/RequiresRoot.java @@ -0,0 +1,12 @@ +package oshi.driver; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface RequiresRoot { +} diff --git a/reference/src/main/java/oshi/driver/SystemDriver.java b/reference/src/main/java/oshi/driver/SystemDriver.java new file mode 100644 index 0000000..0cf9726 --- /dev/null +++ b/reference/src/main/java/oshi/driver/SystemDriver.java @@ -0,0 +1,65 @@ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.MultiSystem; +import oshi.api.PlatformEnum; +import oshi.api.hardware.disk.Disk; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.nic.Nic; + +@SuppressWarnings("unchecked") +public class SystemDriver implements MultiSystem { + + private Object driver; + + public SystemDriver(PlatformEnum platform) { + switch (platform) { + case FREEBSD: + driver = new SystemDriverFreeBsd(); + break; + case LINUX: + driver = new SystemDriverLinux(); + break; + case MACOSX: + driver = new SystemDriverMac(); + break; + case SOLARIS: + driver = new SystemDriverSolaris(); + break; + case WINDOWS: + driver = new SystemDriverWindows(); + break; + default: + break; + } + } + + @Override + public Stream getNicStream() { + try { + return (Stream) driver.getClass().getMethod("getNicStream").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Stream getDiskStream() { + try { + return (Stream) driver.getClass().getMethod("getDiskStream").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Firmware getFirmware() { + try { + return (Firmware) driver.getClass().getMethod("getFirmware").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java b/reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java new file mode 100644 index 0000000..10c4105 --- /dev/null +++ b/reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java @@ -0,0 +1,30 @@ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.FreeBsdSystem; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.api.hardware.nic.NicFreeBsd; + +public class SystemDriverFreeBsd implements FreeBsdSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareFreeBsd getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/src/main/java/oshi/driver/SystemDriverLinux.java b/reference/src/main/java/oshi/driver/SystemDriverLinux.java new file mode 100644 index 0000000..82c86b1 --- /dev/null +++ b/reference/src/main/java/oshi/driver/SystemDriverLinux.java @@ -0,0 +1,93 @@ +package oshi.driver; + +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import oshi.api.LinuxSystem; +import oshi.api.hardware.disk.DiskContainerLinux; +import oshi.api.hardware.disk.DiskLinux; +import oshi.api.hardware.firmware.FirmwareContainerLinux; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.api.hardware.nic.NicContainerLinux; +import oshi.api.hardware.nic.NicLinux; +import oshi.driver.hardware.disk.DiskDriverLinux; +import oshi.driver.hardware.firmware.FirmwareDriverLinux; +import oshi.driver.hardware.nic.NicDriverJava; +import oshi.driver.hardware.nic.NicDriverLinux; +import oshi.old.Udev; + +public class SystemDriverLinux implements LinuxSystem { + + @Override + public Stream getNicStream() { + try { + return NetworkInterface.networkInterfaces().map(nif -> { + var container = new NicContainerLinux(); + container.name = nif.getName(); + var driver = new NicDriverLinux(container); + driver.register(new NicDriverJava(container, nif)); + + container.attach(driver); + return container; + }); + } catch (SocketException e) { + // No interfaces found or I/O error occurred + return Stream.empty(); + } + } + + @Override + public Stream getDiskStream() { + List results = new ArrayList<>(); + + Udev.UdevDevice device = null; + Udev.UdevListEntry entry; + Udev.UdevListEntry oldEntry; + + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevEnumerate enumerate = Udev.INSTANCE.udev_enumerate_new(handle); + Udev.INSTANCE.udev_enumerate_add_match_subsystem(enumerate, "block"); + Udev.INSTANCE.udev_enumerate_scan_devices(enumerate); + + entry = Udev.INSTANCE.udev_enumerate_get_list_entry(enumerate); + while (true) { + oldEntry = entry; + device = Udev.INSTANCE.udev_device_new_from_syspath(handle, Udev.INSTANCE.udev_list_entry_get_name(entry)); + if (device == null) { + break; + } + + // Ignore loopback and ram disks; do nothing + if (!Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/loop") + && !Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/ram")) { + if ("disk".equals(Udev.INSTANCE.udev_device_get_devtype(device))) { + var container = new DiskContainerLinux(); + container.name = Udev.INSTANCE.udev_list_entry_get_name(entry); + var driver = new DiskDriverLinux(container); + // TODO SMART extension + container.attach(driver); + + results.add(container); + } + } + + entry = Udev.INSTANCE.udev_list_entry_get_next(oldEntry); + Udev.INSTANCE.udev_device_unref(device); + } + + return results.stream(); + } + + @Override + public FirmwareLinux getFirmware() { + var container = new FirmwareContainerLinux(); + var driver = new FirmwareDriverLinux(container); + + container.attach(driver); + return container; + } + +} diff --git a/reference/src/main/java/oshi/driver/SystemDriverMac.java b/reference/src/main/java/oshi/driver/SystemDriverMac.java new file mode 100644 index 0000000..09b5352 --- /dev/null +++ b/reference/src/main/java/oshi/driver/SystemDriverMac.java @@ -0,0 +1,30 @@ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.MacSystem; +import oshi.api.hardware.disk.DiskMac; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.api.hardware.nic.NicMac; + +public class SystemDriverMac implements MacSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareMac getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/src/main/java/oshi/driver/SystemDriverSolaris.java b/reference/src/main/java/oshi/driver/SystemDriverSolaris.java new file mode 100644 index 0000000..f7d14f1 --- /dev/null +++ b/reference/src/main/java/oshi/driver/SystemDriverSolaris.java @@ -0,0 +1,30 @@ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.SolarisSystem; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.api.hardware.nic.NicSolaris; + +public class SystemDriverSolaris implements SolarisSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareSolaris getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/src/main/java/oshi/driver/SystemDriverWindows.java b/reference/src/main/java/oshi/driver/SystemDriverWindows.java new file mode 100644 index 0000000..5165c47 --- /dev/null +++ b/reference/src/main/java/oshi/driver/SystemDriverWindows.java @@ -0,0 +1,30 @@ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.WindowsSystem; +import oshi.api.hardware.disk.DiskWindows; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.api.hardware.nic.NicWindows; + +public class SystemDriverWindows implements WindowsSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareWindows getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java b/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java new file mode 100644 index 0000000..9db2bd5 --- /dev/null +++ b/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java @@ -0,0 +1,81 @@ +package oshi.driver.hardware.disk; + +import static oshi.api.hardware.disk.internal.DiskAttribute.MODEL; +import static oshi.api.hardware.disk.internal.DiskAttribute.NAME; +import static oshi.api.hardware.disk.internal.DiskAttribute.QUEUE_LENGTH; +import static oshi.api.hardware.disk.internal.DiskAttribute.READS; +import static oshi.api.hardware.disk.internal.DiskAttribute.READ_BYTES; +import static oshi.api.hardware.disk.internal.DiskAttribute.SERIAL; +import static oshi.api.hardware.disk.internal.DiskAttribute.SIZE; +import static oshi.api.hardware.disk.internal.DiskAttribute.TRANSFER_TIME; +import static oshi.api.hardware.disk.internal.DiskAttribute.WRITES; +import static oshi.api.hardware.disk.internal.DiskAttribute.WRITE_BYTES; + +import oshi.api.hardware.disk.DiskContainerLinux; +import oshi.api.hardware.disk.internal.DiskQuery; +import oshi.driver.ComponentDriver; +import oshi.old.ParseUtil; +import oshi.old.Udev; + +public class DiskDriverLinux extends ComponentDriver { + + private DiskContainerLinux container; + + public DiskDriverLinux(DiskContainerLinux container) { + this.container = container; + } + + /** + * The size of a logical sector in bytes. + */ + private static final int SECTOR_SIZE = 512; + + // Get a list of orders to pass to ParseUtil + private static final int[] UDEV_STAT_ORDERS = new int[] { + // + 0, // Reads + 2, // Read bytes + 4, // Writes + 6, // Write bytes + 8, // Queue length + 9 // Transfer time + }; + + // There are at least 11 elements in udev stat output. Some platforms have + // 12 but we want the last 11. ParseUtil works from the right + private static final int UDEV_STAT_LENGTH = 11; + + @DiskQuery({ MODEL, SERIAL, SIZE, NAME }) + private void diskInfo() { + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); + + container.model = Udev.INSTANCE.udev_device_get_property_value(device, "ID_MODEL"); + container.serial = Udev.INSTANCE.udev_device_get_property_value(device, "ID_SERIAL_SHORT"); + container.size = ParseUtil.parseLongOrDefault(Udev.INSTANCE.udev_device_get_sysattr_value(device, "size"), 0L) + * 512; + + Udev.INSTANCE.udev_device_unref(device); + Udev.INSTANCE.udev_unref(handle); + } + + @DiskQuery({ READS, READ_BYTES, WRITES, WRITE_BYTES, QUEUE_LENGTH, TRANSFER_TIME }) + private void diskStats() { + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); + + long[] deviceStats = ParseUtil.parseStringToLongArray( + Udev.INSTANCE.udev_device_get_sysattr_value(device, "stat"), UDEV_STAT_ORDERS, UDEV_STAT_LENGTH, ' '); + + container.reads = deviceStats[0]; + container.readBytes = deviceStats[1] * SECTOR_SIZE; + container.writes = deviceStats[2]; + container.writeBytes = deviceStats[3] * SECTOR_SIZE; + container.queueLength = deviceStats[4]; + container.transferTime = deviceStats[5]; + + Udev.INSTANCE.udev_device_unref(device); + Udev.INSTANCE.udev_unref(handle); + } + +} diff --git a/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java b/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java new file mode 100644 index 0000000..680d4a3 --- /dev/null +++ b/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java @@ -0,0 +1,45 @@ +package oshi.driver.hardware.disk; + +import static oshi.api.hardware.disk.internal.DiskAttribute.CALIBRATION_RETRIES; +import static oshi.api.hardware.disk.internal.DiskAttribute.CRC_ERRORS; +import static oshi.api.hardware.disk.internal.DiskAttribute.CURRENT_PENDING_SECTOR; +import static oshi.api.hardware.disk.internal.DiskAttribute.FIRMWARE_VERSION; +import static oshi.api.hardware.disk.internal.DiskAttribute.LOAD_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttribute.MODEL_FAMILY; +import static oshi.api.hardware.disk.internal.DiskAttribute.MULTIZONE_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttribute.OFFLINE_UNCORRECTABLE; +import static oshi.api.hardware.disk.internal.DiskAttribute.POWEROFF_RETRACTS; +import static oshi.api.hardware.disk.internal.DiskAttribute.POWER_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttribute.POWER_ON_TIME; +import static oshi.api.hardware.disk.internal.DiskAttribute.READ_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttribute.REALLOCATED_EVENTS; +import static oshi.api.hardware.disk.internal.DiskAttribute.REALLOCATED_SECTORS; +import static oshi.api.hardware.disk.internal.DiskAttribute.ROTATION_RATE; +import static oshi.api.hardware.disk.internal.DiskAttribute.SEEK_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttribute.SPIN_RETRIES; +import static oshi.api.hardware.disk.internal.DiskAttribute.SPIN_UP_TIME; +import static oshi.api.hardware.disk.internal.DiskAttribute.START_STOP_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttribute.TEMPERATURE; + +import oshi.api.hardware.disk.DiskContainerLinux; +import oshi.api.hardware.disk.internal.DiskQuery; +import oshi.driver.ExtensionDriver; +import oshi.old.ExecutingCommand; + +public class DiskDriverLinuxSMART extends ExtensionDriver { + + private DiskContainerLinux container; + + public DiskDriverLinuxSMART(DiskContainerLinux container) { + this.container = container; + } + + @DiskQuery({ MODEL_FAMILY, FIRMWARE_VERSION, ROTATION_RATE, READ_ERROR_RATE, SPIN_UP_TIME, START_STOP_CYCLES, + REALLOCATED_SECTORS, SEEK_ERROR_RATE, POWER_ON_TIME, SPIN_RETRIES, CALIBRATION_RETRIES, POWER_CYCLES, + POWEROFF_RETRACTS, LOAD_CYCLES, TEMPERATURE, REALLOCATED_EVENTS, CURRENT_PENDING_SECTOR, + OFFLINE_UNCORRECTABLE, CRC_ERRORS, MULTIZONE_ERROR_RATE }) + private void diskStats() { + // TODO parse command + ExecutingCommand.runNative("sudo smartctl --all " + container.name); + } +} diff --git a/reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java b/reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java new file mode 100644 index 0000000..95a1919 --- /dev/null +++ b/reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java @@ -0,0 +1,78 @@ +package oshi.driver.hardware.firmware; + +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.DESCRIPTION; +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.MANUFACTURER; +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.NAME; +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.RELEASE_DATE; +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.REVISION; +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.UEFI; +import static oshi.api.hardware.firmware.internal.FirmwareAttribute.VERSION; + +import oshi.api.hardware.firmware.FirmwareContainerLinux; +import oshi.api.hardware.firmware.internal.FirmwareQuery; +import oshi.driver.ComponentDriver; +import oshi.driver.RequiresRoot; +import oshi.old.ExecutingCommand; +import oshi.old.FileUtil; + +public class FirmwareDriverLinux extends ComponentDriver { + + private FirmwareContainerLinux container; + + public FirmwareDriverLinux(FirmwareContainerLinux container) { + this.container = container; + } + + private static final String SYSFS_SERIAL_PATH = "/sys/devices/virtual/dmi/id/"; + + @FirmwareQuery(NAME) + public void name() { + } + + @FirmwareQuery(MANUFACTURER) + private void manufacturer() { + container.manufacturer = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_vendor").trim(); + } + + @FirmwareQuery(DESCRIPTION) + private void description() { + container.description = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "modalias").trim(); + } + + @FirmwareQuery(VERSION) + private void version() { + container.version = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_version").trim(); + } + + @FirmwareQuery(RELEASE_DATE) + private void releaseDate() { + container.releaseDate = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_date").trim(); + } + + @RequiresRoot + @FirmwareQuery(REVISION) + private void revision() { + final String marker = "Bios Revision:"; + for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { + if (checkLine.contains(marker)) { + container.revision = checkLine.split(marker)[1].trim(); + return; + } + } + } + + @RequiresRoot + @FirmwareQuery(UEFI) + private void uefi() { + final String marker = "UEFI is supported"; + for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { + if (checkLine.contains(marker)) { + container.uefi = true; + return; + } + } + + container.uefi = false; + } + +} diff --git a/reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java b/reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java new file mode 100644 index 0000000..a60adf3 --- /dev/null +++ b/reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java @@ -0,0 +1,61 @@ +package oshi.driver.hardware.nic; + +import static oshi.api.hardware.nic.internal.NicAttribute.IPV4; +import static oshi.api.hardware.nic.internal.NicAttribute.IPV6; +import static oshi.api.hardware.nic.internal.NicAttribute.MAC; +import static oshi.api.hardware.nic.internal.NicAttribute.MTU; +import static oshi.api.hardware.nic.internal.NicAttribute.NAME; +import static oshi.api.hardware.nic.internal.NicAttribute.VIRTUAL; + +import java.net.NetworkInterface; +import java.net.SocketException; + +import oshi.api.hardware.nic.NicContainer; +import oshi.api.hardware.nic.internal.NicQuery; +import oshi.driver.ExtensionDriver; + +/** + * A driver that uses Java's built-in {@link NetworkInterface} class. + */ +public class NicDriverJava extends ExtensionDriver { + + protected NetworkInterface instance; + private NicContainer container; + + public NicDriverJava(NicContainer container, NetworkInterface instance) { + this.container = container; + this.instance = instance; + } + + @NicQuery(VIRTUAL) + private void virtual() { + container.virtual = instance.isVirtual(); + } + + @NicQuery(NAME) + private void name() { + container.name = instance.getName(); + } + + @NicQuery(MAC) + private void mac() throws SocketException { + } + + @NicQuery(IPV4) + private void ipv4() { + container.ipv4 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) + .filter(address -> !address.contains(":")).toArray(String[]::new); + } + + @NicQuery(IPV6) + private void ipv6() { + container.ipv6 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) + .filter(address -> address.contains(":")).toArray(String[]::new); + } + + @NicQuery(MTU) + private void mtu() throws SocketException { + container.mtu = instance.getMTU(); + } + +} diff --git a/reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java b/reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java new file mode 100644 index 0000000..1a575e2 --- /dev/null +++ b/reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java @@ -0,0 +1,150 @@ +package oshi.driver.hardware.nic; + +import static oshi.api.hardware.nic.internal.NicAttribute.BROADCAST; +import static oshi.api.hardware.nic.internal.NicAttribute.DEFAULT_GATEWAY; +import static oshi.api.hardware.nic.internal.NicAttribute.DESCRIPTION; +import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_LOOPBACK; +import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_MULTICAST; +import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_RUNNING; +import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_UP; +import static oshi.api.hardware.nic.internal.NicAttribute.LINK_SPEED; +import static oshi.api.hardware.nic.internal.NicAttribute.MTU; +import static oshi.api.hardware.nic.internal.NicAttribute.NETMASK; +import static oshi.api.hardware.nic.internal.NicAttribute.READ_BYTES; +import static oshi.api.hardware.nic.internal.NicAttribute.READ_DROPS; +import static oshi.api.hardware.nic.internal.NicAttribute.READ_ERRORS; +import static oshi.api.hardware.nic.internal.NicAttribute.READ_PACKETS; +import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_BYTES; +import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_COLLISIONS; +import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_DROPS; +import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_ERRORS; +import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_PACKETS; + +import oshi.api.hardware.nic.NicContainerLinux; +import oshi.api.hardware.nic.internal.NicQuery; +import oshi.driver.ComponentDriver; +import oshi.old.FileUtil; + +public class NicDriverLinux extends ComponentDriver { + + private NicContainerLinux container; + + public NicDriverLinux(NicContainerLinux container) { + this.container = container; + } + + @NicQuery(READ_BYTES) + private void readBytes() { + container.readBytes = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_bytes", container.name)); + } + + @NicQuery(WRITE_BYTES) + private void writeBytes() { + container.writeBytes = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_bytes", container.name)); + } + + @NicQuery(READ_PACKETS) + private void readPackets() { + container.readPackets = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_packets", container.name)); + } + + @NicQuery(WRITE_PACKETS) + private void writePackets() { + container.writePackets = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_packets", container.name)); + } + + @NicQuery(READ_ERRORS) + private void readErrors() { + container.readErrors = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_errors", container.name)); + } + + @NicQuery(WRITE_ERRORS) + private void writeErrors() { + container.writeErrors = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_errors", container.name)); + } + + @NicQuery(DESCRIPTION) + private void description() { + // TODO Auto-generated method stub + + } + + @NicQuery(BROADCAST) + private void broadcast() { + // TODO Auto-generated method stub + + } + + @NicQuery(NETMASK) + private void netmask() { + // TODO Auto-generated method stub + + } + + @NicQuery(READ_DROPS) + private void readDrops() { + container.readDrops = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_dropped", container.name)); + + } + + @NicQuery(WRITE_DROPS) + private void writeDrops() { + container.writeDrops = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_dropped", container.name)); + } + + @NicQuery(WRITE_COLLISIONS) + private void writeCollisions() { + container.writeCollisions = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/collisions", container.name)); + } + + @NicQuery(LINK_SPEED) + private void linkSpeed() { + container.linkSpeed = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/speed", container.name)); + } + + @NicQuery(DEFAULT_GATEWAY) + private void defaultGateway() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_UP) + private void flagUp() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_RUNNING) + private void flagRunning() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_LOOPBACK) + private void flagLoopback() { + // TODO Auto-generated method stub + + } + + @NicQuery(FLAG_MULTICAST) + private void flagMulticast() { + // TODO Auto-generated method stub + + } + + @NicQuery(MTU) + private void mac() { + container.mtu = FileUtil.getIntFromFile(String.format("/sys/class/net/%s/mtu", container.name)); + } + +} diff --git a/reference/src/main/java/oshi/example/DiskExample.java b/reference/src/main/java/oshi/example/DiskExample.java new file mode 100644 index 0000000..f710443 --- /dev/null +++ b/reference/src/main/java/oshi/example/DiskExample.java @@ -0,0 +1,17 @@ +package oshi.example; + +import oshi.api.OSHI; + +public class DiskExample { + public static void main(String[] args) { + + OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.querySize()); + System.out.println("\tRead bytes: " + disk.queryReadBytes()); + System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); + System.out.println("\tQueue length: " + disk.queryQueueLength()); + System.out.println("\tTransfer time: " + disk.queryTransferTime()); + }); + } +} diff --git a/reference/src/main/java/oshi/example/FirmwareExample.java b/reference/src/main/java/oshi/example/FirmwareExample.java new file mode 100644 index 0000000..f4c78bf --- /dev/null +++ b/reference/src/main/java/oshi/example/FirmwareExample.java @@ -0,0 +1,21 @@ +package oshi.example; + +import oshi.api.OSHI; + +public class FirmwareExample { + + public static void main(String[] args) { + + var firmware = OSHI.getSystem().getFirmware(); + System.out.println("=== CrossPlatform Firmware ==="); + System.out.println("Name: " + firmware.getName()); + System.out.println("Description: " + firmware.getDescription()); + System.out.println("Version: " + firmware.getVersion()); + System.out.println("Revision: " + firmware.getRevision()); + System.out.println("Release: " + firmware.getReleaseDate()); + + var linuxFirmware = OSHI.getLinuxSystem().getFirmware(); + System.out.println("=== Linux Firmware ==="); + System.out.println("UEFI support: " + linuxFirmware.getUefi()); + } +} diff --git a/reference/src/main/java/oshi/example/NicExample.java b/reference/src/main/java/oshi/example/NicExample.java new file mode 100644 index 0000000..b6b7217 --- /dev/null +++ b/reference/src/main/java/oshi/example/NicExample.java @@ -0,0 +1,22 @@ +package oshi.example; + +import java.util.Arrays; + +import oshi.api.OSHI; + +public class NicExample { + + public static void main(String[] args) throws Exception { + + OSHI.getLinuxSystem().getNicStream().forEach(nic -> { + System.out.println("NIC: " + nic.getName()); + System.out.println("\tReadBytes: " + nic.queryReadBytes()); + System.out.println("\tWriteBytes: " + nic.queryWriteBytes()); + System.out.println("\tMTU: " + nic.queryMtu()); + System.out.println("\tIPv4: " + Arrays.toString(nic.queryIpv4())); + System.out.println("\tLink Speed: " + nic.queryLinkSpeed()); + }); + + } + +} diff --git a/reference/src/main/java/oshi/old/ExecutingCommand.java b/reference/src/main/java/oshi/old/ExecutingCommand.java new file mode 100644 index 0000000..b6f90ef --- /dev/null +++ b/reference/src/main/java/oshi/old/ExecutingCommand.java @@ -0,0 +1,136 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A class for executing on the command line and returning the result of + * execution. + * + * @author alessandro[at]perucchi[dot]org + */ +public class ExecutingCommand { + + private static final Logger LOG = LoggerFactory.getLogger(ExecutingCommand.class); + + private ExecutingCommand() { + } + + /** + * Executes a command on the native command line and returns the result. + * This is a convenience method to call {@link Runtime#exec(String)} and + * capture the resulting output in a list of Strings. On Windows, built-in + * commands not associated with an executable program may require + * {@code cmd.exe /c} to be prepended to the command. + * + * @param cmdToRun + * Command to run + * @return A list of Strings representing the result of the command, or + * empty string if the command failed + */ + public static List runNative(String cmdToRun) { + String[] cmd = cmdToRun.split(" "); + return runNative(cmd); + } + + /** + * Executes a command on the native command line and returns the result line + * by line. This is a convenience method to call + * {@link Runtime#exec(String[])} and capture the resulting output in a list + * of Strings. On Windows, built-in commands not associated with an + * executable program may require the strings {@code cmd.exe} and {@code /c} + * to be prepended to the array. + * + * @param cmdToRunWithArgs + * Command to run and args, in an array + * @return A list of Strings representing the result of the command, or + * empty string if the command failed + */ + public static List runNative(String[] cmdToRunWithArgs) { + Process p = null; + try { + p = Runtime.getRuntime().exec(cmdToRunWithArgs); + } catch (SecurityException | IOException e) { + LOG.trace("Couldn't run command {}: {}", Arrays.toString(cmdToRunWithArgs), e); + return new ArrayList<>(0); + } + + ArrayList sa = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))) { + String line; + while ((line = reader.readLine()) != null) { + sa.add(line); + } + p.waitFor(); + } catch (IOException e) { + LOG.trace("Problem reading output from {}: {}", Arrays.toString(cmdToRunWithArgs), e); + return new ArrayList<>(0); + } catch (InterruptedException ie) { + LOG.trace("Interrupted while reading output from {}: {}", Arrays.toString(cmdToRunWithArgs), ie); + Thread.currentThread().interrupt(); + } + return sa; + } + + /** + * Return first line of response for selected command. + * + * @param cmd2launch + * String command to be launched + * @return String or empty string if command failed + */ + public static String getFirstAnswer(String cmd2launch) { + return getAnswerAt(cmd2launch, 0); + } + + /** + * Return response on selected line index (0-based) after running selected + * command. + * + * @param cmd2launch + * String command to be launched + * @param answerIdx + * int index of line in response of the command + * @return String whole line in response or empty string if invalid index or + * running of command fails + */ + public static String getAnswerAt(String cmd2launch, int answerIdx) { + List sa = ExecutingCommand.runNative(cmd2launch); + + if (answerIdx >= 0 && answerIdx < sa.size()) { + return sa.get(answerIdx); + } + return ""; + } + +} diff --git a/reference/src/main/java/oshi/old/FileUtil.java b/reference/src/main/java/oshi/old/FileUtil.java new file mode 100644 index 0000000..75da965 --- /dev/null +++ b/reference/src/main/java/oshi/old/FileUtil.java @@ -0,0 +1,202 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * File reading methods + * + * @author widdis[at]gmail[dot]com + */ +public class FileUtil { + private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class); + + private FileUtil() { + } + + /** + * Read an entire file at one time. Intended primarily for Linux /proc + * filesystem to avoid recalculating file contents on iterative reads. + * + * @param filename The file to read + * + * @return A list of Strings representing each line of the file, or an empty + * list if file could not be read or is empty + */ + public static List readFile(String filename) { + return readFile(filename, true); + } + + /** + * Read an entire file at one time. Intended primarily for Linux /proc + * filesystem to avoid recalculating file contents on iterative reads. + * + * @param filename The file to read + * @param reportError Whether to log errors reading the file + * + * @return A list of Strings representing each line of the file, or an empty + * list if file could not be read or is empty + */ + public static List readFile(String filename, boolean reportError) { + if (new File(filename).canRead()) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + try { + return Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8); + } catch (IOException e) { + if (reportError) { + LOG.error("Error reading file {}. {}", filename, e); + } + } + } else if (reportError) { + LOG.warn("File not found or not readable: {}", filename); + } + return new ArrayList<>(); + } + + /** + * Read a file and return the long value contained therein. Intended primarily + * for Linux /sys filesystem + * + * @param filename The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static long getLongFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return ParseUtil.parseLongOrDefault(read.get(0), 0L); + } + return 0L; + } + + /** + * Read a file and return the unsigned long value contained therein as a long. + * Intended primarily for Linux /sys filesystem + * + * @param filename The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static long getUnsignedLongFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return ParseUtil.parseUnsignedLongOrDefault(read.get(0), 0L); + } + return 0L; + } + + /** + * Read a file and return the int value contained therein. Intended primarily + * for Linux /sys filesystem + * + * @param filename The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static int getIntFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + try { + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return Integer.parseInt(read.get(0)); + } + } catch (NumberFormatException ex) { + LOG.warn("Unable to read value from {}. {}", filename, ex); + } + return 0; + } + + /** + * Read a file and return the String value contained therein. Intended primarily + * for Linux /sys filesystem + * + * @param filename The file to read + * @return The value contained in the file, if any; otherwise empty string + */ + public static String getStringFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return read.get(0); + } + return ""; + } + + /** + * Read a file and return a map of string keys to string values contained + * therein. Intended primarily for Linux /proc/[pid]/io + * + * @param filename The file to read + * @param separator Characters in each line of the file that separate the key + * and the value + * @return The map contained in the file, if any; otherwise empty map + */ + public static Map getKeyValueMapFromFile(String filename, String separator) { + Map map = new HashMap<>(); + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List lines = FileUtil.readFile(filename, false); + for (String line : lines) { + String[] parts = line.split(separator); + if (parts.length == 2) { + map.put(parts[0], parts[1].trim()); + } + } + return map; + } +} diff --git a/reference/src/main/java/oshi/old/ParseUtil.java b/reference/src/main/java/oshi/old/ParseUtil.java new file mode 100644 index 0000000..b272b94 --- /dev/null +++ b/reference/src/main/java/oshi/old/ParseUtil.java @@ -0,0 +1,766 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * String parsing utility. + * + * @author alessio.fachechi[at]gmail[dot]com + */ +public class ParseUtil { + + private static final Logger LOG = LoggerFactory.getLogger(ParseUtil.class); + + private static final String DEFAULT_LOG_MSG = "{} didn't parse. Returning default. {}"; + /* + * Used for matching + */ + private static final Pattern HERTZ_PATTERN = Pattern.compile("(\\d+(.\\d+)?) ?([kMGT]?Hz).*"); + + /* + * Used to check validity of a hexadecimal string + */ + private static final Pattern VALID_HEX = Pattern.compile("[0-9a-fA-F]+"); + + /* + * Pattern for [dd-[hh:[mm:ss]]] + */ + private static final Pattern DHMS = Pattern.compile("(?:(\\d+)-)?(?:(\\d+):)?(\\d+):(\\d+)(?:\\.(\\d+))?"); + + /* + * Pattern for a UUID + */ + private static final Pattern UUID_PATTERN = Pattern + .compile(".*([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}).*"); + + /* + * Hertz related variables. + */ + private static final String HZ = "Hz"; + private static final String KHZ = "kHz"; + private static final String MHZ = "MHz"; + private static final String GHZ = "GHz"; + private static final String THZ = "THz"; + private static final String PHZ = "PHz"; + + private static final Map multipliers; + + // PDH timestamps are 1601 epoch, local time + // Constants to convert to UTC millis + private static final long EPOCH_DIFF = 11644473600000L; + private static final int TZ_OFFSET = TimeZone.getDefault().getOffset(System.currentTimeMillis()); + + public static final Pattern whitespacesColonWhitespace = Pattern.compile("\\s+:\\s"); + + public static final Pattern whitespaces = Pattern.compile("\\s+"); + + public static final Pattern notDigits = Pattern.compile("[^0-9]+"); + + public static final Pattern startWithNotDigits = Pattern.compile("^[^0-9]*"); + + static { + multipliers = new HashMap<>(); + multipliers.put(HZ, 1L); + multipliers.put(KHZ, 1_000L); + multipliers.put(MHZ, 1_000_000L); + multipliers.put(GHZ, 1_000_000_000L); + multipliers.put(THZ, 1_000_000_000_000L); + multipliers.put(PHZ, 1_000_000_000_000_000L); + } + + // Fast decimal exponentiation: pow(10,y) --> POWERS_OF_10[y] + private static final long[] POWERS_OF_TEN = { 1L, 10L, 100L, 1_000L, 10_000L, 100_000L, 1_000_000L, 10_000_000L, + 100_000_000L, 1_000_000_000L, 10_000_000_000L, 100_000_000_000L, 1_000_000_000_000L, 10_000_000_000_000L, + 100_000_000_000_000L, 1_000_000_000_000_000L, 10_000_000_000_000_000L, 100_000_000_000_000_000L, + 1_000_000_000_000_000_000L }; + + // Fast hex character lookup + private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); + + private ParseUtil() { + } + + /** + * Parse hertz from a string, eg. "2.00MHz" in 2000000L. + * + * @param hertz + * Hertz size. + * @return {@link Long} Hertz value or -1 if not parsable. + */ + public static long parseHertz(String hertz) { + Matcher matcher = HERTZ_PATTERN.matcher(hertz.trim()); + if (matcher.find() && matcher.groupCount() == 3) { + // Regexp enforces #(.#) format so no test for NFE required + double value = Double.valueOf(matcher.group(1)) * multipliers.getOrDefault(matcher.group(3), -1L); + if (value >= 0d) { + return (long) value; + } + } + return -1L; + } + + /** + * Parse the last element of a space-delimited string to a value + * + * @param s + * The string to parse + * @param i + * Default integer if not parsable + * @return value or the given default if not parsable + */ + public static int parseLastInt(String s, int i) { + try { + return Integer.parseInt(parseLastString(s)); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return i; + } + } + + /** + * Parse the last element of a space-delimited string to a value + * + * @param s + * The string to parse + * @param li + * Default long integer if not parsable + * @return value or the given default if not parsable + */ + public static long parseLastLong(String s, long li) { + try { + return Long.parseLong(parseLastString(s)); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return li; + } + } + + /** + * Parse the last element of a space-delimited string to a value + * + * @param s + * The string to parse + * @param d + * Default double if not parsable + * @return value or the given default if not parsable + */ + public static double parseLastDouble(String s, double d) { + try { + return Double.parseDouble(parseLastString(s)); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return d; + } + } + + /** + * Parse the last element of a space-delimited string to a string + * + * @param s + * The string to parse + * @return last space-delimited element + */ + public static String parseLastString(String s) { + String[] ss = whitespaces.split(s); + if (ss.length < 1) { + return s; + } else { + return ss[ss.length - 1]; + } + } + + /** + * Parse a byte aray into a string of hexadecimal digits including leading + * zeros + * + * @param bytes + * The byte array to represent + * @return A string of hex characters corresponding to the bytes. The string + * is upper case. + */ + public static String byteArrayToHexString(byte[] bytes) { + // Solution copied from https://stackoverflow.com/questions/9655181 + char[] hexChars = new char[bytes.length * 2]; + for (int j = 0; j < bytes.length; j++) { + int v = bytes[j] & 0xFF; + hexChars[j * 2] = HEX_ARRAY[v >>> 4]; + hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; + } + return new String(hexChars); + } + + /** + * Parse a string of hexadecimal digits into a byte array + * + * @param digits + * The string to be parsed + * @return a byte array with each pair of characters converted to a byte, or + * empty array if the string is not valid hex + */ + public static byte[] hexStringToByteArray(String digits) { + int len = digits.length(); + // Check if string is valid hex + if (!VALID_HEX.matcher(digits).matches() || (len & 0x1) != 0) { + LOG.warn("Invalid hexadecimal string: {}", digits); + return new byte[0]; + } + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) (Character.digit(digits.charAt(i), 16) << 4 + | Character.digit(digits.charAt(i + 1), 16)); + } + return data; + } + + /** + * Parse a human readable string into a byte array, truncating or padding + * with zeros (if necessary) so the array has the specified length. + * + * @param text + * The string to be parsed + * @param length + * Length of the returned array. + * @return A byte array of specified length, with each of the first length + * characters converted to a byte. If length is longer than the + * provided string length, will be filled with zeroes. + */ + public static byte[] stringToByteArray(String text, int length) { + return Arrays.copyOf(text.getBytes(), length); + } + + /** + * Convert a long value to a byte array using Big Endian, truncating or + * padding with zeros (if necessary) so the array has the specified length. + * + * @param value + * The value to be converted + * @param valueSize + * Number of bytes representing the value + * @param length + * Number of bytes to return + * @return A byte array of specified length representing the long in the + * first valueSize bytes + */ + public static byte[] longToByteArray(long value, int valueSize, int length) { + long val = value; + // Convert the long to 8-byte BE representation + byte[] b = new byte[8]; + for (int i = 7; i >= 0 && val != 0L; i--) { + b[i] = (byte) val; + val >>>= 8; + } + // Then copy the rightmost valueSize bytes + // e.g., for an integer we want rightmost 4 bytes + return Arrays.copyOfRange(b, 8 - valueSize, 8 + length - valueSize); + } + + /** + * Convert a string to an integer representation. + * + * @param str + * A human readable ASCII string + * @param size + * Number of characters to convert to the long. May not exceed 8. + * @return An integer representing the string where each character is + * treated as a byte + */ + public static long strToLong(String str, int size) { + return byteArrayToLong(str.getBytes(StandardCharsets.US_ASCII), size); + } + + /** + * Convert a byte array to its integer representation. + * + * @param bytes + * An array of bytes no smaller than the size to be converted + * @param size + * Number of bytes to convert to the long. May not exceed 8. + * @return An integer representing the byte array as a 64-bit number + */ + public static long byteArrayToLong(byte[] bytes, int size) { + if (size > 8) { + throw new IllegalArgumentException("Can't convert more than 8 bytes."); + } + if (size > bytes.length) { + throw new IllegalArgumentException("Size can't be larger than array length."); + } + long total = 0L; + for (int i = 0; i < size; i++) { + total = total << 8 | bytes[i] & 0xff; + } + return total; + } + + /** + * Convert a byte array to its floating point representation. + * + * @param bytes + * An array of bytes no smaller than the size to be converted + * @param size + * Number of bytes to convert to the float. May not exceed 8. + * @param fpBits + * Number of bits representing the decimal + * @return A float; the integer portion representing the byte array as an + * integer shifted by the bits specified in fpBits; with the + * remaining bits used as a decimal + */ + public static float byteArrayToFloat(byte[] bytes, int size, int fpBits) { + return byteArrayToLong(bytes, size) / (float) (1 << fpBits); + } + + /** + * Convert an unsigned integer to a long value. The method assumes that all + * bits in the specified integer value are 'data' bits, including the + * most-significant bit which Java normally considers a sign bit. The method + * must be used only when it is certain that the integer value represents an + * unsigned integer, for example when the integer is returned by JNA library + * in a structure which holds unsigned integers. + * + * @param unsignedValue + * The unsigned integer value to convert. + * @return The unsigned integer value widened to a long. + */ + public static long unsignedIntToLong(int unsignedValue) { + // use standard Java widening conversion to long which does + // sign-extension, + // then drop any copies of the sign bit, to prevent the value being + // considered a negative one by Java if it is set + long longValue = unsignedValue; + return longValue & 0xffffffffL; + } + + /** + * Convert an unsigned long to a signed long value by stripping the sign + * bit. This method "rolls over" long values greater than the max value but + * ensures the result is never negative. + * + * @param unsignedValue + * The unsigned long value to convert. + * @return The signed long value. + */ + public static long unsignedLongToSignedLong(long unsignedValue) { + return unsignedValue & 0x7fffffff_ffffffffL; + } + + /** + * Parses a string of hex digits to a string where each pair of hex digits + * represents an ASCII character + * + * @param hexString + * A sequence of hex digits + * @return The corresponding string if valid hex; otherwise the original + * hexString + */ + public static String hexStringToString(String hexString) { + // Odd length strings won't parse, return + if (hexString.length() % 2 > 0) { + return hexString; + } + int charAsInt; + StringBuilder sb = new StringBuilder(); + try { + for (int pos = 0; pos < hexString.length(); pos += 2) { + charAsInt = Integer.parseInt(hexString.substring(pos, pos + 2), 16); + if (charAsInt < 32 || charAsInt > 127) { + return hexString; + } + sb.append((char) charAsInt); + } + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, hexString, e); + // Hex failed to parse, just return the existing string + return hexString; + } + return sb.toString(); + } + + /** + * Attempts to parse a string to an int. If it fails, returns the default + * + * @param s + * The string to parse + * @param defaultInt + * The value to return if parsing fails + * @return The parsed int, or the default if parsing failed + */ + public static int parseIntOrDefault(String s, int defaultInt) { + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultInt; + } + } + + /** + * Attempts to parse a string to a long. If it fails, returns the default + * + * @param s + * The string to parse + * @param defaultLong + * The value to return if parsing fails + * @return The parsed long, or the default if parsing failed + */ + public static long parseLongOrDefault(String s, long defaultLong) { + try { + return Long.parseLong(s); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultLong; + } + } + + /** + * Attempts to parse a string to an "unsigned" long. If it fails, returns + * the default + * + * @param s + * The string to parse + * @param defaultLong + * The value to return if parsing fails + * @return The parsed long containing the same 64 bits that an unsigned long + * would contain (which may produce a negative value) + */ + public static long parseUnsignedLongOrDefault(String s, long defaultLong) { + try { + return new BigInteger(s).longValue(); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultLong; + } + } + + /** + * Attempts to parse a string to a double. If it fails, returns the default + * + * @param s + * The string to parse + * @param defaultDouble + * The value to return if parsing fails + * @return The parsed double, or the default if parsing failed + */ + public static double parseDoubleOrDefault(String s, double defaultDouble) { + try { + return Double.parseDouble(s); + } catch (NumberFormatException e) { + LOG.trace(DEFAULT_LOG_MSG, s, e); + return defaultDouble; + } + } + + /** + * Attempts to parse a string of the form [DD-[hh:]]mm:ss[.ddd] to a number + * of milliseconds. If it fails, returns the default. + * + * @param s + * The string to parse + * @param defaultLong + * The value to return if parsing fails + * @return The parsed number of seconds, or the default if parsing fails + */ + public static long parseDHMSOrDefault(String s, long defaultLong) { + Matcher m = DHMS.matcher(s); + if (m.matches()) { + long milliseconds = 0L; + if (m.group(1) != null) { + milliseconds += parseLongOrDefault(m.group(1), 0L) * 86400000L; + } + if (m.group(2) != null) { + milliseconds += parseLongOrDefault(m.group(2), 0L) * 3600000L; + } + milliseconds += parseLongOrDefault(m.group(3), 0L) * 60000L; + milliseconds += parseLongOrDefault(m.group(4), 0L) * 1000L; + milliseconds += (long) (1000 * parseDoubleOrDefault("0." + m.group(5), 0d)); + return milliseconds; + } + return defaultLong; + } + + /** + * Attempts to parse a UUID. If it fails, returns the default. + * + * @param s + * The string to parse + * @param defaultStr + * The value to return if parsing fails + * @return The parsed UUID, or the default if parsing fails + */ + public static String parseUuidOrDefault(String s, String defaultStr) { + Matcher m = UUID_PATTERN.matcher(s.toLowerCase()); + if (m.matches()) { + return m.group(1); + } + return defaultStr; + } + + /** + * Parses a string key = 'value' (string) + * + * @param line + * The entire string + * @return the value contained between single tick marks + */ + public static String getSingleQuoteStringValue(String line) { + return getStringBetween(line, '\''); + } + + /** + * Parse a string key = "value" (string) + * + * @param line + * the entire string + * @return the value contained between double tick marks + */ + public static String getDoubleQuoteStringValue(String line) { + return getStringBetween(line, '"'); + } + + /** + * Gets a value between two characters having multiple same characters + * between them. Examples : + *
    + *
  • "name = 'James Gosling's Java'" returns "James Gosling's Java"
  • + *
  • "pci.name = 'Realtek AC'97 Audio Device'" returns "Realtek AC'97 + * Audio Device"
  • + *
+ * + * @param line + * The "key-value" pair line. + * @param c + * The Trailing And Leading characters of the string line + * @return : The value having the characters between them. + */ + public static String getStringBetween(String line, char c) { + int firstOcc = line.indexOf(c); + if (firstOcc < 0) { + return ""; + } + return line.substring(firstOcc + 1, line.lastIndexOf(c)).trim(); + } + + /** + * Parses a string such as "10.12.2" or "key = 1 (0x1) (int)" to find the + * integer value of the first set of one or more consecutive digits + * + * @param line + * The entire string + * @return the value of first integer if any; 0 otherwise + */ + public static int getFirstIntValue(String line) { + return getNthIntValue(line, 1); + } + + /** + * Parses a string such as "10.12.2" or "key = 1 (0x1) (int)" to find the + * integer value of the nth set of one or more consecutive digits + * + * @param line + * The entire string + * @param n + * Which set of integers to return + * @return the value of nth integer if any; 0 otherwise + */ + public static int getNthIntValue(String line, int n) { + // Split the string by non-digits, + String[] split = notDigits.split(startWithNotDigits.matcher(line).replaceFirst("")); + if (split.length >= n) { + return parseIntOrDefault(split[n - 1], 0); + } + return 0; + } + + /** + * Removes all matching sub strings from the string. More efficient than + * regexp. + * + * @param original + * source String to remove from + * @param toRemove + * the sub string to be removed + * @return The string with all matching substrings removed + */ + public static String removeMatchingString(final String original, final String toRemove) { + if (original == null || original.isEmpty() || toRemove == null || toRemove.isEmpty()) { + return original; + } + + int matchIndex = original.indexOf(toRemove, 0); + if (matchIndex == -1) { + return original; + } + + StringBuilder buffer = new StringBuilder(original.length() - toRemove.length()); + int currIndex = 0; + do { + buffer.append(original.substring(currIndex, matchIndex)); + currIndex = matchIndex + toRemove.length(); + matchIndex = original.indexOf(toRemove, currIndex); + } while (matchIndex != -1); + + buffer.append(original.substring(currIndex)); + return buffer.toString(); + } + + /** + * Parses a delimited string to an array of longs. Optimized for processing + * predictable-length arrays such as outputs of reliably formatted Linux + * proc or sys filesystem, minimizing new object creation. Users should + * perform other sanity checks of data. + * + * The indices parameters are referenced assuming the length as specified, + * and leading characters are ignored. For example, if the string is "foo 12 + * 34 5" and the length is 3, then index 0 is 12, index 1 is 34, and index 2 + * is 5. + * + * @param s + * The string to parse + * @param indices + * An array indicating which indexes should be populated in the + * final array; other values will be skipped. This idex is + * zero-referenced assuming the rightmost delimited fields of the + * string contain the array. + * @param length + * The total number of elements in the string array. It is + * permissible for the string to have more elements than this; + * leading elements will be ignored. + * @param delimiter + * The character to delimit by + * @return If successful, an array of parsed longs. If parsing errors + * occurred, will be an array of zeros. + */ + public static long[] parseStringToLongArray(String s, int[] indices, int length, char delimiter) { + long[] parsed = new long[indices.length]; + // Iterate from right-to-left of String + // Fill right to left of result array using index array + int charIndex = s.length() - 1; + int parsedIndex = indices.length - 1; + int stringIndex = length - 1; + + int power = 0; + int c; + boolean delimCurrent = false; + while (charIndex > 0 && parsedIndex >= 0) { + c = s.charAt(charIndex--); + if (c == delimiter) { + if (!delimCurrent) { + power = 0; + if (indices[parsedIndex] == stringIndex--) { + parsedIndex--; + } + delimCurrent = true; + } + } else if (indices[parsedIndex] != stringIndex || c == '+') { + // Doesn't impact parsing, ignore + delimCurrent = false; + } else if (c >= '0' && c <= '9') { + if (power > 18) { + LOG.error("Number is too big for a long parsing string '{}' to long array", s); + return new long[indices.length]; + } + parsed[parsedIndex] += (c - '0') * ParseUtil.POWERS_OF_TEN[power++]; + delimCurrent = false; + } else if (c == '-') { + parsed[parsedIndex] *= -1L; + delimCurrent = false; + } else { + // error on everything else + LOG.error("Illegal character parsing string '{}' to long array: {}", s, s.charAt(charIndex)); + return new long[indices.length]; + } + } + if (parsedIndex > 0) { + LOG.error("Not enough fields in string '{}' parsing to long array: {}", s, indices.length - parsedIndex); + return new long[indices.length]; + } + return parsed; + } + + /** + * Get a String in a line of text between two marker strings + * + * @param text + * Text to search for match + * @param before + * Start matching after this text + * @param after + * End matching before this text + * @return Text between the strings before and after, or empty string if + * either marker does not exist + */ + public static String getTextBetweenStrings(String text, String before, String after) { + + String result = ""; + + if (text.indexOf(before) >= 0 && text.indexOf(after) >= 0) { + result = text.substring(text.indexOf(before) + before.length(), text.length()); + result = result.substring(0, result.indexOf(after)); + } + return result; + } + + /** + * Convert a long representing filetime (100-ns since 1601 epoch) to ms + * since 1970 epoch + * + * @param filetime + * A 64-bit value equivalent to FILETIME + * @param local + * True if converting from a local filetime (PDH counter); false + * if already UTC (WMI PerfRawData classes) + * @return Equivalent milliseconds since the epoch + */ + public static long filetimeToUtcMs(long filetime, boolean local) { + return filetime / 10000L - EPOCH_DIFF - (local ? TZ_OFFSET : 0L); + } + + /** + * Parse a date in MM-DD-YYYY or MM/DD/YYYY to YYYY-MM-DD + * + * @param dateString + * The date in MM DD YYYY format + * @return The date in ISO YYYY-MM-DD format if parseable, or the original + * string + */ + public static String parseMmDdYyyyToYyyyMmDD(String dateString) { + try { + // Date is MM-DD-YYYY, convert to YYYY-MM-DD + return String.format("%s-%s-%s", dateString.substring(6, 10), dateString.substring(0, 2), + dateString.substring(3, 5)); + } catch (StringIndexOutOfBoundsException e) { + return dateString; + } + } +} diff --git a/reference/src/main/java/oshi/old/Udev.java b/reference/src/main/java/oshi/old/Udev.java new file mode 100644 index 0000000..2807d93 --- /dev/null +++ b/reference/src/main/java/oshi/old/Udev.java @@ -0,0 +1,120 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import com.sun.jna.Library; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.PointerType; + +/** + * Interface for talking with Udev. + * + * @author enrico[dot]bianchi[at]gmail[dot]com + */ +public interface Udev extends Library { + + Udev INSTANCE = Native.load("udev", Udev.class); + + final class UdevHandle extends PointerType { + + public UdevHandle(Pointer address) { + super(address); + } + + public UdevHandle() { + super(); + } + } + + final class UdevDevice extends PointerType { + + public UdevDevice(Pointer address) { + super(address); + } + + public UdevDevice() { + super(); + } + } + + final class UdevEnumerate extends PointerType { + + public UdevEnumerate(Pointer address) { + super(address); + } + + public UdevEnumerate() { + super(); + } + } + + final class UdevListEntry extends PointerType { + + public UdevListEntry(Pointer address) { + super(address); + } + + public UdevListEntry() { + super(); + } + } + + Udev.UdevHandle udev_new(); + + void udev_unref(Udev.UdevHandle udev); + + void udev_device_unref(Udev.UdevDevice udev_device); + + void udev_enumerate_unref(Udev.UdevEnumerate udev_enumerate); + + Udev.UdevEnumerate udev_enumerate_new(Udev.UdevHandle udev); + + Udev.UdevDevice udev_device_get_parent_with_subsystem_devtype(Udev.UdevDevice udev_device, String subsystem, + String devtype); + + Udev.UdevDevice udev_device_new_from_syspath(Udev.UdevHandle udev, String syspath); + + Udev.UdevListEntry udev_list_entry_get_next(Udev.UdevListEntry list_entry); + + String udev_device_get_sysattr_value(Udev.UdevDevice udev_device, String sysattr); + + int udev_enumerate_add_match_subsystem(Udev.UdevEnumerate udev_enumerate, String subsystem); + + int udev_enumerate_scan_devices(Udev.UdevEnumerate udev_enumerate); + + Udev.UdevListEntry udev_enumerate_get_list_entry(Udev.UdevEnumerate udev_enumerate); + + String udev_list_entry_get_name(Udev.UdevListEntry list_entry); + + String udev_device_get_devtype(Udev.UdevDevice udev_device); + + String udev_device_get_devnode(Udev.UdevDevice udev_device); + + String udev_device_get_syspath(Udev.UdevDevice udev_device); + + String udev_device_get_property_value(Udev.UdevDevice udev_device, String key); + + String udev_device_get_sysname(UdevDevice udev_device); +} diff --git a/reference/src/main/java/oshi/old/WmiUtil.java b/reference/src/main/java/oshi/old/WmiUtil.java new file mode 100644 index 0000000..4c08c48 --- /dev/null +++ b/reference/src/main/java/oshi/old/WmiUtil.java @@ -0,0 +1,296 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import com.sun.jna.platform.win32.Variant; // NOSONAR +import com.sun.jna.platform.win32.COM.Wbemcli; +import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiQuery; +import com.sun.jna.platform.win32.COM.WbemcliUtil.WmiResult; + +/** + * Helper class for WMI + * + * @author widdis[at]gmail[dot]com + */ +public class WmiUtil { + + // Not a built in namespace, failed connections are normal and don't need + // error logging + public static final String OHM_NAMESPACE = "ROOT\\OpenHardwareMonitor"; + + private static final String CLASS_CAST_MSG = "%s is not a %s type. CIM Type is %d and VT type is %d"; + + /** + * Private constructor so this class can't be instantiated from the outside. + */ + private WmiUtil() { + } + + /** + * Translate a WmiQuery to the actual query string + * + * @param + * The properties enum + * @param query + * The WmiQuery object + * @return The string that is queried in WMI + */ + public static > String queryToString(WmiQuery query) { + T[] props = query.getPropertyEnum().getEnumConstants(); + StringBuilder sb = new StringBuilder("SELECT "); + sb.append(props[0].name()); + for (int i = 1; i < props.length; i++) { + sb.append(',').append(props[i].name()); + } + sb.append(" FROM ").append(query.getWmiClassName()); + return sb.toString(); + } + + /** + * Gets a String value from a WmiResult + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, an empty-string otherwise + */ + public static > String getString(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_STRING) { + return getStr(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "String", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Date value from a WmiResult as a String + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, an empty-string otherwise + */ + public static > String getDateString(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_DATETIME) { + String date = getStr(result, property, index); + return date.substring(0, 4) + '-' + date.substring(4, 6) + '-' + date.substring(6, 8); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "DateTime", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Reference value from a WmiResult as a String + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, an empty-string otherwise + */ + public static > String getRefString(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_REFERENCE) { + return getStr(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "Reference", + result.getCIMType(property), result.getVtType(property))); + } + + private static > String getStr(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return ""; + } else if (result.getVtType(property) == Variant.VT_BSTR) { + return (String) o; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "String-mapped", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Uint64 value from a WmiResult (parsing the String). Note that + * while the CIM type is unsigned, the return type is signed and the parsing + * will exclude any return values above Long.MAX_VALUE. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null and parseable as a long, 0 otherwise + */ + public static > long getUint64(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return 0L; + } else if (result.getCIMType(property) == Wbemcli.CIM_UINT64 && result.getVtType(property) == Variant.VT_BSTR) { + return ParseUtil.parseLongOrDefault((String) o, 0L); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT64", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets an UINT32 value from a WmiResult. Note that while a UINT32 CIM type + * is unsigned, the return type is signed and requires further processing by + * the user if unsigned values are desired. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > int getUint32(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_UINT32) { + return getInt(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT32", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets an UINT32 value from a WmiResult as a long, preserving the + * unsignedness. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > long getUint32asLong(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_UINT32) { + return getInt(result, property, index) & 0xFFFFFFFFL; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT32", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Sint32 value from a WmiResult. Note that while the CIM type is + * unsigned, the return type is signed and requires further processing by + * the user if unsigned values are desired. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > int getSint32(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_SINT32) { + return getInt(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "SINT32", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Uint16 value from a WmiResult. Note that while the CIM type is + * unsigned, the return type is signed and requires further processing by + * the user if unsigned values are desired. + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > int getUint16(WmiResult result, T property, int index) { + if (result.getCIMType(property) == Wbemcli.CIM_UINT16) { + return getInt(result, property, index); + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "UINT16", + result.getCIMType(property), result.getVtType(property))); + } + + private static > int getInt(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return 0; + } else if (result.getVtType(property) == Variant.VT_I4) { + return (int) o; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "32-bit integer", + result.getCIMType(property), result.getVtType(property))); + } + + /** + * Gets a Float value from a WmiResult + * + * @param + * The enum type containing the property keys + * @param result + * The WmiResult from which to fetch the value + * @param property + * The property (column) to fetch + * @param index + * The index (row) to fetch + * @return The stored value if non-null, 0 otherwise + */ + public static > float getFloat(WmiResult result, T property, int index) { + Object o = result.getValue(property, index); + if (o == null) { + return 0f; + } else if (result.getCIMType(property) == Wbemcli.CIM_REAL32 && result.getVtType(property) == Variant.VT_R4) { + return (float) o; + } + throw new ClassCastException(String.format(CLASS_CAST_MSG, property.name(), "Float", + result.getCIMType(property), result.getVtType(property))); + } +} From 3682b39766368152921e5f2a785d90bfb3a1abf1 Mon Sep 17 00:00:00 2001 From: Tyler Cook Date: Tue, 6 Aug 2019 16:02:50 -0500 Subject: [PATCH 2/4] Rebase on current project --- reference/.gitignore | 10 + .../.mvn/wrapper/MavenWrapperDownloader.java | 117 ++ .../.mvn/wrapper/maven-wrapper.properties | 2 + reference/.travis.yml | 60 + reference/CHANGELOG.md | 358 ++++++ reference/CONTRIBUTING.md | 116 ++ reference/FAQ.md | 38 + reference/LICENSE_HEADER | 21 + reference/README.md | 229 ++++ reference/RELEASING.md | 49 + reference/UPGRADING.md | 135 ++ reference/appveyor.yml | 52 + reference/definitions-full.json | 925 -------------- reference/definitions.json | 396 ------ .../gen/main/java/oshi/api/FreeBsdSystem.java | 15 - .../gen/main/java/oshi/api/LinuxSystem.java | 15 - .../gen/main/java/oshi/api/MacSystem.java | 15 - .../gen/main/java/oshi/api/MultiSystem.java | 15 - .../gen/main/java/oshi/api/SolarisSystem.java | 15 - .../gen/main/java/oshi/api/WindowsSystem.java | 15 - .../hardware/disk/DiskContainerFreeBsd.java | 17 - .../api/hardware/disk/DiskContainerLinux.java | 17 - .../api/hardware/disk/DiskContainerMac.java | 17 - .../hardware/disk/DiskContainerSolaris.java | 17 - .../hardware/disk/DiskContainerWindows.java | 17 - .../oshi/api/hardware/disk/DiskFreeBsd.java | 5 - .../oshi/api/hardware/disk/DiskLinux.java | 5 - .../java/oshi/api/hardware/disk/DiskMac.java | 5 - .../oshi/api/hardware/disk/DiskSolaris.java | 5 - .../oshi/api/hardware/disk/DiskWindows.java | 5 - .../hardware/disk/internal/DiskAttribute.java | 64 - .../api/hardware/disk/internal/DiskQuery.java | 13 - .../oshi/api/hardware/firmware/Firmware.java | 16 - .../firmware/FirmwareContainerFreeBsd.java | 17 - .../firmware/FirmwareContainerLinux.java | 30 - .../firmware/FirmwareContainerMac.java | 17 - .../firmware/FirmwareContainerSolaris.java | 17 - .../firmware/FirmwareContainerWindows.java | 17 - .../hardware/firmware/FirmwareFreeBsd.java | 5 - .../api/hardware/firmware/FirmwareLinux.java | 6 - .../api/hardware/firmware/FirmwareMac.java | 5 - .../hardware/firmware/FirmwareSolaris.java | 5 - .../hardware/firmware/FirmwareWindows.java | 5 - .../firmware/internal/FirmwareAttribute.java | 18 - .../firmware/internal/FirmwareQuery.java | 13 - .../api/hardware/nic/NicContainerFreeBsd.java | 17 - .../api/hardware/nic/NicContainerLinux.java | 17 - .../api/hardware/nic/NicContainerMac.java | 17 - .../api/hardware/nic/NicContainerSolaris.java | 17 - .../oshi/api/hardware/nic/NicFreeBsd.java | 5 - .../java/oshi/api/hardware/nic/NicLinux.java | 5 - .../java/oshi/api/hardware/nic/NicMac.java | 5 - .../oshi/api/hardware/nic/NicSolaris.java | 5 - .../oshi/api/hardware/nic/NicWindows.java | 20 - .../hardware/nic/internal/NicAttribute.java | 60 - .../api/hardware/nic/internal/NicQuery.java | 13 - reference/mvnw | 310 +++++ reference/mvnw.cmd | 182 +++ reference/oshi-core-shaded/pom.xml | 127 ++ reference/oshi-core/pom.xml | 99 ++ .../src/gen/java/oshi/api/FreeBsdSystem.java | 40 + .../src/gen/java/oshi/api/LinuxSystem.java | 40 + .../src/gen/java/oshi/api/MacSystem.java | 40 + .../src/gen/java/oshi/api/MultiSystem.java | 40 + .../src/gen/java/oshi/api/SolarisSystem.java | 40 + .../src/gen/java/oshi/api/WindowsSystem.java | 40 + .../java/oshi/api/hardware/disk/Disk.java | 26 + .../oshi/api/hardware/disk/DiskFreeBsd.java | 31 + .../oshi/api/hardware/disk/DiskLinux.java | 31 + .../java/oshi/api/hardware/disk/DiskMac.java | 31 + .../oshi/api/hardware/disk/DiskSolaris.java | 31 + .../oshi/api/hardware/disk/DiskWindows.java | 31 + .../hardware/disk/internal/DiskAttribute.java | 90 ++ .../disk/internal}/DiskContainer.java | 29 +- .../disk/internal/DiskContainerFreeBsd.java | 43 + .../disk/internal/DiskContainerLinux.java | 43 + .../disk/internal/DiskContainerMac.java | 43 + .../disk/internal/DiskContainerSolaris.java | 43 + .../disk/internal/DiskContainerWindows.java | 43 + .../api/hardware/disk/internal/DiskQuery.java | 38 + .../oshi/api/hardware/firmware/Firmware.java | 42 + .../hardware/firmware/FirmwareFreeBsd.java | 31 + .../api/hardware/firmware/FirmwareLinux.java | 32 + .../api/hardware/firmware/FirmwareMac.java | 31 + .../hardware/firmware/FirmwareSolaris.java | 31 + .../hardware/firmware/FirmwareWindows.java | 31 + .../firmware/internal/FirmwareAttribute.java | 44 + .../firmware/internal}/FirmwareContainer.java | 29 +- .../internal/FirmwareContainerFreeBsd.java | 43 + .../internal/FirmwareContainerLinux.java | 55 + .../internal/FirmwareContainerMac.java | 43 + .../internal/FirmwareContainerSolaris.java | 43 + .../internal/FirmwareContainerWindows.java | 43 + .../firmware/internal/FirmwareQuery.java | 38 + .../gen}/java/oshi/api/hardware/nic/Nic.java | 26 + .../oshi/api/hardware/nic/NicFreeBsd.java | 31 + .../java/oshi/api/hardware/nic/NicLinux.java | 31 + .../java/oshi/api/hardware/nic/NicMac.java | 31 + .../oshi/api/hardware/nic/NicSolaris.java | 31 + .../oshi/api/hardware/nic/NicWindows.java | 46 + .../hardware/nic/internal/NicAttribute.java | 86 ++ .../hardware/nic/internal}/NicContainer.java | 29 +- .../nic/internal/NicContainerFreeBsd.java | 43 + .../nic/internal/NicContainerLinux.java | 43 + .../nic/internal/NicContainerMac.java | 43 + .../nic/internal/NicContainerSolaris.java | 43 + .../nic/internal}/NicContainerWindows.java | 29 +- .../api/hardware/nic/internal/NicQuery.java | 38 + .../src/main/java/oshi/ApiGenerator.java | 231 ++-- .../oshi/api/DetachedContainerException.java | 34 + .../src/main/java/oshi/api/OSHI.java | 156 +++ .../src/main/java/oshi/api/PlatformEnum.java | 61 + .../api/UnsupportedPlatformException.java | 30 + .../java/oshi/driver/ComponentDriver.java | 30 +- .../java/oshi/driver/ExtensionDriver.java | 31 + .../src/main/java/oshi/driver/Fallback.java | 36 + .../main/java/oshi/driver/QueryStatus.java | 46 + .../main/java/oshi/driver/RequiresRoot.java | 35 + .../main/java/oshi/driver/SystemDriver.java | 70 ++ .../java/oshi/driver/SystemDriverFreeBsd.java | 53 + .../java/oshi/driver/SystemDriverLinux.java | 29 +- .../java/oshi/driver/SystemDriverMac.java | 53 + .../java/oshi/driver/SystemDriverSolaris.java | 53 + .../java/oshi/driver/SystemDriverWindows.java | 53 + .../src/main/java/oshi/driver/Timeout.java | 36 + .../driver/hardware/disk/DiskDriverLinux.java | 25 +- .../hardware/disk/DiskDriverLinuxSMART.java | 25 +- .../firmware/FirmwareDriverLinux.java | 25 +- .../driver/hardware/nic/NicDriverJava.java | 25 +- .../driver/hardware/nic/NicDriverLinux.java | 25 +- .../main/java/oshi/example/DiskExample.java | 40 + .../java/oshi/example/FirmwareExample.java | 44 + .../main/java/oshi/example/NicExample.java | 45 + .../main/java/oshi/old/ExecutingCommand.java | 0 .../src/main/java/oshi/old/FileUtil.java | 0 .../src/main/java/oshi/old/ParseUtil.java | 0 .../src/main/java/oshi/old/Udev.java | 0 .../src/main/java/oshi/old/WmiUtil.java | 0 reference/oshi-core/src/site/site.xml | 52 + reference/oshi-demo/pom.xml | 70 ++ reference/oshi-dist/LICENSE_MIT | 21 + reference/oshi-dist/pom.xml | 89 ++ reference/oshi-dist/src/assembly/assembly.xml | 76 ++ .../eclipse/OSHIJavaFormatConventions.xml | 318 +++++ reference/oshi-dist/src/site/site.xml | 52 + reference/pom.xml | 1085 +++++++++++++++++ .../oshi/api/DetachedContainerException.java | 14 - .../oshi/api/NoSuchQueryMethodException.java | 5 - reference/src/main/java/oshi/api/OSHI.java | 78 -- .../src/main/java/oshi/api/PlatformEnum.java | 51 - .../java/oshi/driver/ExtensionDriver.java | 12 - .../src/main/java/oshi/driver/Fallback.java | 13 - .../main/java/oshi/driver/RequiresRoot.java | 12 - .../main/java/oshi/driver/SystemDriver.java | 65 - .../java/oshi/driver/SystemDriverFreeBsd.java | 30 - .../java/oshi/driver/SystemDriverMac.java | 30 - .../java/oshi/driver/SystemDriverSolaris.java | 30 - .../java/oshi/driver/SystemDriverWindows.java | 30 - .../main/java/oshi/example/DiskExample.java | 17 - .../java/oshi/example/FirmwareExample.java | 21 - .../main/java/oshi/example/NicExample.java | 22 - reference/src/site/markdown/README.md | 223 ++++ reference/src/site/site.xml | 52 + 163 files changed, 7004 insertions(+), 2489 deletions(-) create mode 100644 reference/.gitignore create mode 100644 reference/.mvn/wrapper/MavenWrapperDownloader.java create mode 100644 reference/.mvn/wrapper/maven-wrapper.properties create mode 100644 reference/.travis.yml create mode 100644 reference/CHANGELOG.md create mode 100644 reference/CONTRIBUTING.md create mode 100644 reference/FAQ.md create mode 100644 reference/LICENSE_HEADER create mode 100644 reference/README.md create mode 100644 reference/RELEASING.md create mode 100644 reference/UPGRADING.md create mode 100644 reference/appveyor.yml delete mode 100644 reference/definitions-full.json delete mode 100644 reference/definitions.json delete mode 100644 reference/gen/main/java/oshi/api/FreeBsdSystem.java delete mode 100644 reference/gen/main/java/oshi/api/LinuxSystem.java delete mode 100644 reference/gen/main/java/oshi/api/MacSystem.java delete mode 100644 reference/gen/main/java/oshi/api/MultiSystem.java delete mode 100644 reference/gen/main/java/oshi/api/SolarisSystem.java delete mode 100644 reference/gen/main/java/oshi/api/WindowsSystem.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicMac.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java delete mode 100644 reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java create mode 100755 reference/mvnw create mode 100644 reference/mvnw.cmd create mode 100644 reference/oshi-core-shaded/pom.xml create mode 100644 reference/oshi-core/pom.xml create mode 100644 reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/MacSystem.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java rename reference/{gen/main => oshi-core/src/gen}/java/oshi/api/hardware/disk/Disk.java (57%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java rename reference/{gen/main/java/oshi/api/hardware/disk => oshi-core/src/gen/java/oshi/api/hardware/disk/internal}/DiskContainer.java (87%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java rename reference/{gen/main/java/oshi/api/hardware/firmware => oshi-core/src/gen/java/oshi/api/hardware/firmware/internal}/FirmwareContainer.java (51%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java rename reference/{gen/main => oshi-core/src/gen}/java/oshi/api/hardware/nic/Nic.java (50%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java rename reference/{gen/main/java/oshi/api/hardware/nic => oshi-core/src/gen/java/oshi/api/hardware/nic/internal}/NicContainer.java (85%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java rename reference/{gen/main/java/oshi/api/hardware/nic => oshi-core/src/gen/java/oshi/api/hardware/nic/internal}/NicContainerWindows.java (56%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java rename reference/{ => oshi-core}/src/main/java/oshi/ApiGenerator.java (75%) create mode 100644 reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java create mode 100644 reference/oshi-core/src/main/java/oshi/api/OSHI.java create mode 100644 reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java create mode 100644 reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java rename reference/{ => oshi-core}/src/main/java/oshi/driver/ComponentDriver.java (78%) create mode 100644 reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/Fallback.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java rename reference/{ => oshi-core}/src/main/java/oshi/driver/SystemDriverLinux.java (65%) create mode 100644 reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java create mode 100644 reference/oshi-core/src/main/java/oshi/driver/Timeout.java rename reference/{ => oshi-core}/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java (69%) rename reference/{ => oshi-core}/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java (65%) rename reference/{ => oshi-core}/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java (64%) rename reference/{ => oshi-core}/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java (57%) rename reference/{ => oshi-core}/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java (77%) create mode 100644 reference/oshi-core/src/main/java/oshi/example/DiskExample.java create mode 100644 reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java create mode 100644 reference/oshi-core/src/main/java/oshi/example/NicExample.java rename reference/{ => oshi-core}/src/main/java/oshi/old/ExecutingCommand.java (100%) rename reference/{ => oshi-core}/src/main/java/oshi/old/FileUtil.java (100%) rename reference/{ => oshi-core}/src/main/java/oshi/old/ParseUtil.java (100%) rename reference/{ => oshi-core}/src/main/java/oshi/old/Udev.java (100%) rename reference/{ => oshi-core}/src/main/java/oshi/old/WmiUtil.java (100%) create mode 100644 reference/oshi-core/src/site/site.xml create mode 100644 reference/oshi-demo/pom.xml create mode 100644 reference/oshi-dist/LICENSE_MIT create mode 100644 reference/oshi-dist/pom.xml create mode 100644 reference/oshi-dist/src/assembly/assembly.xml create mode 100644 reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml create mode 100644 reference/oshi-dist/src/site/site.xml create mode 100644 reference/pom.xml delete mode 100644 reference/src/main/java/oshi/api/DetachedContainerException.java delete mode 100644 reference/src/main/java/oshi/api/NoSuchQueryMethodException.java delete mode 100644 reference/src/main/java/oshi/api/OSHI.java delete mode 100644 reference/src/main/java/oshi/api/PlatformEnum.java delete mode 100644 reference/src/main/java/oshi/driver/ExtensionDriver.java delete mode 100644 reference/src/main/java/oshi/driver/Fallback.java delete mode 100644 reference/src/main/java/oshi/driver/RequiresRoot.java delete mode 100644 reference/src/main/java/oshi/driver/SystemDriver.java delete mode 100644 reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java delete mode 100644 reference/src/main/java/oshi/driver/SystemDriverMac.java delete mode 100644 reference/src/main/java/oshi/driver/SystemDriverSolaris.java delete mode 100644 reference/src/main/java/oshi/driver/SystemDriverWindows.java delete mode 100644 reference/src/main/java/oshi/example/DiskExample.java delete mode 100644 reference/src/main/java/oshi/example/FirmwareExample.java delete mode 100644 reference/src/main/java/oshi/example/NicExample.java create mode 100644 reference/src/site/markdown/README.md create mode 100644 reference/src/site/site.xml diff --git a/reference/.gitignore b/reference/.gitignore new file mode 100644 index 0000000..1b1362c --- /dev/null +++ b/reference/.gitignore @@ -0,0 +1,10 @@ +# Output +target +.project +.settings +.classpath +.idea +.DS_Store +*.iml +.mvn/wrapper/maven-wrapper.jar +oshi-core-shaded/dependency-reduced-pom.xml diff --git a/reference/.mvn/wrapper/MavenWrapperDownloader.java b/reference/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..c32394f --- /dev/null +++ b/reference/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.5"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/reference/.mvn/wrapper/maven-wrapper.properties b/reference/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..fa87ad7 --- /dev/null +++ b/reference/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar diff --git a/reference/.travis.yml b/reference/.travis.yml new file mode 100644 index 0000000..56d91f9 --- /dev/null +++ b/reference/.travis.yml @@ -0,0 +1,60 @@ +language: java + +before_install: + # When building the coverity_scan branch, allow only the first job to continue. + - if [[ "${TRAVIS_BRANCH}" == "coverity_scan" && "$MATRIX_ID" != "first" ]]; then exit 0; fi + # Get most recent JDK versions on-the-fly + - wget https://github.com/sormuras/bach/raw/master/install-jdk.sh + +after_success: + - bash <(curl -s https://codecov.io/bash) + - if [ "$MATRIX_ID" == "first" ]; then + ./mvnw clean test jacoco:report coveralls:report; + ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar; + fi + +env: + global: + # COVERITY_SCAN_TOKEN + - secure: "JuTWT2u7BWQEJGMGkVvQMIQxwxajntxqbCGYt+bJD3JQhioPVFUJoEFrLCx+jJ0qLy5usrneCDFrvRhvTh6C+95kvHypvGQ3UoeWyXS8zD+GRPUyskbuQ7P60kqqIqc+naGd3uyGddniixoAA6C/Ptmknhls4FlhDCMjW3HDS0c=" + +addons: + coverity_scan: + project: + name: "dblock/oshi" + description: "Build submitted via Travis CI" + notification_email: widdis@gmail.com + build_command_prepend: "cov-configure --comptype gcc --compiler gcc-4.8 --template" + build_command: "./mvnw -DskipTests=true clean compile" + branch_pattern: coverity_scan + sonarcloud: + organization: "default" # the key of the open source org + hosts: + - oshi + hostname: oshi + +matrix: + include: + - os: osx + env: + - JDK = "Oracle JDK 8 - Mac" + - MATRIX_ID="first" + osx_image: xcode9.3 + - os: osx + env: JDK = "OpenJDK 11 - Mac" + osx_image: xcode10.1 + - os: linux + install: . ./install-jdk.sh -F 11 -L GPL + env: JDK = "OpenJDK 11 - Linux" + - os: linux + install: . ./install-jdk.sh -F 12 -L GPL + env: JDK = "OpenJDK 12 - Linux" + - os: linux + install: . ./install-jdk.sh -F ea -L GPL + env: JDK = "OpenJDK 13-ea - Linux" + +script: + # Skip tests on coverity_scan branch + - if [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]; then exit 0; fi + - java -version + - mvn test diff --git a/reference/CHANGELOG.md b/reference/CHANGELOG.md new file mode 100644 index 0000000..b2b2ca9 --- /dev/null +++ b/reference/CHANGELOG.md @@ -0,0 +1,358 @@ +4.0.0 (in progress) +================ +* [#756](https://github.com/oshi/oshi/pull/756): Require Java 8. - [@dbwiddis](https://github.com/dbwiddis). +* [#773](https://github.com/oshi/oshi/pull/773): Remove oshi-json artifact. - [@dbwiddis](https://github.com/dbwiddis). +* [#774](https://github.com/oshi/oshi/pull/774): API overhaul - ComputerSystem, Baseboard, and Firmware. - [@dbwiddis](https://github.com/dbwiddis). +* [#775](https://github.com/oshi/oshi/pull/775): API overhaul - GlobalMemory, new VirtualMemory. - [@dbwiddis](https://github.com/dbwiddis). +* [#776](https://github.com/oshi/oshi/pull/776): oshi-demo artifact. - [@dbwiddis](https://github.com/dbwiddis). +* [#779](https://github.com/oshi/oshi/pull/779): API overhaul - CentralProcessor, new LogicalProcessor. - [@dbwiddis](https://github.com/dbwiddis). +* [#794](https://github.com/oshi/oshi/pull/794): Add NUMA nodes to Logical Processors. - [@dbwiddis](https://github.com/dbwiddis). +* [#838](https://github.com/oshi/oshi/pull/838): JNA 5.3.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#845](https://github.com/oshi/oshi/pull/845): JNA 5.3.1. - [@dbwiddis](https://github.com/dbwiddis). +* [#857](https://github.com/oshi/oshi/pull/857): Fix CPU temperature - [@rlouwerens](https://github.com/rlouwerens). +* [#901](https://github.com/oshi/oshi/pull/901): Fix incorrect physical processor count on Linux. - [@ellesummer](https://github.com/ellesummer). +* [#845](https://github.com/oshi/oshi/pull/911): JNA 5.4.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#914](https://github.com/oshi/oshi/pull/914): Add System Boot Time. - [@shannondavid](https://github.com/shannondavid). +* [#916](https://github.com/oshi/oshi/pull/916): Move Uptime and Boot Time to OperatingSystem class. - [@dbwiddis](https://github.com/dbwiddis). +* [#917](https://github.com/oshi/oshi/pull/917): API overhaul - Sensors. - [@dbwiddis](https://github.com/dbwiddis). +* [#918](https://github.com/oshi/oshi/pull/918): Removed time interval based caching. - [@dbwiddis](https://github.com/dbwiddis). +* [#921](https://github.com/oshi/oshi/pull/921): Removed static map based caching. - [@dbwiddis](https://github.com/dbwiddis). +* [#922](https://github.com/oshi/oshi/pull/922): Show OSProcess Bitness. - [@dbwiddis](https://github.com/dbwiddis). +* [#926](https://github.com/oshi/oshi/pull/926): Fix SMC datatype reading. - [@dbwiddis](https://github.com/dbwiddis). +* [#928](https://github.com/oshi/oshi/pull/928): Raspberry Pi compatibility fixes. - [@dbwiddis](https://github.com/dbwiddis). +* [#929](https://github.com/oshi/oshi/pull/929): Add isElevated check to OperatingSystem. - [@dbwiddis](https://github.com/dbwiddis). +* [#931](https://github.com/oshi/oshi/pull/931): Standardize attribute updating. - [@dbwiddis](https://github.com/dbwiddis). +* Your contribution here. + +3.13.0 (1/18/2019), 3.13.1 (4/21/2019), 3.13.2 (4/28/2019), 3.13.3 (6/5/2019) +================ +* [#763](https://github.com/oshi/oshi/pull/763): Refactor PDH/WMI Fallback. - [@dbwiddis](https://github.com/dbwiddis). +* [#766](https://github.com/oshi/oshi/pull/766): Use query key to update counters in groups. - [@dbwiddis](https://github.com/dbwiddis). +* [#767](https://github.com/oshi/oshi/pull/767): Allow subclassing WmiQueryHandler with reflection. - [@dbwiddis](https://github.com/dbwiddis). +* [#769](https://github.com/oshi/oshi/pull/769): Close PDH handles after each query. - [@dbwiddis](https://github.com/dbwiddis). +* [#839](https://github.com/oshi/oshi/pull/838): JNA 5.3.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#845](https://github.com/oshi/oshi/pull/845): JNA 5.3.1. - [@dbwiddis](https://github.com/dbwiddis). + +3.12.1 (12/31/2018), 3.12.2 (1/10/2019) +================ +* [#728](https://github.com/oshi/oshi/pull/728): Separate WMI Query Handling from Util. - [@retomerz](https://github.com/retomerz). +* [#730](https://github.com/oshi/oshi/pull/730): Fix Windows process token handle leak. - [@dbwiddis](https://github.com/dbwiddis). +* [#731](https://github.com/oshi/oshi/pull/731): Switch to MIT License, JNA 5.2.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#735](https://github.com/oshi/oshi/pull/735): Windows XP Compatibility fixes. - [@dbwiddis](https://github.com/dbwiddis). +* [#737](https://github.com/oshi/oshi/pull/737): Properly handle redundant COM initialization. - [@dbwiddis](https://github.com/dbwiddis). + +3.12.0 (12/16/2018) +================ +* [#694](https://github.com/oshi/oshi/pull/694): ComputerIdentifier Util Method - [@Aashishthakur10](https://github.com/Aashishthakur10). +* [#699](https://github.com/oshi/oshi/pull/699): Fix PerfData error handling - [@dbwiddis](https://github.com/dbwiddis). +* [#703](https://github.com/oshi/oshi/pull/703): Remove deprecated CentralProcessor serialNumber method - [@dbwiddis](https://github.com/dbwiddis). +* [#704](https://github.com/oshi/oshi/pull/704): Check for Virtual Machine - [@haidong](https://github.com/haidong). +* [#724](https://github.com/oshi/oshi/pull/724): Refactor unsigned long bitmasking - [@LiborB] (https://github.com/LiborB). + +3.11.0 (11/21/2018) +================ +* [#685](https://github.com/oshi/oshi/pull/685): Get Linux HZ from system config - [@dbwiddis](https://github.com/dbwiddis). +* [#686](https://github.com/oshi/oshi/pull/686): JNA 5.1.0 - [@dbwiddis](https://github.com/dbwiddis). +* [#688](https://github.com/oshi/oshi/pull/688): Fix Linux proc stat and pagesize parsing - [@dbwiddis](https://github.com/dbwiddis). +* [#689](https://github.com/oshi/oshi/pull/689): Optionally skip slow OSProcess fields - [@dbwiddis](https://github.com/dbwiddis). +* [#690](https://github.com/oshi/oshi/pull/690): Prioritize system-release for Fedora and CentOS version - [@dbwiddis](https://github.com/dbwiddis). +* [#691](https://github.com/oshi/oshi/pull/691): Cache OSProcesses on Linux - [@dbwiddis](https://github.com/dbwiddis). + +3.10.0 (11/03/2018) +================ +* [#656](https://github.com/oshi/oshi/pull/656): JNA 5.0.0. - [@dbwiddis](https://github.com/dbwiddis). +* [#659](https://github.com/oshi/oshi/pull/659): Add free/total inode counts. - [@Space2Man](https://github.com/Space2Man). +* [#666](https://github.com/oshi/oshi/pull/666): Recreate counter handles when invalid - [@dbwiddis](https://github.com/dbwiddis). +* [#675](https://github.com/oshi/oshi/pull/675): Solaris 10 network stats compatibility fix - [@dbwiddis](https://github.com/dbwiddis). + +3.9.1 (10/14/2018) +================ +* [#647](https://github.com/oshi/oshi/pull/647): Fix Windows idle counter calculation. - [@dbwiddis](https://github.com/dbwiddis). +* [#653](https://github.com/oshi/oshi/pull/653): Fix transferTime in WindowsDisks by using 1-%Idle - [@Space2Man](https://github.com/Space2Man). + +3.9.0 (10/7/2018) +================ +* [#630](https://github.com/oshi/oshi/pull/630), [#640](https://github.com/oshi/oshi/pull/640), [#645](https://github.com/oshi/oshi/pull/645), [#652](https://github.com/oshi/oshi/pull/652), [#655](https://github.com/oshi/oshi/pull/655): Add Sound Card list. - [@bilalAM](https://github.com/bilalAM). +* [#636](https://github.com/oshi/oshi/pull/636): Catch exception when english counters missing. - [@dbwiddis](https://github.com/dbwiddis). +* [#639](https://github.com/oshi/oshi/pull/639): Implement QueueLength metric in HWDiskStore. - [@Space2Man](https://github.com/Space2Man). + +3.8.1 (09/01/2018), 3.8.2 (09/07/2018), 3.8.3 (09/14/2018), 3.8.4 (09/24/2018) +================ +* [#592](https://github.com/oshi/oshi/pull/592): Test for non-numeric doubles in JSON parsing. - [@dbwiddis](https://github.com/dbwiddis). +* [#597](https://github.com/oshi/oshi/pull/597): Fix Windows serialnumber fallback bug. - [@dbwiddis](https://github.com/dbwiddis). +* [#603](https://github.com/oshi/oshi/pull/603): Fix Process Uptime bug. - [@anitakosman](https://github.com/anitakosman). +* [#604](https://github.com/oshi/oshi/pull/604): Fix Windows interrupt count bug. - [@dbwiddis](https://github.com/dbwiddis). +* [#605](https://github.com/oshi/oshi/pull/605): Update OSGi imports. - [@dbwiddis](https://github.com/dbwiddis). +* [#608](https://github.com/oshi/oshi/pull/608): Fix Windows context swith count bug. - [@dbwiddis](https://github.com/dbwiddis). +* [#611](https://github.com/oshi/oshi/pull/611): Fix proc stat parsing on older Linux distros. - [@dbwiddis](https://github.com/dbwiddis). +* [#612](https://github.com/oshi/oshi/pull/612): OSProcess toString. - [@dbwiddis](https://github.com/dbwiddis). +* [#614](https://github.com/oshi/oshi/pull/614): Remove unneeded debug query and fix a WMI cast error - [@dbwiddis](https://github.com/dbwiddis). +* [#626](https://github.com/oshi/oshi/pull/626): Fix calculation of Hz on Linux - [@dbwiddis](https://github.com/dbwiddis). + +3.8.0 (08/20/2018) +================ +* [#580](https://github.com/oshi/oshi/pull/580): Windows process uptime wasn't updating. - [@dbwiddis](https://github.com/dbwiddis). +* [#585](https://github.com/oshi/oshi/pull/585): Fix WMI type mapping and BSTR allocation. - [@dbwiddis](https://github.com/dbwiddis). +* [#586](https://github.com/oshi/oshi/pull/586): Add PerfDataUtil.removeAllCounters. - [@dbwiddis](https://github.com/dbwiddis). +* [#587](https://github.com/oshi/oshi/pull/587): Localize PDH instance enumeration. - [@dbwiddis](https://github.com/dbwiddis). +* [#588](https://github.com/oshi/oshi/pull/588): WMI backup for all PDH Counters. - [@dbwiddis](https://github.com/dbwiddis). + +3.7.1 (07/28/2018), 3.7.2 (08/01/2018) +================ +* [#571](https://github.com/oshi/oshi/pull/571): CIM date broken for timezones east of GMT. - [@dbwiddis](https://github.com/dbwiddis). +* [#573](https://github.com/oshi/oshi/pull/573): Don't get PDH swap stats if no swap. - [@dbwiddis](https://github.com/dbwiddis). +* [#574](https://github.com/oshi/oshi/pull/574): Suppress repeat updates of failed PDH counters. - [@dbwiddis](https://github.com/dbwiddis). +* [#575](https://github.com/oshi/oshi/pull/575): Replace WMI value types with Variant types. - [@dbwiddis](https://github.com/dbwiddis). +* [#577](https://github.com/oshi/oshi/pull/577): Get Windows temperature from PDH counters. - [@dbwiddis](https://github.com/dbwiddis). + +3.7.0 (07/28/2018) +================ +* [#551](https://github.com/oshi/oshi/pull/551): Check for zero-length PDH counter lists to avoid exceptions - [@dbwiddis](https://github.com/dbwiddis). +* [#556](https://github.com/oshi/oshi/pull/556): WMI timeouts, standardization, and simplification. - [@dbwiddis](https://github.com/dbwiddis). +* [#557](https://github.com/oshi/oshi/pull/557): Localize PDH Counter paths. - [@dbwiddis](https://github.com/dbwiddis). +* [#561](https://github.com/oshi/oshi/pull/561): Optimize Process CPU sort. - [@dbwiddis](https://github.com/dbwiddis). +* [#564](https://github.com/oshi/oshi/pull/564): Cache WMI connections. - [@dbwiddis](https://github.com/dbwiddis). +* [#567](https://github.com/oshi/oshi/pull/567): Cache USB devices. - [@dbwiddis](https://github.com/dbwiddis). +* [#569](https://github.com/oshi/oshi/pull/569): Remove threetenbp dependency. - [@dbwiddis](https://github.com/dbwiddis). + +3.6.1 (6/28/2018), 3.6.2 (7/10/2018) +================ +* [#527](https://github.com/oshi/oshi/pull/527): Correct process information caching and command line retrieval under Windows - [@dustin-johnson](https://github.com/dustin-johnson). +* [#533](https://github.com/oshi/oshi/pull/533): Filter to CPU zone if multiple Windows Thermal sensors. - [@dbwiddis](https://github.com/dbwiddis). +* [#542](https://github.com/oshi/oshi/pull/542): Disabled Windows performance collection leads to empty Process cache - [@MarcMil](https://github.com/MarcMil). +* [#547](https://github.com/oshi/oshi/pull/547): Remove DataTypeConverter dependency so OSHI builds on Java 9+ - [@dbwiddis](https://github.com/dbwiddis). + +3.6.0 (6/20/2018) +================ +* [#489](https://github.com/oshi/oshi/pull/489): Switch from WMI to native methods for most Windows Process data. - [@dbwiddis](https://github.com/dbwiddis). +* [#501](https://github.com/oshi/oshi/pull/501): Added HWDiskStore.updateDiskStats. - [@cjbrowne](https://github.com/cjbrowne). +* [#503](https://github.com/oshi/oshi/pull/503): Expose memory page size to API. - [@dbwiddis](https://github.com/dbwiddis). +* [#507](https://github.com/oshi/oshi/pull/507): Replace WMI with (faster) PDH queries for WindowsCentralProcessor. - [@dbwiddis](https://github.com/dbwiddis). +* [#508](https://github.com/oshi/oshi/pull/508): Replace WMI with (faster) registry data for Windows Processes. - [@dbwiddis](https://github.com/dbwiddis). +* [#509](https://github.com/oshi/oshi/pull/509): Add pages swapped in/out to paging/swap file. - [@dbwiddis](https://github.com/dbwiddis). +* [#518](https://github.com/oshi/oshi/pull/518): Add OS bitness. - [@dbwiddis](https://github.com/dbwiddis). + +3.5.0 (4/15/2018) +================ +* [#446](https://github.com/oshi/oshi/pull/446): Add getChildProcesses to OperatingSystem. - [@jsimomaa](https://github.com/jsimomaa) +* [#447](https://github.com/oshi/oshi/pull/447), [#471](https://github.com/oshi/oshi/pull/471): Added context switches and interrupts - [@jpbempel](https://github.com/jpbempel), [@dbwiddis](https://github.com/dbwiddis). +* [#476](https://github.com/dblock/oshi/pull/476): Count CPU Packages - [@dbwiddis](https://github.com/dbwiddis). +* [#478](https://github.com/dblock/oshi/pull/478): Windows RSS now reports Private Working Set, matching Task Manager - [@dbwiddis](https://github.com/dbwiddis). +* Updated to JNA 4.5.1 + +3.4.5 (4/11/2018) +================ +* [#433](https://github.com/oshi/oshi/pull/433): Performance improvements for getProcesses() on Linux - [@bildechinger](https://github.com/bildechinger). +* [#455](https://github.com/oshi/oshi/pull/455): Open files/handles support - [@spyhunter99](https://github.com/spyhunter99). +* [#459](https://github.com/oshi/oshi/pull/459): New methods for querying for a list of specific pids - [@spyhunter99](https://github.com/spyhunter99). +* [#464](https://github.com/oshi/oshi/pull/464): OSGi fixes - [@lprimak](https://github.com/lprimak). +* [#465](https://github.com/oshi/oshi/pull/465): Include a shaded jar with all dependencies - [@lprimak](https://github.com/lprimak). + +3.4.4 (10/15/17) +================ +* [#392](https://github.com/dblock/oshi/pull/392): Fix NPE for processes terminating before iteration - [@dbwiddis](https://github.com/dbwiddis). +* [#396](https://github.com/oshi/oshi/pull/396): Fix issue on Mac OS X whereby the buffer size for the call to proc_listpids() was improperly calculated - [@brettwooldridge](https://github.com/brettwooldridge) +* Updated to JNA 4.5.0 + +3.4.3 (6/2/17) +================ +* [#336](https://github.com/dblock/oshi/pull/336): Add Process Current Working Directory - [@dbwiddis](https://github.com/dbwiddis). +* [#357](https://github.com/dblock/oshi/pull/357): Prioritize OpenHardwareMonitor for Windows Sensors - [@dbwiddis](https://github.com/dbwiddis). +* [#362](https://github.com/oshi/oshi/pull/362): Add logical volume attribute to OSFileStore (Linux support only), providing a place for an alternate volume name. [@darinhoward](https://github.com/darinhoward) +* [#363](https://github.com/oshi/oshi/pull/363): Adding Steal Tick Type for Linux - [@darinhoward](https://github.com/darinhoward). +* [#375](https://github.com/oshi/oshi/pull/375): Added OSGi bundle support - [@swimmesberger](https://github.com/swimmesberger) +* Updated to JNA 4.4.0. + +3.4.2 (3/2/2017) +================ +* [#332](https://github.com/dblock/oshi/pull/332): Remove streamsupport dependency - [@dbwiddis](https://github.com/dbwiddis). + +3.4.1 (3/1/2017) +================ +* [#327](https://github.com/dblock/oshi/pull/327): Restore Java 7 compatibility. - [@dbwiddis](https://github.com/dbwiddis). +* [#328](https://github.com/dblock/oshi/pull/328): Updated to JNA 4.3.0. - [@dbwiddis](https://github.com/dbwiddis). + +3.4.0 (2/26/2017) +================ +* Switch groupId to com.github.oshi +* [#294](https://github.com/oshi/oshi/pull/294), [#305](https://github.com/oshi/oshi/pull/305): Add NetworkParams for network parameter of OS - [@chikei](https://github.com/chikei), [@dbwiddis](https://github.com/dbwiddis). +* [#295](https://github.com/oshi/oshi/pull/295): Make OSProcess (AbstractProcess.java) more easily extendible - [@michaeldesigaud](https://github.com/michaeldesigaud). +* [#307](https://github.com/dblock/oshi/pull/307): Deprecate CentralProcessor's getSystemSerialNumber method that duplicated ComputerSystem's getSerialNumber method. - [@dbwiddis](https://github.com/dbwiddis). +* [#308](https://github.com/dblock/oshi/pull/308): Add getProcessorID to CentralProcessor. - [@dbwiddis](https://github.com/dbwiddis). +* [#309](https://github.com/dblock/oshi/pull/309): Reduce C library duplication. - [@dbwiddis](https://github.com/dbwiddis). +* [#317](https://github.com/dblock/oshi/pull/317): Add user/uid, group/gid, and command line to OSProcess. - [@dbwiddis](https://github.com/dbwiddis). + +3.3 (12/31/2016) +================ +* [#262](https://github.com/dblock/oshi/pull/262): Add bytesRead and bytesWritten to OSProcess - [@plamenko](https://github.com/plamenko). +* [#264](https://github.com/dblock/oshi/pull/264), [#289](https://github.com/dblock/oshi/pull/289): BIOS, manufacturer, and baseboard information - [@lundefugl](https://github.com/lundefugl), [@dbwiddis](https://github.com/dbwiddis). +* [#281](https://github.com/dblock/oshi/pull/281): Improve Linux battery AC device exclusion - [@dbwiddis](https://github.com/dbwiddis). +* [#282](https://github.com/dblock/oshi/pull/282): Get Windows version from WMI - [@dbwiddis](https://github.com/dbwiddis). +* [#283](https://github.com/dblock/oshi/pull/283): Fix Linux block device stats on some distributions - [@lu-ko](https://github.com/lu-ko). +* [#284](https://github.com/dblock/oshi/pull/284): Remove incorrect IOWait counter from WindowsCentralProcessor - [@dbwiddis](https://github.com/dbwiddis). +* [#285](https://github.com/dblock/oshi/pull/285): Rebrand Mac OS 10.12+ as macOS - [@dbwiddis](https://github.com/dbwiddis). +* [#286](https://github.com/dblock/oshi/pull/286): Reduce required calculations for LinuxProcess initialization - [@dbwiddis](https://github.com/dbwiddis). +* [#290](https://github.com/dblock/oshi/pull/290): Add input/output errors to Network IF - [@dbwiddis](https://github.com/dbwiddis). + +3.2 (9/1/2016) +================ +* [#243](https://github.com/dblock/oshi/pull/243): Make Windows network statistics 64-bit - [@dbwiddis](https://github.com/dbwiddis). +* [#244](https://github.com/dblock/oshi/pull/244): Add timestamps to Disk and Network IO Stats - [@dbwiddis](https://github.com/dbwiddis). +* [#253](https://github.com/dblock/oshi/pull/253): Properly handle CoreStorage Volumes on OSX - [@dbwiddis](https://github.com/dbwiddis). +* [#256](https://github.com/dblock/oshi/pull/256): Use DeviceID to link Windows Disks and Partitions - [@dbwiddis](https://github.com/dbwiddis). + +3.1.1 (8/5/2016) +================ +* [#239](https://github.com/dblock/oshi/pull/239): Fix exceptions on windows disks/partitions - [@dbwiddis](https://github.com/dbwiddis). +* [#240](https://github.com/dblock/oshi/pull/240): Check sysfs for Linux system serial number - [@dbwiddis](https://github.com/dbwiddis). + +3.1 (8/1/2016) +================ +* [#225](https://github.com/dblock/oshi/pull/225): Bugfixes from Coverity, FindBugs, and PMD - [@dbwiddis](https://github.com/dbwiddis). +* [#229](https://github.com/dblock/oshi/pull/229): Solaris port - [@dbwiddis](https://github.com/dbwiddis). +* [#232](https://github.com/dblock/oshi/pull/232): FreeBSD port - [@dbwiddis](https://github.com/dbwiddis). +* [#234](https://github.com/dblock/oshi/pull/234): Add read/write count and active disk time to HWDiskStores - [@dbwiddis](https://github.com/dbwiddis). +* [#235](https://github.com/dblock/oshi/pull/235): Add partition information to HWDiskStores - [@dbwiddis](https://github.com/dbwiddis). + +3.0 (7/1/2016) +================ +* [#205](https://github.com/dblock/oshi/pull/205): Separated oshi-core and oshi-json modules - [@dbwiddis](https://github.com/dbwiddis). +* [#209](https://github.com/dblock/oshi/pull/209): Move FileSystem and Processes to OperatingSystem - [@dbwiddis](https://github.com/dbwiddis). +* [#210](https://github.com/dblock/oshi/pull/210): Streamlined macOS FileSystem - [@dbwiddis](https://github.com/dbwiddis). +* [#211](https://github.com/dblock/oshi/pull/211): Combine IOwait and IRQ ticks into processor tick array - [@dbwiddis](https://github.com/dbwiddis). +* [#213](https://github.com/dblock/oshi/pull/213): Sort and Limit returned Processes - [@dbwiddis](https://github.com/dbwiddis). +* [#214](https://github.com/dblock/oshi/pull/214): Offer flat or tree USB listing - [@dbwiddis](https://github.com/dbwiddis). +* [#216](https://github.com/dblock/oshi/pull/216): Filter JSON output with properties - [@dbwiddis](https://github.com/dbwiddis). +* [#219](https://github.com/dblock/oshi/pull/219): NetworkIFs can now update stats - [@dbwiddis](https://github.com/dbwiddis). +* [#223](https://github.com/dblock/oshi/pull/223): JUnit Test overhaul, adds, refactoring - [@dbwiddis](https://github.com/dbwiddis). + +2.6.2 (6/21/2016) +================ +* [#199](https://github.com/dblock/oshi/pull/199): Use WMI queries for raw data instead of maintaining PDH threads - [@dbwiddis](https://github.com/dbwiddis). +* Multiple efficiency improvements + +2.6-java7 / 2.6.1 (6/17/2016) +================ +* [#190](https://github.com/dblock/oshi/pull/190): Add VendorID and ProductID to UsbDevice - [@dbwiddis](https://github.com/dbwiddis). +* [#193](https://github.com/dblock/oshi/pull/193): Add read/write to Windows and OS X HWDiskStores - [@dbwiddis](https://github.com/dbwiddis). +* [#194](https://github.com/dblock/oshi/pull/194): Add volume name to OSFileStores - [@henryx](https://github.com/henryx). +* [#195](https://github.com/dblock/oshi/pull/195): Fixed reading multiple (in particular external) displays on Mac - [@dpagano](https://github.com/dpagano). +* [#197](https://github.com/dblock/oshi/pull/197): Add UUID to OSFileStores - [@dbwiddis](https://github.com/dbwiddis). +* [#198](https://github.com/dblock/oshi/pull/198): macOS 10.12 (Sierra) - [@dbwiddis](https://github.com/dbwiddis). +* Created a Java 7 backport using threeten.org dependency released as 2.6-m-java7 + +2.5.1-java7 / 2.5.2 (6/9/2016) +================ +* [#186](https://github.com/dblock/oshi/pull/186), [#187](https://github.com/dblock/oshi/pull/187), [#188](https://github.com/dblock/oshi/pull/188): Improve USB device trees - [@dbwiddis](https://github.com/dbwiddis). +* Created a Java 7 backport using threeten.org dependency released as 2.5.1-java7 + +2.5 (6/4/2016) +================ +* Upgraded to Java 8 base support +* [#163](https://github.com/dblock/oshi/pull/163): Update getFileStores() method to include mount point [@henryx](https://github.com/henryx). +* [#165](https://github.com/dblock/oshi/pull/165): Added system-wide file descriptor counts - [@cholland1989](https://github.com/cholland1989). +* [#168](https://github.com/dblock/oshi/pull/168): Switched WMI queries to use COM - [@dbwiddis](https://github.com/dbwiddis). +* [#171](https://github.com/dblock/oshi/pull/171): Added detailed process statistics - [@dbwiddis](https://github.com/dbwiddis). +* [#176](https://github.com/dblock/oshi/pull/176): Eliminate Swing threads in WindowsFileSystem - [@henryx](https://github.com/henryx). +* [#180](https://github.com/dblock/oshi/pull/180): Made all system information classes serializable - [@dbwiddis](https://github.com/dbwiddis). +* [#181](https://github.com/dblock/oshi/pull/181): Added USB Device listing - [@dbwiddis](https://github.com/dbwiddis). +* [#184](https://github.com/dblock/oshi/pull/184): Improve Linux OS version parsing - [@dbwiddis](https://github.com/dbwiddis). + +2.4 (5/2/2016) +================ +* [#140](https://github.com/dblock/oshi/pull/140): Added process and thread counts - [@dbwiddis](https://github.com/dbwiddis). +* [#142](https://github.com/dblock/oshi/pull/142): Added methods for getting swap (total and used) in the system - [@henryx](https://github.com/henryx). +* [#145](https://github.com/dblock/oshi/pull/145): Refactored common code to abstract classes - [@dbwiddis](https://github.com/dbwiddis). +* [#147](https://github.com/dblock/oshi/pull/147), [#149](https://github.com/dblock/oshi/pull/149): Added disk information and statistics - [@henryx](https://github.com/henryx), [@dbwiddis](https://github.com/dbwiddis). +* [#150](https://github.com/dblock/oshi/pull/150): Added filesystem types - [@dbwiddis](https://github.com/dbwiddis). +* [#155](https://github.com/dblock/oshi/pull/155), [#157](https://github.com/dblock/oshi/pull/157): Added network interface statistics - [@henryx](https://github.com/henryx), [@dbwiddis](https://github.com/dbwiddis). + +2.3 (4/14/2016) +================ +* [#124](https://github.com/dblock/oshi/pull/124): Read Windows Sensor info from Open Hardware Monitor as fallback - [@dbwiddis](https://github.com/dbwiddis). +* [#129](https://github.com/dblock/oshi/pull/129): Improve Linux version and code name parsing - [@dbwiddis](https://github.com/dbwiddis). +* [#132](https://github.com/dblock/oshi/pull/132), [#133](https://github.com/dblock/oshi/pull/133): Fix NPEs on Raspberry Pi - [@pcollaog](https://github.com/pcollaog). +* [#136](https://github.com/dblock/oshi/pull/136): Updated CPU load average to use system call - [@henryx](https://github.com/henryx). +* [#137](https://github.com/dblock/oshi/pull/137): Added iowait and irq ticks - [@dbwiddis](https://github.com/dbwiddis). + +2.2 (3/1/2016) +================ +* [#121](https://github.com/dblock/oshi/pull/121): Added CPU temperature, fan speeds, and voltage - [@dbwiddis](https://github.com/dbwiddis). +* [#123](https://github.com/dblock/oshi/pull/123): Handle JSON nulls - [@dbwiddis](https://github.com/dbwiddis). + +2.1.2 (2/24/2016) +================ +* [#118](https://github.com/dblock/oshi/pull/118): Port JSON to javax.json - [@dbwiddis](https://github.com/dbwiddis). +* [#120](https://github.com/dblock/oshi/pull/120): Support all windows processor methods - [@dbwiddis](https://github.com/dbwiddis). + +2.1.1 (2/19/2016) +================ +* [#114](https://github.com/dblock/oshi/pull/114): Memory information wasn't updating for Windows - [@dbwiddis](https://github.com/dbwiddis). +* [#116](https://github.com/dblock/oshi/pull/116): Added JSON output - [@dbwiddis](https://github.com/dbwiddis). + +2.1 (1/1/2016) +================ +* [#108](https://github.com/dblock/oshi/pull/108): Added Display info from EDID - [@dbwiddis](https://github.com/dbwiddis). +* [#111](https://github.com/dblock/oshi/pull/111): Catch exceptions when Linux c library missing - [@dbwiddis](https://github.com/dbwiddis). + +2.0 (11/28/2015) +================ +* [#101](https://github.com/dblock/oshi/pull/101): Refactored package structure for consistency - [@dbwiddis](https://github.com/dbwiddis). +* [#103](https://github.com/dblock/oshi/pull/103): Switched CentralProcessor to a single object for all processors - [@dbwiddis](https://github.com/dbwiddis). +* See [UPGRADING.md](UPGRADING.md) for more details. + +1.5.2 (11/23/2015) +================ +* [#98](https://github.com/dblock/oshi/pull/98): Upgraded JNA to 4.2.1 - [@dbwiddis](https://github.com/dbwiddis). +* [#100](https://github.com/dblock/oshi/pull/100): Add physical and logical CPU counts - [@dbwiddis](https://github.com/dbwiddis). + +1.5.1 (10/15/2015) +================ +* [#94](https://github.com/dblock/oshi/pull/94): Upgraded JNA to 4.2.0 - [@dbwiddis](https://github.com/dbwiddis). +* [#96](https://github.com/dblock/oshi/pull/96): Read buffer immediately after Runtime.exec to prevent deadlock - [@dbwiddis](https://github.com/dbwiddis). +* [#97](https://github.com/dblock/oshi/pull/97): Add system serial number - [@dbwiddis](https://github.com/dbwiddis). + +1.5 (9/21/2015) +================ +* [#87](https://github.com/dblock/oshi/pull/87): Added SLF4J logging, changed exception throwing to log errors to be robust to lack of permissions - [@dbwiddis](https://github.com/dbwiddis). + +1.4 (9/3/2015) +================ +* [#71](https://github.com/dblock/oshi/pull/71), [#72](https://github.com/dblock/oshi/pull/72): Added support for Windows 10 & Windows Server 2016 - [@laurent-r](https://github.com/laurent-r). +* [#75](https://github.com/dblock/oshi/pull/75): Added uptime information - [@dbwiddis](https://github.com/dbwiddis). +* [#76](https://github.com/dblock/oshi/pull/76): Better linux CPU processor counting - [@dbwiddis](https://github.com/dbwiddis). +* [#78](https://github.com/dblock/oshi/pull/78): Execute FileSystemView on Swing's Event Dispatch Thread - [@dbwiddis](https://github.com/dbwiddis). + +1.3 (6/27/2015) +================ +* Upgraded to Java 7 base support +* Upgraded JNA to 4.1.0 +* Brought over lessons learned from [waffle](https://github.com/dblock/waffle) for building project from source. +* [#50](https://github.com/dblock/oshi/pull/50): Added file store information - [@dbwiddis](https://github.com/dbwiddis). +* [#51](https://github.com/dblock/oshi/pull/51): Added CPU Ticks and switched to OperatingSystemMXBean for CPU load / load average - [@dbwiddis](https://github.com/dbwiddis). +* [#62](https://github.com/dblock/oshi/pull/62): Added Per-Processor CPU Load and Ticks - [@dbwiddis](https://github.com/dbwiddis). + +1.2 (6/13/2014) +================ + +* Added TODO list and enhanced README documentation - [@ptitvert](https://github.com/ptitvert) +* Added Travis-CI - [@dblock](https://github.com/dblock). +* [#3](https://github.com/dblock/oshi/pull/3): Mavenized project - [@le-yams](https://github.com/le-yams). +* [#5](https://github.com/dblock/oshi/pull/5): Added Linux support - [@ptitvert](https://github.com/ptitvert). +* [#7](https://github.com/dblock/oshi/pull/7): Added Mac OS X Support - [@ptitvert](https://github.com/ptitvert). +* [#13](https://github.com/dblock/oshi/pull/13): Support for Windows 8.1 and Windows Server 2008 R2 - [@NagyGa1](https://github.com/NagyGa1). +* [#15](https://github.com/dblock/oshi/pull/15), [#18](https://github.com/dblock/oshi/pull/18): Added support for CPU load - [@kamenitxan](https://github.com/kamenitxan), [@Sorceror](https://github.com/Sorceror). +* [#25](https://github.com/dblock/oshi/pull/25), [#29](https://github.com/dblock/oshi/pull/29): Included inactive/reclaimable memory amount in GlobalMemory#getAvailable on Mac/Linux - [@dbwiddis](https://github.com/dbwiddis). +* [#27](https://github.com/dblock/oshi/pull/27): Replaced all Mac OS X command line parsing with JNA or System properties - [@dbwiddis](https://github.com/dbwiddis). +* [#30](https://github.com/dblock/oshi/pull/30): Added processor vendor frequency information - [@alessiofachechi](https://github.com/alessiofachechi). +* [#32](https://github.com/dblock/oshi/pull/32): Added battery state information - [@dbwiddis](https://github.com/dbwiddis). + +1.1 (10/13/2013) +================ + +* Added support for Windows 8 to `oshi.software.os.OperatingSystemVersion`, `oshi.software.os.windows.nt.OSVersionInfoEx` - [@laurent-r](https://github.com/laurent-r). + +1.0 (6/23/2010) +=============== + +* Initial public release - [@dblock](https://github.com/dblock). diff --git a/reference/CONTRIBUTING.md b/reference/CONTRIBUTING.md new file mode 100644 index 0000000..1098523 --- /dev/null +++ b/reference/CONTRIBUTING.md @@ -0,0 +1,116 @@ +Contributing to Oshi +===================== + +Oshi is work of [many contributors](https://github.com/oshi/oshi/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/oshi/oshi/pulls), [propose features and discuss issues](https://github.com/oshi/oshi/issues). + +OSHI is [first-timers-only](https://www.firsttimersonly.com/) friendly. If you're new to open source, or coding, or git, we're happy to help you get started! Look for the `first-timers-only` or `good first issue` tags on issues, or simply post a new issue asking how you can help. We'll walk you through the steps needed to contribute to the project. + +#### Fork the Project + +Fork the project on Github by clicking on the word "Fork" above and to the right of this page. This will create your own fork at https://github.com/yournamehere/oshi.git. Then clone your fork to your local repository on your machine using these commands: +``` +git clone https://github.com/yournamehere/oshi.git +cd oshi +git remote add upstream https://github.com/oshi/oshi.git +``` + +#### Create a Topic Branch + +Make sure your fork is up-to-date and create a topic branch for your feature or bug fix. + +``` +git checkout master +git pull upstream master +git checkout -b my-feature-branch +``` + +#### Build and Test + +Ensure that you can build the project and run tests. + +``` +mvn test +``` + +#### Write Tests + +Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. + +We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix. + +#### Write Code + +Implement your feature or bug fix. + +Make sure that `mvn test` completes without errors. + +#### Write Documentation + +Document any external behavior in the [README](README.md). + +#### Update Changelog + +Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Make it look like every other line, including your name and link to your Github account. + +#### Commit Changes + +Make sure git knows your name and email address: + +``` +git config --global user.name "Your Name" +git config --global user.email "contributor@example.com" +``` + +Writing good commit logs is important. A commit log should describe what changed and why. + +``` +git add ... +git commit +``` + +#### Push + +``` +git push origin my-feature-branch +``` + +#### Make a Pull Request + +Go to https://github.com/contributor/oshi and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days. + +#### Rebase + +If you've been working on a change for a while, rebase with upstream/master. + +``` +git fetch upstream +git rebase upstream/master +git push origin my-feature-branch -f +``` + +#### Update CHANGELOG Again + +Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows. + +``` +* [#123](https://github.com/oshi/oshi/pull/123): Reticulated splines - [@contributor](https://github.com/contributor). +``` + +Amend your previous commit and force push the changes. + +``` +git commit --amend +git push origin my-feature-branch -f +``` + +#### Check on Your Pull Request + +Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above. + +#### Be Patient + +It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there! + +#### Thank You + +Please do know that we really appreciate and value your time and work. We love you, really. diff --git a/reference/FAQ.md b/reference/FAQ.md new file mode 100644 index 0000000..9fc0a5b --- /dev/null +++ b/reference/FAQ.md @@ -0,0 +1,38 @@ +What is the intended use of the API? +======== +Users should create a new instance of [SystemInfo](http://oshi.github.io/oshi/apidocs/oshi/SystemInfo.html). This provides access to the platform-specific hardware and software interfaces using the respective `get*()` methods. The interfaces in `oshi.hardware` and `oshi.software.os` provide cross-platform functionality. See the `main()` method of [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) for sample code. + +Methods return a "snapshot" of current levels. To display values which change over time, it is intended that users poll for information no more frequently than approximately every second. Disk and file system calls may incur some latency and should be polled less frequently. + +Is the API compatible between versions? +======== +The interfaces and classes in `oshi.hardware` and `oshi.software.os` are considered the OSHI API and are guaranteed to be compatible with the same major version. Differences between major versions can be found in the [UPGRADING.md](UPGRADING.md) document. + +Most, if not all, of the platform-specific implementations of these APIs in lower level packages will remain the same, although it is not intended that users access platform-specific code, and some changes may occur between minor versions. Supporting code in the `oshi.util` package may, rarely, change between minor versions, usually associated with organizing package structure or changing parsing methods for efficiency/consistency/ease of use. + +Code in the platform-specific `oshi.jna.*` packages is intended to be temporary and will be removed when that respective code is included in the JNA project. + +What minimum Java version is required? +======== +OSHI 3.x is compatible with Java 7 and will remain so with bug fixes. OSHI 4.x requires minimum Java 8 compatibility, and OSHI 5.x (envisioned in 2020) will require Java 11. + +Which operating systems are supported? +======== +OSHI has been implemented and tested on the following systems. Some features may work on earlier versions. +* Windows 7 and higher. (Nearly all features work on Vista and most work on Windows XP.) +* Mac OS X version 10.6 (Snow Leopard) and higher +* Linux (Most major distributions) Kernel 2.6 and higher +* Unix: Solaris 11 (SunOS 5.11) / FreeBSD 10 + + +What API features are not implemented on some operating systems? +======== +The following generally summarizes known exceptions. If you have missing data that is not on this list, please report it in an issue so we can investigate. +* Windows does not provide a load average, so the Processor's `getSystemLoadAverage()` returns -1. +* MacOS does not track time processors spend idle due to hard disk latency (iowait) or time spent processing hardware or software interrupts, and returns 0 for those associated tick values. +* Windows sensor (temperature, fans, voltage) readings are drawn from Microsoft's Windows Management Instrumentation (WMI) API; however, most hardware manufacturers do not publish these readings to WMI. If a value is not available through the Microsoft API, Oshi will attempt to retrieve values as published by the [Open Hardware Monitor](http://openhardwaremonitor.org/) if it is running. Only temperature sensors are detected on FreeBSD using `coretemp`. +* Linux, Solaris, and FreeBSD may require either running as root/sudo or additional software installs for full capability, particularly HAL daemon (`hald`/`lshal`) and X (`xrandr`). + +Will you implement ... ? +======== +Maybe! If you can contribute all the code to implement the feature, it will almost certainly be added. Even if you can't code but can provide pointers to where the information can be found cross-platform, your feature has a good chance. Otherwise, you can always submit an issue to ask, but are at the mercy of the developers' time, enthusiasm level, and the availability of documentation for the feature. diff --git a/reference/LICENSE_HEADER b/reference/LICENSE_HEADER new file mode 100644 index 0000000..7837e10 --- /dev/null +++ b/reference/LICENSE_HEADER @@ -0,0 +1,21 @@ +OSHI (https://github.com/oshi/oshi) + +Copyright (c) 2010 - 2019 The OSHI Project Team: +https://github.com/oshi/oshi/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/reference/README.md b/reference/README.md new file mode 100644 index 0000000..509d037 --- /dev/null +++ b/reference/README.md @@ -0,0 +1,229 @@ +![OSHI](https://dl.dropboxusercontent.com/s/c82qboyvvudpvdp/oshilogo.png) + +[![Maven central](https://maven-badges.herokuapp.com/maven-central/com.github.oshi/oshi-core/badge.svg?)](https://search.maven.org/search?q=com.github.oshi) +[![Travis Build Status](https://travis-ci.org/oshi/oshi.svg)](https://travis-ci.org/oshi/oshi) +[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/v489i8xoyfspxx7s?svg=true)](https://ci.appveyor.com/project/dbwiddis/oshi) +[![Coverage Status](https://coveralls.io/repos/github/oshi/oshi/badge.svg?branch=master)](https://coveralls.io/github/oshi/oshi?branch=master) +[![codecov.io](https://codecov.io/github/oshi/oshi/coverage.svg?branch=master)](https://codecov.io/github/oshi/oshi?branch=master) +[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/9332.svg)](https://scan.coverity.com/projects/dblock-oshi) +[![Codacy Grade](https://api.codacy.com/project/badge/Grade/5370178ae91d4f56b43de2f26f7c5e7a)](https://www.codacy.com/app/widdis/oshi?utm_source=github.com&utm_medium=referral&utm_content=oshi/oshi&utm_campaign=Badge_Grade) +[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![SonarQube Bugs](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=bugs)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Maintainability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Reliability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Security](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=security_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/oshi/oshi.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/oshi/oshi/context:java) +[![LGTM Stats](https://www.openhub.net/p/oshi/widgets/project_thin_badge.gif)](https://www.openhub.net/p/oshi?ref=github) +[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/) +[![Join the chat at https://gitter.im/oshi/oshi](https://badges.gitter.im/oshi/oshi.svg)](https://gitter.im/oshi/oshi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/dbwiddis) + +OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java. +It does not require the installation of any additional native libraries and aims to provide a +cross-platform implementation to retrieve system information, such as OS version, processes, +memory & CPU usage, disks & partitions, devices, sensors, etc. + +Supported platforms +--------------------------- +Windows • Linux • Mac OS X • Unix (Solaris, FreeBSD) + +Essentials +---------- +* [API](http://oshi.github.io/oshi/apidocs/) +* [Find OSHI on Maven Central](https://search.maven.org/search?q=com.github.oshi) +* [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md) +* [Upgrading from an earlier version?](https://github.com/oshi/oshi/blob/master/UPGRADING.md) + +Supported features +-------------------------- +* Computer System and firmware, baseboard +* Operating System and Version/Build +* Physical (core) and Logical (hyperthreaded) CPUs +* System and per-processor load % and tick counters +* CPU uptime, processes, and threads +* Process uptime, CPU, memory usage +* Physical and virtual memory used/available +* Mounted filesystems (type, usable and total space) +* Disk drives (model, serial, size) and partitions +* Network interfaces (IPs, bandwidth in/out) +* Battery state (% capacity, time remaining) +* Connected displays (with EDID info) +* USB Devices +* Sensors (temperature, fan speeds, voltage) + +Downloads +--------- +| Stable Release Version | Current Development Version | Dependencies | +| ------------- | ------------- | ------------- | +| [oshi-core-3.13.3](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.github.oshi&a=oshi-core&v=3.13.3&e=jar) | [oshi-core-4.0.0-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.github.oshi&a=oshi-core&v=4.0.0-SNAPSHOT&e=jar) | [JNA](https://github.com/java-native-access/jna) • [SLF4J](http://www.slf4j.org/) | + +Output +------------- +OSHI provides output directly via Java methods for each of its interfaces. +By periodically polling dynamic information (e.g., every second), users can calculate and track changes. + +The `main()` method of [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +provides sample code demonstrating the use of `oshi-core` interfaces to retrieve information and calculate additional metrics shown in the examples below. + +General information about the operating system and computer system. +``` +Apple macOS 10.12.3 (Sierra) build 16D32 +manufacturer: Apple Inc. +model: MacBook Pro (MacBookPro8,2) +serialnumber: C02FG6XYDF71 +``` +Processor identification. +``` +Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz + 4 physical CPU(s) + 8 logical CPU(s) +Identifier: Intel64 Family 6 Model 42 Stepping 7 +ProcessorID: BFEBFBFF000206A7 +``` +By measuring ticks (user, nice, system, idle, iowait, and irq) between time intervals, percent usage can be calculated. +Java MXBean and per-processor information is also provided. +``` +CPU, IOWait, and IRQ ticks @ 0 sec:[967282, 15484, 195343, 124216619], 6176, [4054, 2702] +CPU, IOWait, and IRQ ticks @ 1 sec:[967308, 15484, 195346, 124216790], 6177, [4057, 2705] +User: 13.0% Nice: 0.0% System: 1.5% Idle: 85.5% +CPU load: 8.8% (counting ticks) +CPU load: 9.0% (OS MXBean) +CPU load averages: 2.69 2.47 2.38 +CPU load per processor: 23.6% 1.3% 18.2% 0.7% 12.9% 0.7% 12.1% 1.3% +``` +Process information including CPU and memory per process is available. +``` +Processes: 401, Threads: 1159 + PID %CPU %MEM VSZ RSS Name + 55977 27.9 0.2 6.8 GiB 34.3 MiB java + 51820 18.7 5.6 6.3 GiB 919.2 MiB eclipse + 39272 11.2 17.8 7.1 GiB 2.8 GiB prl_vm_app + 85316 6.5 2.9 5.6 GiB 471.4 MiB thunderbird + 35301 5.4 0.5 1.7 GiB 89.8 MiB Microsoft Excel + ``` +Memory and swapfile information is available. +``` +Memory: 2.9 GiB/16 GiB +Swap used: 90.8 MiB/1 GiB +``` +The EDID for each Display is provided. This can be parsed with various utilities for detailed information. OSHI provides a summary of selected data. +``` +Displays: + Display 0: + Manuf. ID=SAM, Product ID=2ad, Analog, Serial=HA19, ManufDate=3/2008, EDID v1.3 + 41 x 27 cm (16.1 x 10.6 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: H9FQ345476 + Display 1: + Manuf. ID=SAM, Product ID=226, Analog, Serial=HA19, ManufDate=4/2007, EDID v1.3 + 41 x 26 cm (16.1 x 10.2 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: HMCP431880 +``` +Disks and usage (reads, writes, transfer times) are shown, and partitions can be mapped to filesystems. +``` +Disks: + disk0: (model: SanDisk Ultra II 960GB - S/N: 161008800550) size: 960.2 GB, reads: 1053132 (23.0 GiB), writes: 243792 (11.1 GiB), xfer: 73424854 ms + |-- disk0s1: EFI (EFI System Partition) Maj:Min=1:1, size: 209.7 MB + |-- disk0s2: Macintosh HD (Macintosh SSD) Maj:Min=1:2, size: 959.3 GB @ / + disk1: (model: Disk Image - S/N: ) size: 960.0 GB, reads: 3678 (60.0 MiB), writes: 281 (8.6 MiB), xfer: 213627 ms + |-- disk1s1: EFI (EFI System Partition) Maj:Min=1:4, size: 209.7 MB + |-- disk1s2: Dropbox (disk image) Maj:Min=1:5, size: 959.7 GB @ /Volumes/Dropbox + +``` +Sensor readings are available for some hardware (see notes in the [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md)). +``` +Sensors: + CPU Temperature: 69.8°C + Fan Speeds:[4685, 4687] + CPU Voltage: 3.9V +``` +Attached USB devices can be listed: +``` +USB Devices: + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- IR Receiver (Apple Computer, Inc.) + |-- USB Receiver (Logitech) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- FaceTime HD Camera (Built-in) (Apple Inc.) [s/n: DJHB1V077FDH5HL0] + |-- IOUSBHostDevice + |-- Apple Internal Keyboard / Trackpad (Apple Inc.) + |-- BRCM2070 Hub (Apple Inc.) + |-- Bluetooth USB Host Controller (Apple Inc.) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- Apple Thunderbolt Display (Apple Inc.) [s/n: 162C0C25] + |-- Display Audio (Apple Inc.) [s/n: 162C0C25] + |-- FaceTime HD Camera (Display) (Apple Inc.) [s/n: CCGCAN000TDJ7DFX] + |-- USB2.0 Hub + |-- ANT USBStick2 (Dynastream Innovations) [s/n: 051] + |-- Fitbit Base Station (Fitbit Inc.) +``` + +You can run the [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +and see the full output for your system by cloning the project and building it with [Maven](http://maven.apache.org/index.html). + +``` +git clone https://github.com/oshi/oshi.git && cd oshi + +mvn test-compile -pl oshi-core -q exec:java \ + -Dexec.mainClass="oshi.SystemInfoTest" \ + -Dexec.classpathScope="test" +``` + +Where are we? +------------- +[OSHI originated](http://code.dblock.org/2010/06/23/introducing-oshi-operating-system-and-hardware-information-java.html) +as a platform-independent library that did not require additional software and had a license compatible with +both open source and commercial products. We have developed a strong core of features on major Operating Systems, +but we would love for *you* to help by: +* Testing! Our CI testing is limited. Download and test the program on various operating systems/versions and hardware and help identify gaps that our limited development and testing may have missed. +* Contributing ports. Have an OS that's not covered? It's likely one of the existing ports can be slightly modified. +* Contributing code. See something that's not working right or could work better? Help us fix it! New contributors welcome. +* Documenting implementation. Our Wiki is blank. Want to help new users follow in your footsteps? +* Suggesting new features. Do you need OSHI to do something it doesn't currently do? Let us know. + +Acknowledgements +------------------- +Many thanks to the following companies for providing free support of Open Source projects including OSHI: +* [SonarCloud](https://sonarcloud.io/about) for a range of code quality tools +* [Travis CI](https://travis-ci.org/) for continuous integration testing +* The [jProfile Java Profiler](https://www.ej-technologies.com/products/jprofiler/overview.html) used to eliminate cpu bottlenecks + +Projects using OSHI +------------------- +* [CAS Server](https://apereo.github.io/cas) +* [JPPF](https://jppf.org/) +* [Apache Flink](https://flink.apache.org/) +* [DeepLearning4J](https://deeplearning4j.org/) +* [PSI Probe](https://github.com/psi-probe/psi-probe) +* [GigaSpaces XAP](https://xap.github.io/) +* [openHAB Systeminfo Binding](https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.systeminfo) +* [Jenkins swarm plugin](https://wiki.jenkins.io/display/JENKINS/Swarm+Plugin) +* [Java for IBM Watson IoT Platform](https://ibm-watson-iot.github.io/iot-java/) +* [Semux](https://www.semux.org/) +* [Arthas](https://alibaba.github.io/arthas/en/) +* [Hawkular Agent](https://github.com/hawkular/hawkular-agent) +* [GeoServer](https://docs.geoserver.org/stable/en/user/community/status-monitoring/index.html) +* [UniversalMediaServer](https://github.com/UniversalMediaServer/UniversalMediaServer) +* [Dagr](https://github.com/fulcrumgenomics/dagr) +* [sys-API](https://github.com/Krillsson/sys-API) +* [NexCapMAT](http://www.nexess-solutions.com/fr/produits/application-nexcap-mat/) +* [360Suite](https://360suite.io/) +* [GoMint](https://gomint.io/) +* [Stefan's OS](https://BotCompany.de/) +* [Eclipse Passage](https://projects.eclipse.org/projects/technology.passage) +* [Eclipse Orbit](https://projects.eclipse.org/projects/tools.orbit) + +License +------- +This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/reference/RELEASING.md b/reference/RELEASING.md new file mode 100644 index 0000000..659f8b4 --- /dev/null +++ b/reference/RELEASING.md @@ -0,0 +1,49 @@ +Releasing OSHI +===================== +### Credentials + +* Put your [repository credentials in your Maven settings.xml file](http://central.sonatype.org/pages/apache-maven.html#distribution-management-and-authentication) for both snapshot and staging repositories in [pom.xml](pom.xml). +* Put your [gpg certificate credentials in the settings.xml file](http://central.sonatype.org/pages/apache-maven.html#gpg-signed-components) + +### Snapshots + +* Snapshot releases may be deployed using `mvn clean deploy` + * The version number in the pom.xml must end in -SNAPSHOT + +### Prepare + +* Make sure tests are green on [Travis CI](https://travis-ci.org/oshi/oshi). +* Review [SonarQube](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) for any bugs. +* Run `mvn clean test` on every OS you have access to +* Choose an appropriate [version number](http://semver.org/) for the release + * Proactively change version numbers in the download links on [README.md](README.md). + * Copy [README.md](README.md) to [src/site/markdown/README.md](src/site/markdown/README.md) + * HTML-escape `&`, `<`, and `>` in any links in the site version + * Change "Next" or in-progress version in [CHANGELOG.md](CHANGELOG.md) to this new version. + * Move "Your contribution here." to a new empty "Next" section + * Commit changes as a "prep for x.x release" + +### Release + +* See [this page](http://central.sonatype.org/pages/apache-maven.html#performing-a-release-deployment-with-the-maven-release-plugin) for a summary of the below steps +* `mvn clean deploy` + * Do a final snapshot release and fix any errors in the javadocs + * If license headers are rewritten as part of this deployment, commit the changes +* `mvn release:clean` + * Takes a few seconds +* `mvn release:prepare` + * Takes a few minutes + * This will ask for the version being released, removing -SNAPSHOT + * This will suggest the next version, increment appropriately +* `mvn release:perform` + * Takes a few minutes. + * This pushes the release to the [Nexus](https://oss.sonatype.org/) staging repository + * This also pushes to [gh_pages](https://oshi.github.io/oshi) +* Log on to [Nexus](https://oss.sonatype.org/) and [release the deployment from OSSRH to the Central Repository](http://central.sonatype.org/pages/releasing-the-deployment.html). + +* Add a title and release notes [to the tag](https://github.com/oshi/oshi/tags) on GitHub and publish the release to make it current. + +* As development progresses, update version in [pom.xml](pom.xml) using -SNAPSHOT appended to the new version using [Semantic Versioning](http://semver.org/) standards: + * Increment major version (x.0) for API-breaking changes or additions + * Increment minor version (x.1) for substantive additions, bugfixes and changes that are backwards compatible + * Increment patch version (x.x.1) for minor bugfixes or changes that are backwards compatible diff --git a/reference/UPGRADING.md b/reference/UPGRADING.md new file mode 100644 index 0000000..97fc050 --- /dev/null +++ b/reference/UPGRADING.md @@ -0,0 +1,135 @@ + +# Guide to upgrading from OSHI 3.x to 4.x + +OSHI 4.0 requires minimum Java 8 compatibility. + +The `oshi-json` artifact has been completely removed. It is trivial to obtain +JSON output using [Jackson's ObjectMapper](http://www.mkyong.com/java/ +jackson-2-convert-java-object-to-from-json/). + +There is a new `oshi-demo` artifact which will contain many "how to" classes +to demonstrate OSHI's capabilities and integration with other libraries. + +## API Changes + +`NetworkIF#getNetworkInterface()` is now `queryNetworkInterface()` to prevent +Jackson's ObjectMapper from attempting to serialize the returned object. + +There is a new `VirtualMemory `class which is accessible with a getter from +`GlobalMemory`. Methods associated with swap file usage were moved to this +new class. + +The `CentralProcessor` setters were removed from the API. The methods +`getSystemCpuLoadBetweenTicks()` and `getProcessorCpuLoadBetweenTicks()` now take +an argument with the previous set of ticks, rather than internally saving the +previous call. This enables users to measure over a longer period or multiple +different periods. The `getSystemCpuLoad()` method is now a direct passthrough +to the `OperatingSystemMXBean` method if running an Oracle JVM, otherwise it +returns a negative value. The no-argument `getSystemLoadAverage()` has been +removed; users can call with an argument of 1 to obtain the same value. + +The `getSystemUptime()` method was moved from the `CentralProcessor` class to +the `OperatingSystem` class. + +The `NetworkIF#updateNetworkStats()` and `HWDiskStore#updateDiskStats()` methods +were renamed to `updateAttributes()` to conform to other similarly named methods +to permit update of individual elements of arrays. + +# Guide to upgrading from OSHI 2.x to 3.x + +The most significant change in OSHI 3.0 is the separation of JSON output to a +separate artifact, filtering output using configurable properties. Users of +`oshi-core` who do not require JSON will find most of the API the same except +as noted below. Those who use JSON will find improved functionality in the +`oshi-json` module. + +## API Changes - oshi-core + +The `CentralProcessor`'s `getSystemIOWaitTicks()` and `getSystemIrqTicks()` +methods were removed. The `getSystemCpuLoadTicks()` now include the IOWait and +IRQ tick information previously reported by those methods, although Idle time +no longer includes IOWait, and System Time no longer includes IRQ ticks. The +`getProcessorCpuLoadTicks()` now includes per-processor IOWait and IRQ tick +information. + +The `getFileSystem()` method was moved from the `HardwareAbstractionLayer` to +the `OperatingSystem`. The `getFileStores()` method on the +`HardwareAbstractionLayer` was redundant with the same method on the +`FileSystem` class and was removed. + +The `OSProcess` methods (`getProcesses()`, `getProcess()`, `getProcessId()`, +`getProcessCount()`, and `getThreadCount()`) were moved from the +`CentralProcessor` to the `OperatingSystem`. + +The (`OperatingSystem`'s) `getProcesses()` method now takes two arguments, to +limit the number of results returned, and to sort the results. + +The `HardwareAbstractionLayer`'s `getUsbDevices()` method now takes a boolean +argument which offers both the existing tree-based or a flat list format. + +The `Networks` interface had an `updateNetworkStats()` method that was not +reachable from cross-platform code. That method is now on the `NetworkIF` +class. + +## API Changes - oshi-json + +Decorator classes for the OSHI API which enable JSON functionality are now in +the `oshi.json.*` packages with the same API changes in the previous section. + +JSON objects associated with the above method changes were updated: + - `systemCpuLoadTicks` and `processorCpuLoadTicks` now have 7-element arrays + instead of 4, and the `systemIOWaitTicks` and `systemIrqTicks` elements have + been removed from the `processor` object. + - `fileSystem` is now an element of `operatingSystem` rather than `processor`. + - `fileStores` is now an element of `fileSystem` rather than `processor`. + - `processID`, `processCount`, `threadCount`, and `processes` are now + elements of `operatingSystem` rather than `processor`. + +While the existing `toJSON()` method remains and is backwards compatible, the +new API permits using a `java.util.Properties` object as an optional parameter +which will be persistent to future (no argument) calls to that method until +replaced. See the [FAQ](FAQ.md) for more information. + +# Guide to upgrading from OSHI 1.x to 2.x + +Even though it's a major release, OSHI 2.0 functionality is identical to +1.5.2. For the most part, the highest level APIs demonstrated in the test +classes have remained the same, except as documented below. Several lower +level packages and classes have been moved and/or renamed. + +## Package Changes + +New packages `oshi.jna.platform.*` were created and code which extends +`com.sun.jna.Library` was moved into its respective platform library. These +classes should be considered non-API as they may be removed if/when their +code is incorporated into the JNA project. + +New packages `oshi.hardware.platform.*` were created and contain the +platform-specific implementations of interfaces in `oshi.hardware`, with +implementing classes renamed to prepend the platform name to the interface +name. Similar renaming was done for implementations of `oshi.software.os` +in the respective `oshi.software.os.*` packages. + +## API Changes + +The `Memory` interface was renamed `GlobalMemory` to avoid name conflict with +JNA's `Memory` class. + +The `Processor` interface, which represented one of an array of logical +processor objects, was renamed `CentralProcessor` and represents the entire +System CPU which may contain multiple logical processors. Methods applicable +to an individual logical processor were modified to return arrays. + +The `HardwareAbstractionLayer`'s `getProcessors()` method was renamed to +`getProcessor()` and now returns a singular `CentralProcessor` object. + +Specific changes to `CentralProcessor` methods: +* The constructor no longer takes a processor number argument and the +`getProcessorNumber()` method was removed +* The deprecated `getLoad()` method was removed. Use +`getSystemCpuLoadBetweenTicks()`. +* The `getProcessorCpuLoadBetweenTicks()` method now returns an array of +load values, one value for each logical processor. +* The `getProcessorCpuLoadTicks()` method now returns a two dimensional +array; one array per logical processor, each containing the tick values +previously returned for a single processor. diff --git a/reference/appveyor.yml b/reference/appveyor.yml new file mode 100644 index 0000000..5fac482 --- /dev/null +++ b/reference/appveyor.yml @@ -0,0 +1,52 @@ +# +# OSHI (https://github.com/oshi/oshi) +# +# Copyright (c) 2010 - 2019 The OSHI Project Team: +# https://github.com/oshi/oshi/graphs/contributors +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +version: '{build}' + +image: Visual Studio 2017 + +branches: + except: + - coverity_scan + +skip_tags: true + +environment: + TERM: dumb + matrix: + - JAVA_HOME: C:\Program Files\Java\jdk1.8.0 + - JAVA_HOME: C:\Program Files\Java\jdk11 + +init: + - git config --global --unset core.autocrlf + +install: + - mvn --version + - java -version + +build_script: + - appveyor-retry mvn clean package -Dmaven.test.skip=true + +test_script: + - mvn test diff --git a/reference/definitions-full.json b/reference/definitions-full.json deleted file mode 100644 index 22ad436..0000000 --- a/reference/definitions-full.json +++ /dev/null @@ -1,925 +0,0 @@ -[ - { - "name": "hardware.Nic", - "root": true, - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": "The interface's name" - }, - { - "name": "description", - "type": "String", - "constant": true, - "desc": "The interface's description" - }, - { - "name": "mtu", - "type": "Integer", - "desc": "The maximum transmission unit" - }, - { - "name": "mac", - "type": "String", - "desc": null - }, - { - "name": "virtual", - "type": "Boolean", - "desc": null - }, - { - "name": "ipv4", - "type": "String[]", - "desc": "The interface's IPv4 addresses" - }, - { - "name": "ipv6", - "type": "String[]", - "desc": "The interface's IPv6 addresses" - }, - { - "name": "broadcast", - "type": "String", - "desc": null - }, - { - "name": "netmask", - "type": "String", - "desc": "The interface's subnet mask" - }, - { - "name": "read_bytes", - "type": "Long", - "desc": "The number of bytes read from the interface" - }, - { - "name": "write_bytes", - "type": "Long", - "desc": "The number of bytes written to the interface" - }, - { - "name": "read_packets", - "type": "Long", - "desc": "The number of packets read from the interface" - }, - { - "name": "write_packets", - "type": "Long", - "desc": "The number of packets written to the interface" - }, - { - "name": "read_errors", - "type": "Long", - "desc": "The number of read errors" - }, - { - "name": "write_errors", - "type": "Long", - "desc": "The number of write errors" - }, - { - "name": "read_drops", - "type": "Long", - "desc": "The number of read drops" - }, - { - "name": "write_drops", - "type": "Long", - "desc": "The number of write drops" - }, - { - "name": "write_collisions", - "type": "Long", - "desc": "The number of write collisions" - }, - { - "name": "link_speed", - "type": "Long", - "desc": "The interface's maximum speed in bytes" - }, - { - "name": "default_gateway", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_up", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_running", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_loopback", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_multicast", - "type": "Boolean", - "desc": null - }, - { - "name": "luid", - "type": "Long", - "desc": "The interface's locally unique identifier", - "compatible": [ - "windows" - ] - }, - { - "name": "guid", - "type": "String", - "desc": "The interface's globally unique identifier", - "compatible": [ - "windows" - ] - }, - { - "name": "paused", - "type": "Boolean", - "desc": "Whether the interface is in a paused state", - "compatible": [ - "windows" - ] - }, - { - "name": "lowPower", - "type": "Boolean", - "desc": "Whether the interface is in a low-power state", - "compatible": [ - "windows" - ] - } - ] - }, - { - "name": "hardware.Disk", - "root": true, - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "model", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "serial", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "size", - "type": "Long", - "desc": "The disk's total size in bytes" - }, - { - "name": "reads", - "type": "Long", - "desc": null - }, - { - "name": "read_bytes", - "type": "Long", - "desc": null - }, - { - "name": "writes", - "type": "Long", - "desc": null - }, - { - "name": "write_bytes", - "type": "Long", - "desc": null - }, - { - "name": "queue_length", - "type": "Long", - "desc": null - }, - { - "name": "transfer_time", - "type": "Long", - "desc": null - }, - { - "name": "model_family", - "type": "String", - "desc": null - }, - { - "name": "firmware_version", - "type": "String", - "desc": null - }, - { - "name": "rotation_rate", - "type": "Long", - "desc": null - }, - { - "name": "read_error_rate", - "type": "Long", - "desc": null - }, - { - "name": "spin_up_time", - "type": "Long", - "desc": null - }, - { - "name": "start_stop_cycles", - "type": "Long", - "desc": null - }, - { - "name": "reallocated_sectors", - "type": "Long", - "desc": null - }, - { - "name": "seek_error_rate", - "type": "Long", - "desc": null - }, - { - "name": "power_on_time", - "type": "Long", - "desc": null - }, - { - "name": "spin_retries", - "type": "Long", - "desc": null - }, - { - "name": "calibration_retries", - "type": "Long", - "desc": null - }, - { - "name": "power_cycles", - "type": "Long", - "desc": null - }, - { - "name": "poweroff_retracts", - "type": "Long", - "desc": null - }, - { - "name": "load_cycles", - "type": "Long", - "desc": null - }, - { - "name": "temperature", - "type": "Long", - "desc": null - }, - { - "name": "reallocated_events", - "type": "Long", - "desc": null - }, - { - "name": "current_pending_sector", - "type": "Long", - "desc": null - }, - { - "name": "offline_uncorrectable", - "type": "Long", - "desc": null - }, - { - "name": "crc_errors", - "type": "Long", - "desc": null - }, - { - "name": "multizone_error_rate", - "type": "Long", - "desc": null - } - ] - }, - { - "name": "hardware.Partition", - "attributes": [ - { - "name": "identification", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "desc", - "type": "String", - "desc": null - }, - { - "name": "uuid", - "type": "String", - "desc": "The partition's UUID" - }, - { - "name": "size", - "type": "Long", - "desc": "The partition's total size in bytes" - }, - { - "name": "major", - "type": "Integer", - "desc": null - }, - { - "name": "minor", - "type": "Integer", - "desc": null - }, - { - "name": "mount", - "type": "String", - "desc": "The partition's mount point" - } - ] - }, - { - "name": "hardware.Cpu", - "root": true, - "attributes": [ - { - "name": "model", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "vendor", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "frequency_spec", - "type": "Integer", - "desc": "The specified frequency in Hertz" - }, - { - "name": "l1_cache", - "type": "Integer", - "desc": "The size of the L1 cache in bytes" - }, - { - "name": "l2_cache", - "type": "Integer", - "desc": "The size of the L2 cache in bytes" - }, - { - "name": "l3_cache", - "type": "Integer", - "desc": "The size of the L3 cache in bytes" - }, - { - "name": "l4_cache", - "type": "Integer", - "desc": "The size of the L4 cache in bytes" - } - ] - }, - { - "name": "hardware.CpuCore", - "attributes": [ - { - "name": "usage", - "type": "Double", - "desc": "The core's usage between 0.0 and 1.0" - }, - { - "name": "temperature", - "type": "Double", - "desc": "The core's temperature in Celsius" - } - ] - }, - { - "name": "hardware.CpuThread", - "attributes": [ - { - "name": "id", - "type": "Integer", - "constant": true, - "desc": "The thread's ID" - } - ] - }, - { - "name": "hardware.Gpu", - "root": true, - "attributes": [ - { - "name": "model", - "type": "String", - "constant": true, - "desc": "The GPU's model string" - }, - { - "name": "vendor", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "memory_size", - "type": "Long", - "desc": null - } - ] - }, - { - "name": "hardware.Memory", - "root": true, - "singular": true, - "attributes": [ - { - "name": "total", - "type": "Long", - "desc": null - }, - { - "name": "free", - "type": "Long" - }, - { - "name": "page_size", - "type": "Long" - }, - { - "name": "swap_size", - "type": "Long" - }, - { - "name": "swap_used", - "type": "Long" - }, - { - "name": "pages_in", - "type": "Long", - "desc": "The number of pages read from swap" - }, - { - "name": "pages_out", - "type": "Long", - "desc": "The number of pages in swap" - } - ] - }, - { - "name": "hardware.Power", - "root": true, - "attributes": [ - { - "name": "name", - "type": "String", - "desc": null - }, - { - "name": "remaining_capacity", - "type": "Double", - "desc": null - }, - { - "name": "remaining_time", - "type": "Double", - "desc": null - } - ] - }, - { - "name": "hardware.Firmware", - "root": true, - "singular": true, - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "manufacturer", - "type": "String", - "constant": true, - "desc": "The BIOS manufacturer title" - }, - { - "name": "description", - "type": "String", - "constant": true, - "desc": "The BIOS description" - }, - { - "name": "version", - "type": "String", - "constant": true, - "desc": "The BIOS version number" - }, - { - "name": "revision", - "type": "String", - "constant": true, - "desc": "The BIOS revision number" - }, - { - "name": "release_date", - "type": "String", - "constant": true, - "desc": "The BIOS release date" - }, - { - "name": "uefi", - "type": "Boolean", - "constant": true, - "desc": "Whether the BIOS supports UEFI mode", - "compatible": [ - "linux" - ] - } - ] - }, - { - "name": "hardware.Mainboard", - "root": true, - "singular": true, - "attributes": [ - { - "name": "model", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "manufacturer", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "version", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "serial_number", - "type": "String", - "constant": true, - "desc": null - } - ] - }, - { - "name": "hardware.Sensor", - "root": true, - "attributes": [ - { - "name": "fan_speed", - "type": "Integer", - "desc": null - }, - { - "name": "temperature", - "type": "Double", - "desc": null - }, - { - "name": "voltage", - "type": "Double", - "desc": null - } - ] - }, - { - "name": "hardware.SoundCard", - "root": true, - "attributes": [ - { - "name": "driver_version", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "codec", - "type": "String", - "desc": null - } - ] - }, - { - "name": "hardware.Display", - "root": true, - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": "The display's name" - }, - { - "name": "edid", - "type": "String", - "desc": null - }, - { - "name": "resolution", - "type": "String", - "desc": "The display's resolution" - }, - { - "name": "size", - "type": "String", - "constant": true, - "desc": "The display's physical size in pixels" - }, - { - "name": "refresh_frequency", - "type": "Integer", - "desc": "Refresh frequency in Hertz" - }, - { - "name": "bit_depth", - "type": "Integer", - "desc": null - } - ] - }, - { - "name": "hardware.UsbDevice", - "root": true, - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "vendor", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "vendor_id", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "product_id", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "serial_number", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "children", - "type": "UsbDevice[]", - "desc": null - } - ] - }, - { - "name": "software.User", - "root": true, - "attributes": [ - { - "name": "id", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "username", - "type": "String", - "desc": "The user's username" - }, - { - "name": "home", - "type": "String", - "desc": "The user's home directory path" - } - ] - }, - { - "name": "software.Process", - "root": true, - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "path", - "type": "String", - "desc": null - }, - { - "name": "command", - "type": "String", - "desc": null - }, - { - "name": "working_directory", - "type": "String", - "desc": null - }, - { - "name": "user", - "type": "String", - "desc": null - }, - { - "name": "user_id", - "type": "String", - "desc": null - }, - { - "name": "group", - "type": "String", - "desc": null - }, - { - "name": "group_id", - "type": "String", - "desc": null - }, - { - "name": "state", - "type": "String", - "desc": null - }, - { - "name": "pid", - "type": "Integer", - "constant": true, - "desc": "The process's process ID" - }, - { - "name": "parent_pid", - "type": "Integer", - "desc": null - }, - { - "name": "thread_count", - "type": "Integer", - "desc": null - }, - { - "name": "priority", - "type": "Integer", - "desc": null - }, - { - "name": "virtual_size", - "type": "Long", - "desc": null - }, - { - "name": "resident_set_size", - "type": "Long", - "desc": "The resident memory size in bytes" - }, - { - "name": "kernel_time", - "type": "Long", - "desc": "The number of milliseconds the process has executed in kernel mode" - }, - { - "name": "user_time", - "type": "Long", - "desc": "The number of milliseconds the process has executed in user mode" - }, - { - "name": "start_time", - "type": "Long", - "desc": "The epoch timestamp of the process start time" - }, - { - "name": "bytes_read", - "type": "Long", - "desc": "The number of bytes the process has read from disk" - }, - { - "name": "bytes_written", - "type": "Long", - "desc": "The number of bytes the process has written to disk" - }, - { - "name": "handle_count", - "type": "Long", - "desc": "The number of file handles that the process owns" - } - ] - }, - { - "name": "software.OS", - "root": true, - "singular": true, - "attributes": [ - { - "name": "family", - "type": "String", - "constant": true, - "desc": "The operating system's family" - }, - { - "name": "manufacturer", - "type": "String", - "constant": true, - "desc": "The operating system's manufacturer" - }, - { - "name": "bitness", - "type": "Integer", - "constant": true, - "desc": "The operating system's register width in bits" - }, - { - "name": "version", - "type": "String", - "constant": true, - "desc": "The operating system's primary version" - }, - { - "name": "codename", - "type": "String", - "constant": true, - "desc": "The operating system's code name" - }, - { - "name": "build_number", - "type": "String", - "constant": true, - "desc": "The operating system's build number" - } - ] - }, - { - "name": "software.Network", - "root": true, - "singular": true, - "attributes": [ - { - "name": "hostname", - "type": "String", - "desc": "The host's hostname" - }, - { - "name": "fqdn", - "type": "String", - "desc": "The host's fully-qualified domain name" - }, - { - "name": "dns", - "type": "String[]", - "desc": "The host's DNS servers" - } - ] - } -] \ No newline at end of file diff --git a/reference/definitions.json b/reference/definitions.json deleted file mode 100644 index 13b0726..0000000 --- a/reference/definitions.json +++ /dev/null @@ -1,396 +0,0 @@ -[ - { - "name": "hardware.Nic", - "root": true, - "desc": "A network interface", - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": "The interface's name" - }, - { - "name": "description", - "type": "String", - "constant": true, - "desc": "The interface's description" - }, - { - "name": "mtu", - "type": "Integer", - "desc": "The maximum transmission unit" - }, - { - "name": "mac", - "type": "String", - "desc": null - }, - { - "name": "virtual", - "type": "Boolean", - "desc": null - }, - { - "name": "ipv4", - "type": "String[]", - "desc": "The interface's IPv4 addresses" - }, - { - "name": "ipv6", - "type": "String[]", - "desc": "The interface's IPv6 addresses" - }, - { - "name": "broadcast", - "type": "String", - "desc": null - }, - { - "name": "netmask", - "type": "String", - "desc": "The interface's subnet mask" - }, - { - "name": "read_bytes", - "type": "Long", - "desc": "The number of bytes read from the interface" - }, - { - "name": "write_bytes", - "type": "Long", - "desc": "The number of bytes written to the interface" - }, - { - "name": "read_packets", - "type": "Long", - "desc": "The number of packets read from the interface" - }, - { - "name": "write_packets", - "type": "Long", - "desc": "The number of packets written to the interface" - }, - { - "name": "read_errors", - "type": "Long", - "desc": "The number of read errors" - }, - { - "name": "write_errors", - "type": "Long", - "desc": "The number of write errors" - }, - { - "name": "read_drops", - "type": "Long", - "desc": "The number of read drops" - }, - { - "name": "write_drops", - "type": "Long", - "desc": "The number of write drops" - }, - { - "name": "write_collisions", - "type": "Long", - "desc": "The number of write collisions" - }, - { - "name": "link_speed", - "type": "Long", - "desc": "The interface's maximum speed in bytes" - }, - { - "name": "default_gateway", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_up", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_running", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_loopback", - "type": "Boolean", - "desc": null - }, - { - "name": "flag_multicast", - "type": "Boolean", - "desc": null - }, - { - "name": "luid", - "type": "Long", - "desc": "The interface's locally unique identifier", - "compatible": [ - "windows" - ] - }, - { - "name": "guid", - "type": "String", - "desc": "The interface's globally unique identifier", - "compatible": [ - "windows" - ] - }, - { - "name": "paused", - "type": "Boolean", - "desc": "Whether the interface is in a paused state", - "compatible": [ - "windows" - ] - }, - { - "name": "lowPower", - "type": "Boolean", - "desc": "Whether the interface is in a low-power state", - "compatible": [ - "windows" - ] - } - ] - }, - { - "name": "hardware.Disk", - "root": true, - "desc": "A storage device", - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "model", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "serial", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "size", - "type": "Long", - "desc": "The disk's total size in bytes" - }, - { - "name": "reads", - "type": "Long", - "desc": null - }, - { - "name": "read_bytes", - "type": "Long", - "desc": null - }, - { - "name": "writes", - "type": "Long", - "desc": null - }, - { - "name": "write_bytes", - "type": "Long", - "desc": null - }, - { - "name": "queue_length", - "type": "Long", - "desc": null - }, - { - "name": "transfer_time", - "type": "Long", - "desc": null - }, - { - "name": "model_family", - "type": "String", - "extension": "smartmontools", - "desc": null - }, - { - "name": "firmware_version", - "type": "String", - "extension": "smartmontools", - "desc": null - }, - { - "name": "rotation_rate", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "read_error_rate", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "spin_up_time", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "start_stop_cycles", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "reallocated_sectors", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "seek_error_rate", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "power_on_time", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "spin_retries", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "calibration_retries", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "power_cycles", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "poweroff_retracts", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "load_cycles", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "temperature", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "reallocated_events", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "current_pending_sector", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "offline_uncorrectable", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "crc_errors", - "type": "Long", - "extension": "smartmontools", - "desc": null - }, - { - "name": "multizone_error_rate", - "type": "Long", - "extension": "smartmontools", - "desc": null - } - ] - }, - { - "name": "hardware.Firmware", - "root": true, - "singular": true, - "desc": "The system's firmware", - "attributes": [ - { - "name": "name", - "type": "String", - "constant": true, - "desc": null - }, - { - "name": "manufacturer", - "type": "String", - "constant": true, - "desc": "The BIOS manufacturer title" - }, - { - "name": "description", - "type": "String", - "constant": true, - "desc": "The BIOS description" - }, - { - "name": "version", - "type": "String", - "constant": true, - "desc": "The BIOS version number" - }, - { - "name": "revision", - "type": "String", - "constant": true, - "desc": "The BIOS revision number" - }, - { - "name": "release_date", - "type": "String", - "constant": true, - "desc": "The BIOS release date" - }, - { - "name": "uefi", - "type": "Boolean", - "constant": true, - "desc": "Whether the BIOS supports UEFI mode", - "compatible": [ - "linux" - ] - } - ] - } -] \ No newline at end of file diff --git a/reference/gen/main/java/oshi/api/FreeBsdSystem.java b/reference/gen/main/java/oshi/api/FreeBsdSystem.java deleted file mode 100644 index 14f29d8..0000000 --- a/reference/gen/main/java/oshi/api/FreeBsdSystem.java +++ /dev/null @@ -1,15 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api; - -import java.util.stream.Stream; -import oshi.api.hardware.disk.DiskFreeBsd; -import oshi.api.hardware.firmware.FirmwareFreeBsd; -import oshi.api.hardware.nic.NicFreeBsd; - -public interface FreeBsdSystem { - Stream getNicStream(); - - Stream getDiskStream(); - - FirmwareFreeBsd getFirmware(); -} diff --git a/reference/gen/main/java/oshi/api/LinuxSystem.java b/reference/gen/main/java/oshi/api/LinuxSystem.java deleted file mode 100644 index 620a4a4..0000000 --- a/reference/gen/main/java/oshi/api/LinuxSystem.java +++ /dev/null @@ -1,15 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api; - -import java.util.stream.Stream; -import oshi.api.hardware.disk.DiskLinux; -import oshi.api.hardware.firmware.FirmwareLinux; -import oshi.api.hardware.nic.NicLinux; - -public interface LinuxSystem { - Stream getNicStream(); - - Stream getDiskStream(); - - FirmwareLinux getFirmware(); -} diff --git a/reference/gen/main/java/oshi/api/MacSystem.java b/reference/gen/main/java/oshi/api/MacSystem.java deleted file mode 100644 index 57ba458..0000000 --- a/reference/gen/main/java/oshi/api/MacSystem.java +++ /dev/null @@ -1,15 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api; - -import java.util.stream.Stream; -import oshi.api.hardware.disk.DiskMac; -import oshi.api.hardware.firmware.FirmwareMac; -import oshi.api.hardware.nic.NicMac; - -public interface MacSystem { - Stream getNicStream(); - - Stream getDiskStream(); - - FirmwareMac getFirmware(); -} diff --git a/reference/gen/main/java/oshi/api/MultiSystem.java b/reference/gen/main/java/oshi/api/MultiSystem.java deleted file mode 100644 index 858d717..0000000 --- a/reference/gen/main/java/oshi/api/MultiSystem.java +++ /dev/null @@ -1,15 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api; - -import java.util.stream.Stream; -import oshi.api.hardware.disk.Disk; -import oshi.api.hardware.firmware.Firmware; -import oshi.api.hardware.nic.Nic; - -public interface MultiSystem { - Stream getNicStream(); - - Stream getDiskStream(); - - Firmware getFirmware(); -} diff --git a/reference/gen/main/java/oshi/api/SolarisSystem.java b/reference/gen/main/java/oshi/api/SolarisSystem.java deleted file mode 100644 index 5c3e9b7..0000000 --- a/reference/gen/main/java/oshi/api/SolarisSystem.java +++ /dev/null @@ -1,15 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api; - -import java.util.stream.Stream; -import oshi.api.hardware.disk.DiskSolaris; -import oshi.api.hardware.firmware.FirmwareSolaris; -import oshi.api.hardware.nic.NicSolaris; - -public interface SolarisSystem { - Stream getNicStream(); - - Stream getDiskStream(); - - FirmwareSolaris getFirmware(); -} diff --git a/reference/gen/main/java/oshi/api/WindowsSystem.java b/reference/gen/main/java/oshi/api/WindowsSystem.java deleted file mode 100644 index 4a809ab..0000000 --- a/reference/gen/main/java/oshi/api/WindowsSystem.java +++ /dev/null @@ -1,15 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api; - -import java.util.stream.Stream; -import oshi.api.hardware.disk.DiskWindows; -import oshi.api.hardware.firmware.FirmwareWindows; -import oshi.api.hardware.nic.NicWindows; - -public interface WindowsSystem { - Stream getNicStream(); - - Stream getDiskStream(); - - FirmwareWindows getFirmware(); -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java deleted file mode 100644 index b331e05..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerFreeBsd.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -import oshi.driver.ComponentDriver; - -/** - * A storage device - */ -public class DiskContainerFreeBsd extends DiskContainer implements DiskFreeBsd { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java deleted file mode 100644 index 955bf93..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerLinux.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -import oshi.driver.ComponentDriver; - -/** - * A storage device - */ -public class DiskContainerLinux extends DiskContainer implements DiskLinux { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java deleted file mode 100644 index f27d692..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerMac.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -import oshi.driver.ComponentDriver; - -/** - * A storage device - */ -public class DiskContainerMac extends DiskContainer implements DiskMac { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java deleted file mode 100644 index fce8a4d..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerSolaris.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -import oshi.driver.ComponentDriver; - -/** - * A storage device - */ -public class DiskContainerSolaris extends DiskContainer implements DiskSolaris { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java deleted file mode 100644 index 8874f85..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainerWindows.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -import oshi.driver.ComponentDriver; - -/** - * A storage device - */ -public class DiskContainerWindows extends DiskContainer implements DiskWindows { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java deleted file mode 100644 index b3168eb..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskFreeBsd.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -public interface DiskFreeBsd extends Disk { -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java deleted file mode 100644 index 4b8bd34..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskLinux.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -public interface DiskLinux extends Disk { -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java deleted file mode 100644 index 4b1c42b..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskMac.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -public interface DiskMac extends Disk { -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java deleted file mode 100644 index 7ad5bf4..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskSolaris.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -public interface DiskSolaris extends Disk { -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java b/reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java deleted file mode 100644 index 0757b11..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskWindows.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; - -public interface DiskWindows extends Disk { -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java b/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java deleted file mode 100644 index 4384ae2..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskAttribute.java +++ /dev/null @@ -1,64 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk.internal; - -public enum DiskAttribute { - NAME, - - MODEL, - - SERIAL, - - SIZE, - - READS, - - READ_BYTES, - - WRITES, - - WRITE_BYTES, - - QUEUE_LENGTH, - - TRANSFER_TIME, - - MODEL_FAMILY, - - FIRMWARE_VERSION, - - ROTATION_RATE, - - READ_ERROR_RATE, - - SPIN_UP_TIME, - - START_STOP_CYCLES, - - REALLOCATED_SECTORS, - - SEEK_ERROR_RATE, - - POWER_ON_TIME, - - SPIN_RETRIES, - - CALIBRATION_RETRIES, - - POWER_CYCLES, - - POWEROFF_RETRACTS, - - LOAD_CYCLES, - - TEMPERATURE, - - REALLOCATED_EVENTS, - - CURRENT_PENDING_SECTOR, - - OFFLINE_UNCORRECTABLE, - - CRC_ERRORS, - - MULTIZONE_ERROR_RATE -} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java b/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java deleted file mode 100644 index 9f95867..0000000 --- a/reference/gen/main/java/oshi/api/hardware/disk/internal/DiskQuery.java +++ /dev/null @@ -1,13 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk.internal; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface DiskQuery { - DiskAttribute[] value(); -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java b/reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java deleted file mode 100644 index c825053..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/Firmware.java +++ /dev/null @@ -1,16 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -public interface Firmware { - String getName(); - - String getManufacturer(); - - String getDescription(); - - String getVersion(); - - String getRevision(); - - String getReleaseDate(); -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java deleted file mode 100644 index d72564a..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerFreeBsd.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -import oshi.driver.ComponentDriver; - -/** - * The system's firmware - */ -public class FirmwareContainerFreeBsd extends FirmwareContainer implements FirmwareFreeBsd { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java deleted file mode 100644 index c6143db..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerLinux.java +++ /dev/null @@ -1,30 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -import java.lang.Override; -import oshi.api.hardware.firmware.internal.FirmwareAttribute; -import oshi.driver.ComponentDriver; - -/** - * The system's firmware - */ -public class FirmwareContainerLinux extends FirmwareContainer implements FirmwareLinux { - private transient ComponentDriver driver; - - /** - * Whether the BIOS supports UEFI mode - */ - public Boolean uefi; - - @Override - public Boolean getUefi() { - return uefi; - } - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - driver.query(FirmwareAttribute.UEFI); - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java deleted file mode 100644 index 21ebc75..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerMac.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -import oshi.driver.ComponentDriver; - -/** - * The system's firmware - */ -public class FirmwareContainerMac extends FirmwareContainer implements FirmwareMac { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java deleted file mode 100644 index 28efd67..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerSolaris.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -import oshi.driver.ComponentDriver; - -/** - * The system's firmware - */ -public class FirmwareContainerSolaris extends FirmwareContainer implements FirmwareSolaris { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java deleted file mode 100644 index 30ce95b..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainerWindows.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -import oshi.driver.ComponentDriver; - -/** - * The system's firmware - */ -public class FirmwareContainerWindows extends FirmwareContainer implements FirmwareWindows { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java deleted file mode 100644 index 84e1a8f..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -public interface FirmwareFreeBsd extends Firmware { -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java deleted file mode 100644 index 54ca90f..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareLinux.java +++ /dev/null @@ -1,6 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -public interface FirmwareLinux extends Firmware { - Boolean getUefi(); -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java deleted file mode 100644 index 4194db3..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareMac.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -public interface FirmwareMac extends Firmware { -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java deleted file mode 100644 index 547614f..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareSolaris.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -public interface FirmwareSolaris extends Firmware { -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java b/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java deleted file mode 100644 index dae0073..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareWindows.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; - -public interface FirmwareWindows extends Firmware { -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java b/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java deleted file mode 100644 index 444fcce..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java +++ /dev/null @@ -1,18 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware.internal; - -public enum FirmwareAttribute { - NAME, - - MANUFACTURER, - - DESCRIPTION, - - VERSION, - - REVISION, - - RELEASE_DATE, - - UEFI -} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java b/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java deleted file mode 100644 index c09df96..0000000 --- a/reference/gen/main/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java +++ /dev/null @@ -1,13 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware.internal; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface FirmwareQuery { - FirmwareAttribute[] value(); -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java deleted file mode 100644 index 6d13bc1..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerFreeBsd.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -import oshi.driver.ComponentDriver; - -/** - * A network interface - */ -public class NicContainerFreeBsd extends NicContainer implements NicFreeBsd { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java deleted file mode 100644 index 42db77a..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerLinux.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -import oshi.driver.ComponentDriver; - -/** - * A network interface - */ -public class NicContainerLinux extends NicContainer implements NicLinux { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java deleted file mode 100644 index 15e1305..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerMac.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -import oshi.driver.ComponentDriver; - -/** - * A network interface - */ -public class NicContainerMac extends NicContainer implements NicMac { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java b/reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java deleted file mode 100644 index 2bae89b..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerSolaris.java +++ /dev/null @@ -1,17 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -import oshi.driver.ComponentDriver; - -/** - * A network interface - */ -public class NicContainerSolaris extends NicContainer implements NicSolaris { - private transient ComponentDriver driver; - - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java b/reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java deleted file mode 100644 index c994c3b..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicFreeBsd.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -public interface NicFreeBsd extends Nic { -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java b/reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java deleted file mode 100644 index 4d2ccd9..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicLinux.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -public interface NicLinux extends Nic { -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicMac.java b/reference/gen/main/java/oshi/api/hardware/nic/NicMac.java deleted file mode 100644 index e4e7c88..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicMac.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -public interface NicMac extends Nic { -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java b/reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java deleted file mode 100644 index 8bd21f8..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicSolaris.java +++ /dev/null @@ -1,5 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -public interface NicSolaris extends Nic { -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java b/reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java deleted file mode 100644 index 4a39d8f..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicWindows.java +++ /dev/null @@ -1,20 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; - -public interface NicWindows extends Nic { - Long getLuid(); - - Long queryLuid(); - - String getGuid(); - - String queryGuid(); - - Boolean getPaused(); - - Boolean queryPaused(); - - Boolean getLowpower(); - - Boolean queryLowpower(); -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java b/reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java deleted file mode 100644 index 958b187..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/internal/NicAttribute.java +++ /dev/null @@ -1,60 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic.internal; - -public enum NicAttribute { - NAME, - - DESCRIPTION, - - MTU, - - MAC, - - VIRTUAL, - - IPV4, - - IPV6, - - BROADCAST, - - NETMASK, - - READ_BYTES, - - WRITE_BYTES, - - READ_PACKETS, - - WRITE_PACKETS, - - READ_ERRORS, - - WRITE_ERRORS, - - READ_DROPS, - - WRITE_DROPS, - - WRITE_COLLISIONS, - - LINK_SPEED, - - DEFAULT_GATEWAY, - - FLAG_UP, - - FLAG_RUNNING, - - FLAG_LOOPBACK, - - FLAG_MULTICAST, - - LUID, - - GUID, - - PAUSED, - - LOWPOWER -} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java b/reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java deleted file mode 100644 index b298d0c..0000000 --- a/reference/gen/main/java/oshi/api/hardware/nic/internal/NicQuery.java +++ /dev/null @@ -1,13 +0,0 @@ -// This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic.internal; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface NicQuery { - NicAttribute[] value(); -} diff --git a/reference/mvnw b/reference/mvnw new file mode 100755 index 0000000..d2f0ea3 --- /dev/null +++ b/reference/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/reference/mvnw.cmd b/reference/mvnw.cmd new file mode 100644 index 0000000..b26ab24 --- /dev/null +++ b/reference/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/reference/oshi-core-shaded/pom.xml b/reference/oshi-core-shaded/pom.xml new file mode 100644 index 0000000..0636e43 --- /dev/null +++ b/reference/oshi-core-shaded/pom.xml @@ -0,0 +1,127 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-core-shaded + jar + + oshi-core-shaded + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + ${project.parent.basedir} + + + + + org.slf4j + slf4j-jdk14 + ${slf4j.version} + runtime + true + + + ${project.groupId} + oshi-core + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${maven-shade-plugin.version} + + + package + + shade + + + + + org.slf4j:slf4j-api: + org.slf4j:slf4j-jdk14: + + + true + true + + + + + + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + javadoc-jar + package + + jar + + + true + + + com.github.oshi:* + + + + + + + biz.aQute.bnd + bnd-maven-plugin + ${bnd-maven-plugin.version} + + + + + + + diff --git a/reference/oshi-core/pom.xml b/reference/oshi-core/pom.xml new file mode 100644 index 0000000..a299c0b --- /dev/null +++ b/reference/oshi-core/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-core + jar + + oshi-core + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + 5.4.0 + ${project.parent.basedir} + + + + + net.java.dev.jna + jna + ${jna.version} + + + net.java.dev.jna + jna-platform + ${jna.version} + + + + com.squareup + javapoet + 1.11.1 + + + com.fasterxml.jackson.core + jackson-databind + 2.6.3 + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + + diff --git a/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java b/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java new file mode 100644 index 0000000..f93346e --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.api.hardware.nic.NicFreeBsd; + +@Generated("oshi.ApiGenerator") +public interface FreeBsdSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareFreeBsd getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java b/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java new file mode 100644 index 0000000..e761430 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskLinux; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.api.hardware.nic.NicLinux; + +@Generated("oshi.ApiGenerator") +public interface LinuxSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareLinux getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java b/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java new file mode 100644 index 0000000..762d010 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskMac; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.api.hardware.nic.NicMac; + +@Generated("oshi.ApiGenerator") +public interface MacSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareMac getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java b/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java new file mode 100644 index 0000000..0b980db --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.Disk; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.nic.Nic; + +@Generated("oshi.ApiGenerator") +public interface MultiSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + Firmware getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java b/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java new file mode 100644 index 0000000..6eb68ce --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.api.hardware.nic.NicSolaris; + +@Generated("oshi.ApiGenerator") +public interface SolarisSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareSolaris getFirmware(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java b/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java new file mode 100644 index 0000000..5191799 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api; + +import java.util.stream.Stream; +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskWindows; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.api.hardware.nic.NicWindows; + +@Generated("oshi.ApiGenerator") +public interface WindowsSystem { + Stream getNicStream(); + + Stream getDiskStream(); + + FirmwareWindows getFirmware(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/Disk.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java similarity index 57% rename from reference/gen/main/java/oshi/api/hardware/disk/Disk.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java index 464e3b3..50cbb54 100644 --- a/reference/gen/main/java/oshi/api/hardware/disk/Disk.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java @@ -1,6 +1,32 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.disk; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") public interface Disk { String getName(); diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java new file mode 100644 index 0000000..a4a30c7 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskFreeBsd.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskFreeBsd extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java new file mode 100644 index 0000000..143aa31 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskLinux.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskLinux extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java new file mode 100644 index 0000000..a9d2f65 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskMac.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskMac extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java new file mode 100644 index 0000000..727eb5d --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskSolaris.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskSolaris extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java new file mode 100644 index 0000000..dc44c35 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskWindows.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface DiskWindows extends Disk { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java new file mode 100644 index 0000000..f6f2d70 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java @@ -0,0 +1,90 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public enum DiskAttribute { + NAME, + + MODEL, + + SERIAL, + + SIZE, + + READS, + + READ_BYTES, + + WRITES, + + WRITE_BYTES, + + QUEUE_LENGTH, + + TRANSFER_TIME, + + MODEL_FAMILY, + + FIRMWARE_VERSION, + + ROTATION_RATE, + + READ_ERROR_RATE, + + SPIN_UP_TIME, + + START_STOP_CYCLES, + + REALLOCATED_SECTORS, + + SEEK_ERROR_RATE, + + POWER_ON_TIME, + + SPIN_RETRIES, + + CALIBRATION_RETRIES, + + POWER_CYCLES, + + POWEROFF_RETRACTS, + + LOAD_CYCLES, + + TEMPERATURE, + + REALLOCATED_EVENTS, + + CURRENT_PENDING_SECTOR, + + OFFLINE_UNCORRECTABLE, + + CRC_ERRORS, + + MULTIZONE_ERROR_RATE +} diff --git a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java similarity index 87% rename from reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java index 96dbd3d..64fec58 100644 --- a/reference/gen/main/java/oshi/api/hardware/disk/DiskContainer.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java @@ -1,14 +1,39 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.disk; +package oshi.api.hardware.disk.internal; import java.lang.Override; +import javax.annotation.processing.Generated; import oshi.api.DetachedContainerException; -import oshi.api.hardware.disk.internal.DiskAttribute; +import oshi.api.hardware.disk.Disk; import oshi.driver.ComponentDriver; /** * A storage device */ +@Generated("oshi.ApiGenerator") public abstract class DiskContainer implements Disk { private transient ComponentDriver driver; diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java new file mode 100644 index 0000000..dbdf5c3 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerFreeBsd extends DiskContainer implements DiskFreeBsd { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java new file mode 100644 index 0000000..20ff18a --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskLinux; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerLinux extends DiskContainer implements DiskLinux { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java new file mode 100644 index 0000000..4c4ca66 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskMac; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerMac extends DiskContainer implements DiskMac { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java new file mode 100644 index 0000000..2d7d9da --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerSolaris extends DiskContainer implements DiskSolaris { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java new file mode 100644 index 0000000..21ea1e1 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.disk.DiskWindows; +import oshi.driver.ComponentDriver; + +/** + * A storage device + */ +@Generated("oshi.ApiGenerator") +public class DiskContainerWindows extends DiskContainer implements DiskWindows { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java new file mode 100644 index 0000000..b12a316 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java @@ -0,0 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface DiskQuery { + DiskAttribute[] value(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java new file mode 100644 index 0000000..e9f02ac --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java @@ -0,0 +1,42 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface Firmware { + String getName(); + + String getManufacturer(); + + String getDescription(); + + String getVersion(); + + String getRevision(); + + String getReleaseDate(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java new file mode 100644 index 0000000..6a5d2e0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareFreeBsd.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareFreeBsd extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java new file mode 100644 index 0000000..5ff8ede --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java @@ -0,0 +1,32 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareLinux extends Firmware { + Boolean getUefi(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java new file mode 100644 index 0000000..a5570dd --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareMac.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareMac extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java new file mode 100644 index 0000000..ec54fb9 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareSolaris.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareSolaris extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java new file mode 100644 index 0000000..1e87df0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareWindows.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface FirmwareWindows extends Firmware { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java new file mode 100644 index 0000000..23644bd --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java @@ -0,0 +1,44 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public enum FirmwareAttribute { + NAME, + + MANUFACTURER, + + DESCRIPTION, + + VERSION, + + REVISION, + + RELEASE_DATE, + + UEFI +} diff --git a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java similarity index 51% rename from reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java index bd11f04..b377511 100644 --- a/reference/gen/main/java/oshi/api/hardware/firmware/FirmwareContainer.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java @@ -1,13 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.firmware; +package oshi.api.hardware.firmware.internal; import java.lang.Override; -import oshi.api.hardware.firmware.internal.FirmwareAttribute; +import javax.annotation.processing.Generated; +import oshi.api.hardware.firmware.Firmware; import oshi.driver.ComponentDriver; /** * The system's firmware */ +@Generated("oshi.ApiGenerator") public abstract class FirmwareContainer implements Firmware { private transient ComponentDriver driver; diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java new file mode 100644 index 0000000..386602e --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerFreeBsd extends FirmwareContainer implements FirmwareFreeBsd { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java new file mode 100644 index 0000000..8e1a3b5 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java @@ -0,0 +1,55 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.Override; +import javax.annotation.processing.Generated; +import oshi.api.hardware.firmware.FirmwareLinux; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerLinux extends FirmwareContainer implements FirmwareLinux { + private transient ComponentDriver driver; + + /** + * Whether the BIOS supports UEFI mode + */ + public Boolean uefi; + + @Override + public Boolean getUefi() { + return uefi; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + driver.query(FirmwareAttribute.UEFI); + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java new file mode 100644 index 0000000..8fe2144 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerMac extends FirmwareContainer implements FirmwareMac { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java new file mode 100644 index 0000000..721ea7a --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerSolaris extends FirmwareContainer implements FirmwareSolaris { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java new file mode 100644 index 0000000..71b6d5c --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.driver.ComponentDriver; + +/** + * The system's firmware + */ +@Generated("oshi.ApiGenerator") +public class FirmwareContainerWindows extends FirmwareContainer implements FirmwareWindows { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java new file mode 100644 index 0000000..58ac9b2 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java @@ -0,0 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface FirmwareQuery { + FirmwareAttribute[] value(); +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/Nic.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java similarity index 50% rename from reference/gen/main/java/oshi/api/hardware/nic/Nic.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java index 063390b..461c54d 100644 --- a/reference/gen/main/java/oshi/api/hardware/nic/Nic.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java @@ -1,6 +1,32 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.nic; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") public interface Nic { String getName(); diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java new file mode 100644 index 0000000..aacf7c0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicFreeBsd.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicFreeBsd extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java new file mode 100644 index 0000000..b76b590 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicLinux.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicLinux extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java new file mode 100644 index 0000000..b2f178b --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicMac.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicMac extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java new file mode 100644 index 0000000..15f2c3b --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicSolaris.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicSolaris extends Nic { +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java new file mode 100644 index 0000000..728da10 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java @@ -0,0 +1,46 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public interface NicWindows extends Nic { + Long getLuid(); + + Long queryLuid(); + + String getGuid(); + + String queryGuid(); + + Boolean getPaused(); + + Boolean queryPaused(); + + Boolean getLowpower(); + + Boolean queryLowpower(); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java new file mode 100644 index 0000000..17debb3 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java @@ -0,0 +1,86 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +public enum NicAttribute { + NAME, + + DESCRIPTION, + + MTU, + + MAC, + + VIRTUAL, + + IPV4, + + IPV6, + + BROADCAST, + + NETMASK, + + READ_BYTES, + + WRITE_BYTES, + + READ_PACKETS, + + WRITE_PACKETS, + + READ_ERRORS, + + WRITE_ERRORS, + + READ_DROPS, + + WRITE_DROPS, + + WRITE_COLLISIONS, + + LINK_SPEED, + + DEFAULT_GATEWAY, + + FLAG_UP, + + FLAG_RUNNING, + + FLAG_LOOPBACK, + + FLAG_MULTICAST, + + LUID, + + GUID, + + PAUSED, + + LOWPOWER +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java similarity index 85% rename from reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java index 3ed6658..ca641c7 100644 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicContainer.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java @@ -1,14 +1,39 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; +package oshi.api.hardware.nic.internal; import java.lang.Override; +import javax.annotation.processing.Generated; import oshi.api.DetachedContainerException; -import oshi.api.hardware.nic.internal.NicAttribute; +import oshi.api.hardware.nic.Nic; import oshi.driver.ComponentDriver; /** * A network interface */ +@Generated("oshi.ApiGenerator") public abstract class NicContainer implements Nic { private transient ComponentDriver driver; diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java new file mode 100644 index 0000000..1e4d4ce --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.nic.NicFreeBsd; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerFreeBsd extends NicContainer implements NicFreeBsd { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java new file mode 100644 index 0000000..04a36f0 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.nic.NicLinux; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerLinux extends NicContainer implements NicLinux { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java new file mode 100644 index 0000000..a0d27e7 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.nic.NicMac; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerMac extends NicContainer implements NicMac { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java new file mode 100644 index 0000000..4ed1ddd --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java @@ -0,0 +1,43 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import javax.annotation.processing.Generated; +import oshi.api.hardware.nic.NicSolaris; +import oshi.driver.ComponentDriver; + +/** + * A network interface + */ +@Generated("oshi.ApiGenerator") +public class NicContainerSolaris extends NicContainer implements NicSolaris { + private transient ComponentDriver driver; + + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } +} diff --git a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java similarity index 56% rename from reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java index 4184866..dac1d73 100644 --- a/reference/gen/main/java/oshi/api/hardware/nic/NicContainerWindows.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java @@ -1,14 +1,39 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ // This file was automatically generated by the OSHI API generator; do not edit! -package oshi.api.hardware.nic; +package oshi.api.hardware.nic.internal; import java.lang.Override; +import javax.annotation.processing.Generated; import oshi.api.DetachedContainerException; -import oshi.api.hardware.nic.internal.NicAttribute; +import oshi.api.hardware.nic.NicWindows; import oshi.driver.ComponentDriver; /** * A network interface */ +@Generated("oshi.ApiGenerator") public class NicContainerWindows extends NicContainer implements NicWindows { private transient ComponentDriver driver; diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java new file mode 100644 index 0000000..28df010 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java @@ -0,0 +1,38 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.annotation.processing.Generated; + +@Generated("oshi.ApiGenerator") +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface NicQuery { + NicAttribute[] value(); +} diff --git a/reference/src/main/java/oshi/ApiGenerator.java b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java similarity index 75% rename from reference/src/main/java/oshi/ApiGenerator.java rename to reference/oshi-core/src/main/java/oshi/ApiGenerator.java index ac2475f..fc88a31 100644 --- a/reference/src/main/java/oshi/ApiGenerator.java +++ b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi; import static javax.lang.model.element.Modifier.ABSTRACT; @@ -16,6 +39,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.processing.Generated; + import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.squareup.javapoet.AnnotationSpec; @@ -31,94 +56,42 @@ /** * This class generates most of the API layer according to a global - * {@code definitions.json} file in the root project directory. - * - * @author cilki - * @since 5.0.0 + * {@code definitions.json} file in the root project directory. All generated + * sources are output to the src/gen/java directory. */ public final class ApiGenerator { /** - * Represents a system attribute in the definitions file. + * The output source folder. */ - private static class AttributeJson { - /** - * The attribute's name in lowercase underscore format. - */ - public String name; - /** - * The attribute's data type. - */ - public String type; - /** - * The attribute's short description. - */ - public String desc; - /** - * Whether the attribute's value can change over the lifetime of the system. - */ - public boolean constant; - /** - * The attribute's extension type. - */ - public String extension; - /** - * A platform compatibility whitelist. - */ - public List compatible; - } + private static final Path OUTPUT = Paths.get("src/gen/java"); /** - * Represents a system component in the definitions file. + * The API package prefix. */ - private static class ComponentJson { - /** - * The component's name in dot-path notation. - */ - public String name; - /** - * Whether the component is accessible from the root of the API. - */ - public boolean root; - /** - * Whether the system can contain only one or more than one of the component. - */ - public boolean singular; - - /** - * The component's short description. - */ - public String desc; - /** - * The component's attributes. - */ - public List attributes; + private static final String API_PACKAGE = "oshi.api"; - /** - * Parse the last element of the component's dot-path. - * - * @return The component's base name - */ - public String getBaseName() { - return name.substring(name.lastIndexOf('.') + 1); - } + /** + * The driver package prefix. + */ + private static final String DRIVER_PACKAGE = "oshi.driver"; - /** - * Parse the package elements from the component's dot-path. - * - * @return The component's package - */ - public String getPkgName() { - return "oshi.api." + name.substring(0, name.lastIndexOf('.')) + "." + getBaseName().toLowerCase(); - } - } + /** + * A comment to appear below the license header and above the package + * declaration in all generated sources. + */ + private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; /** - * The output source folder. + * An annotation for all generated sources. */ - private static final Path OUTPUT = Paths.get("gen/main/java"); + private static final AnnotationSpec GENERATOR_ANNOTATION = AnnotationSpec.builder(Generated.class) + .addMember("value", String.format("\"%s\"", ApiGenerator.class.getName())).build(); - private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; + /** + * The supported platforms. + */ + private static final String[] PLATFORMS = { "Windows", "Mac", "Linux", "Solaris", "FreeBsd" }; /** * The generator's full output which is collected and written at the end. @@ -133,12 +106,15 @@ public static void main(String[] argv) throws Exception { for (var component : json) { generateAttributeEnums(component); - for (var platform : List.of("", "Windows", "Mac", "Linux", "Solaris", "FreeBsd")) { + + generate(component, ""); + for (var platform : PLATFORMS) { generate(component, platform); } } - for (var platform : List.of("", "Windows", "Mac", "Linux", "Solaris", "FreeBsd")) + generateSystemInterface(json, ""); + for (var platform : PLATFORMS) generateSystemInterface(json, platform); } @@ -147,11 +123,12 @@ public static void main(String[] argv) throws Exception { type.writeTo(OUTPUT); } - private static void generateAttributeEnums(ComponentJson component) throws Exception { + private static void generateAttributeEnums(ComponentJson component) { String baseName = component.getBaseName(); String pkgName = component.getPkgName(); - var attributeEnum = TypeSpec.enumBuilder(baseName + "Attribute").addModifiers(PUBLIC); + var attributeEnum = TypeSpec.enumBuilder(baseName + "Attribute").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); for (var attribute : component.attributes) { // Generate enum constant @@ -162,14 +139,17 @@ private static void generateAttributeEnums(ComponentJson component) throws Excep .build()); } - private static void generate(ComponentJson component, String platform) throws Exception { + private static void generate(ComponentJson component, String platform) { String baseName = component.getBaseName(); String pkgName = component.getPkgName(); // Build classes for component - var container = TypeSpec.classBuilder(baseName + "Container" + platform).addModifiers(PUBLIC); - var containerInterface = TypeSpec.interfaceBuilder(baseName + platform).addModifiers(PUBLIC); + var container = TypeSpec.classBuilder(baseName + "Container" + platform).addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + var containerInterface = TypeSpec.interfaceBuilder(baseName + platform).addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); var queryAnnotation = TypeSpec.annotationBuilder(baseName + "Query").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION) .addAnnotation( AnnotationSpec.builder(Retention.class) .addMember("value", "$T.RUNTIME", @@ -184,7 +164,7 @@ private static void generate(ComponentJson component, String platform) throws Ex // Setup inheritance container.addSuperinterface(ClassName.get(pkgName, baseName + platform)); if (!platform.isEmpty()) { - container.superclass(ClassName.get(pkgName, baseName + "Container")); + container.superclass(ClassName.get(pkgName + ".internal", baseName + "Container")); containerInterface.addSuperinterface(ClassName.get(pkgName, baseName)); } else { container.addModifiers(ABSTRACT); @@ -195,11 +175,11 @@ private static void generate(ComponentJson component, String platform) throws Ex // Add driver field container.addField(FieldSpec - .builder(ClassName.get("oshi.driver", "ComponentDriver"), "driver", PRIVATE, TRANSIENT).build()); + .builder(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver", PRIVATE, TRANSIENT).build()); // Create attach method var attach = MethodSpec.methodBuilder("attach") - .addParameter(ClassName.get("oshi.driver", "ComponentDriver"), "driver") + .addParameter(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver") .addStatement("this.driver = driver").addModifiers(PUBLIC); if (!platform.isEmpty()) attach.addStatement("super.attach(driver)"); @@ -257,7 +237,7 @@ private static void generate(ComponentJson component, String platform) throws Ex container.addMethod(attach.build()); - files.add(JavaFile.builder(pkgName, container.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName + ".internal", container.build()).addFileComment(GENERATOR_COMMENT).build()); files.add(JavaFile.builder(pkgName, containerInterface.build()).addFileComment(GENERATOR_COMMENT).build()); files.add(JavaFile.builder(pkgName + ".internal", queryAnnotation.build()).addFileComment(GENERATOR_COMMENT) .build()); @@ -273,7 +253,7 @@ private static void generate(ComponentJson component, String platform) throws Ex */ private static void generateSystemInterface(List components, String platform) { var system = TypeSpec.interfaceBuilder((platform.isEmpty() ? "Multi" : platform) + "System") - .addModifiers(PUBLIC); + .addModifiers(PUBLIC).addAnnotation(GENERATOR_ANNOTATION); for (var component : components) { if (!component.root) @@ -297,7 +277,7 @@ private static void generateSystemInterface(List components, Stri } } - files.add(JavaFile.builder("oshi.api", system.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(API_PACKAGE, system.build()).addFileComment(GENERATOR_COMMENT).build()); } /** @@ -317,4 +297,81 @@ private static String camel(String... strings) { .flatMap(s -> Arrays.stream(s.split("_"))).map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)) .collect(Collectors.joining()).substring(1); } + + /** + * Represents a system attribute in the definitions file. + */ + private static class AttributeJson { + /** + * The attribute's name in lowercase underscore format. + */ + public String name; + /** + * The attribute's data type. + */ + public String type; + /** + * The attribute's short description. + */ + public String desc; + /** + * Whether the attribute's value can change over the lifetime of the system. + */ + public boolean constant; + /** + * The attribute's extension type. + */ + public String extension; + /** + * A platform compatibility whitelist. + */ + public List compatible; + } + + /** + * Represents a system component in the definitions file. + */ + private static class ComponentJson { + /** + * The component's name in dot-path notation. + */ + public String name; + /** + * Whether the component is accessible from the root of the API. + */ + public boolean root; + /** + * Whether the system can contain only one or more than one of the component. + */ + public boolean singular; + /** + * The component's short description. + */ + public String desc; + /** + * The component's attributes. + */ + public List attributes; + + /** + * Parse the last element of the component's dot-path. + * + * @return The component's base name + */ + public String getBaseName() { + return name.substring(name.lastIndexOf('.') + 1); + } + + /** + * Parse the package elements from the component's dot-path. + * + * @return The component's package + */ + public String getPkgName() { + return API_PACKAGE + "." + name.substring(0, name.lastIndexOf('.')) + "." + getBaseName().toLowerCase(); + } + } + + private ApiGenerator() { + } } \ No newline at end of file diff --git a/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java b/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java new file mode 100644 index 0000000..b1eda0f --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java @@ -0,0 +1,34 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +/** + * Indicates that the attempted operation requires the container to be attached + * to a driver, but no driver instance was found. + */ +public class DetachedContainerException extends IllegalStateException { + + private static final long serialVersionUID = 979546852734821377L; + +} diff --git a/reference/oshi-core/src/main/java/oshi/api/OSHI.java b/reference/oshi-core/src/main/java/oshi/api/OSHI.java new file mode 100644 index 0000000..549b78f --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/OSHI.java @@ -0,0 +1,156 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +import com.sun.jna.Platform; + +import oshi.driver.SystemDriver; +import oshi.driver.SystemDriverFreeBsd; +import oshi.driver.SystemDriverLinux; +import oshi.driver.SystemDriverMac; +import oshi.driver.SystemDriverSolaris; +import oshi.driver.SystemDriverWindows; + +/** + * + */ +public final class OSHI { + + private static final PlatformEnum PLATFORM; + + static { + if (Platform.isWindows()) { + PLATFORM = PlatformEnum.WINDOWS; + } else if (Platform.isLinux()) { + PLATFORM = PlatformEnum.LINUX; + } else if (Platform.isMac()) { + PLATFORM = PlatformEnum.MACOSX; + } else if (Platform.isSolaris()) { + PLATFORM = PlatformEnum.SOLARIS; + } else if (Platform.isFreeBSD()) { + PLATFORM = PlatformEnum.FREEBSD; + } else { + PLATFORM = PlatformEnum.UNSUPPORTED; + } + } + + /** + * Get the system's platform type. + * + * @return The platform type + */ + public static PlatformEnum getPlatform() { + return PLATFORM; + } + + /** + * Build a disposable handle that provides cross-platform system information. + * + * @return A new {@link MultiSystem} handle + */ + public static MultiSystem getSystem() { + switch (PLATFORM) { + case FREEBSD: + return new SystemDriver(new SystemDriverFreeBsd()); + case LINUX: + return new SystemDriver(new SystemDriverLinux()); + case MACOSX: + return new SystemDriver(new SystemDriverMac()); + case SOLARIS: + return new SystemDriver(new SystemDriverSolaris()); + case WINDOWS: + return new SystemDriver(new SystemDriverWindows()); + default: + throw new UnsupportedOperationException("OSHI is not supported on this platform"); + } + } + + /** + * Build a disposable handle that provides Windows system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link WindowsSystem} handle + */ + public static WindowsSystem getWindowsSystem() { + if (PLATFORM != PlatformEnum.WINDOWS) + throw new UnsupportedOperationException("Cannot obtain Windows handle on this platform"); + return new SystemDriverWindows(); + } + + /** + * Build a disposable handle that provides Linux system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link LinuxSystem} handle + */ + public static LinuxSystem getLinuxSystem() { + if (PLATFORM != PlatformEnum.LINUX) + throw new UnsupportedOperationException("Cannot obtain Linux handle on this platform"); + return new SystemDriverLinux(); + } + + /** + * Build a disposable handle that provides macOS system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link MacSystem} handle + */ + public static MacSystem getMacSystem() { + if (PLATFORM != PlatformEnum.MACOSX) + throw new UnsupportedOperationException("Cannot obtain MacOS handle on this platform"); + return new SystemDriverMac(); + } + + /** + * Build a disposable handle that provides Solaris system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link SolarisSystem} handle + */ + public static SolarisSystem getSolarisSystem() { + if (PLATFORM != PlatformEnum.SOLARIS) + throw new UnsupportedOperationException("Cannot obtain Solaris handle on this platform"); + return new SystemDriverSolaris(); + } + + /** + * Build a disposable handle that provides FreeBSD system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link FreeBsdSystem} handle + */ + public static FreeBsdSystem getFreebsdSystem() { + if (PLATFORM != PlatformEnum.FREEBSD) + throw new UnsupportedOperationException("Cannot obtain FreeBSD handle on this platform"); + return new SystemDriverFreeBsd(); + } + + private OSHI() { + } +} diff --git a/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java b/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java new file mode 100644 index 0000000..7e7be87 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java @@ -0,0 +1,61 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +/** + * An enumeration of supported operating systems. + */ +public enum PlatformEnum { + + /** + * Microsoft's Windows operating system. + */ + WINDOWS, + + /** + * An operating system built on the Linux kernel. + */ + LINUX, + + /** + * Apple's macOS (OS X) operating system. + */ + MACOSX, + + /** + * The Solaris (SunOS) operating system. + */ + SOLARIS, + + /** + * The FreeBSD operating system. + */ + FREEBSD, + + /** + * Any unsupported operating system such as OpenBSD, AIX, WindowsCE, Android, + * etc. + */ + UNSUPPORTED; +} diff --git a/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java b/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java new file mode 100644 index 0000000..9432408 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java @@ -0,0 +1,30 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +public class UnsupportedPlatformException extends RuntimeException { + + private static final long serialVersionUID = -5396626644287029649L; + +} diff --git a/reference/src/main/java/oshi/driver/ComponentDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java similarity index 78% rename from reference/src/main/java/oshi/driver/ComponentDriver.java rename to reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java index 25c5069..f22916c 100644 --- a/reference/src/main/java/oshi/driver/ComponentDriver.java +++ b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver; import java.lang.invoke.MethodHandle; @@ -12,8 +35,6 @@ import java.util.Map; import java.util.stream.Collectors; -import oshi.api.NoSuchQueryMethodException; - /** * A {@link ComponentDriver} is the root of the driver hierarchy. Containers can * call {@link #query(Enum)} or {@link #queryAll()} to have this class update @@ -23,9 +44,6 @@ * This class automatically registers all query methods in its subclasses. Query * methods in {@link ExtensionDriver}s can also be registered with * {@link #register(ExtensionDriver)}. - * - * @author cilki - * @since 5.0.0 */ public class ComponentDriver { @@ -76,7 +94,7 @@ public void query(Enum attribute) { var h = handles.get(attribute); if (h == null) { - throw new NoSuchQueryMethodException(); + // TODO } for (var t : h) { diff --git a/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java new file mode 100644 index 0000000..d7e25f7 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java @@ -0,0 +1,31 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +/** + * A marker class for a driver that provides additional query methods to a + * {@link ComponentDriver}. + */ +public class ExtensionDriver { +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/Fallback.java b/reference/oshi-core/src/main/java/oshi/driver/Fallback.java new file mode 100644 index 0000000..7198dc2 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/Fallback.java @@ -0,0 +1,36 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface Fallback { + public Class value(); +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java b/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java new file mode 100644 index 0000000..72245d1 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java @@ -0,0 +1,46 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +/** + * An indicator optionally returned by a query that describes the outcome of the + * query. If a query's return type is {@code void}, then {@link #OK} is implied. + */ +public enum QueryStatus { + + /** + * Indicates the query completed successfully and the corresponding container + * object has been updated. + */ + OK, + + /** + * Indicates the query timed-out and the corresponding container object has not + * been updated. + */ + TIMEOUT, + + // TODO + MISSED_READING, PROCESS_TERMINATED; +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java b/reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java new file mode 100644 index 0000000..6b56417 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java @@ -0,0 +1,35 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface RequiresRoot { +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java new file mode 100644 index 0000000..ef5015c --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java @@ -0,0 +1,70 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.Objects; +import java.util.stream.Stream; + +import oshi.api.MultiSystem; +import oshi.api.hardware.disk.Disk; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.nic.Nic; + +@SuppressWarnings("unchecked") +public class SystemDriver implements MultiSystem { + + private Object driver; + + public SystemDriver(Object driver) { + this.driver = Objects.requireNonNull(driver); + } + + @Override + public Stream getNicStream() { + try { + return (Stream) driver.getClass().getMethod("getNicStream").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Stream getDiskStream() { + try { + return (Stream) driver.getClass().getMethod("getDiskStream").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Firmware getFirmware() { + try { + return (Firmware) driver.getClass().getMethod("getFirmware").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java new file mode 100644 index 0000000..68ec238 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.FreeBsdSystem; +import oshi.api.hardware.disk.DiskFreeBsd; +import oshi.api.hardware.firmware.FirmwareFreeBsd; +import oshi.api.hardware.nic.NicFreeBsd; + +public class SystemDriverFreeBsd implements FreeBsdSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareFreeBsd getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/src/main/java/oshi/driver/SystemDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java similarity index 65% rename from reference/src/main/java/oshi/driver/SystemDriverLinux.java rename to reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java index 82c86b1..a880969 100644 --- a/reference/src/main/java/oshi/driver/SystemDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver; import java.net.NetworkInterface; @@ -7,12 +30,12 @@ import java.util.stream.Stream; import oshi.api.LinuxSystem; -import oshi.api.hardware.disk.DiskContainerLinux; import oshi.api.hardware.disk.DiskLinux; -import oshi.api.hardware.firmware.FirmwareContainerLinux; +import oshi.api.hardware.disk.internal.DiskContainerLinux; import oshi.api.hardware.firmware.FirmwareLinux; -import oshi.api.hardware.nic.NicContainerLinux; +import oshi.api.hardware.firmware.internal.FirmwareContainerLinux; import oshi.api.hardware.nic.NicLinux; +import oshi.api.hardware.nic.internal.NicContainerLinux; import oshi.driver.hardware.disk.DiskDriverLinux; import oshi.driver.hardware.firmware.FirmwareDriverLinux; import oshi.driver.hardware.nic.NicDriverJava; diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java new file mode 100644 index 0000000..c3e54a3 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.MacSystem; +import oshi.api.hardware.disk.DiskMac; +import oshi.api.hardware.firmware.FirmwareMac; +import oshi.api.hardware.nic.NicMac; + +public class SystemDriverMac implements MacSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareMac getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java new file mode 100644 index 0000000..74f7acd --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.SolarisSystem; +import oshi.api.hardware.disk.DiskSolaris; +import oshi.api.hardware.firmware.FirmwareSolaris; +import oshi.api.hardware.nic.NicSolaris; + +public class SystemDriverSolaris implements SolarisSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareSolaris getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java new file mode 100644 index 0000000..78c16c4 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java @@ -0,0 +1,53 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.stream.Stream; + +import oshi.api.WindowsSystem; +import oshi.api.hardware.disk.DiskWindows; +import oshi.api.hardware.firmware.FirmwareWindows; +import oshi.api.hardware.nic.NicWindows; + +public class SystemDriverWindows implements WindowsSystem { + + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } + + @Override + public FirmwareWindows getFirmware() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/Timeout.java b/reference/oshi-core/src/main/java/oshi/driver/Timeout.java new file mode 100644 index 0000000..6f6d3ab --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/Timeout.java @@ -0,0 +1,36 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(RUNTIME) +@Target(METHOD) +public @interface Timeout { + +} diff --git a/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java similarity index 69% rename from reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java rename to reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java index 9db2bd5..822df4d 100644 --- a/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver.hardware.disk; import static oshi.api.hardware.disk.internal.DiskAttribute.MODEL; @@ -11,7 +34,7 @@ import static oshi.api.hardware.disk.internal.DiskAttribute.WRITES; import static oshi.api.hardware.disk.internal.DiskAttribute.WRITE_BYTES; -import oshi.api.hardware.disk.DiskContainerLinux; +import oshi.api.hardware.disk.internal.DiskContainerLinux; import oshi.api.hardware.disk.internal.DiskQuery; import oshi.driver.ComponentDriver; import oshi.old.ParseUtil; diff --git a/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java similarity index 65% rename from reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java rename to reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java index 680d4a3..fa413ca 100644 --- a/reference/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver.hardware.disk; import static oshi.api.hardware.disk.internal.DiskAttribute.CALIBRATION_RETRIES; @@ -21,7 +44,7 @@ import static oshi.api.hardware.disk.internal.DiskAttribute.START_STOP_CYCLES; import static oshi.api.hardware.disk.internal.DiskAttribute.TEMPERATURE; -import oshi.api.hardware.disk.DiskContainerLinux; +import oshi.api.hardware.disk.internal.DiskContainerLinux; import oshi.api.hardware.disk.internal.DiskQuery; import oshi.driver.ExtensionDriver; import oshi.old.ExecutingCommand; diff --git a/reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java similarity index 64% rename from reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java rename to reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java index 95a1919..b72cde8 100644 --- a/reference/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver.hardware.firmware; import static oshi.api.hardware.firmware.internal.FirmwareAttribute.DESCRIPTION; @@ -8,7 +31,7 @@ import static oshi.api.hardware.firmware.internal.FirmwareAttribute.UEFI; import static oshi.api.hardware.firmware.internal.FirmwareAttribute.VERSION; -import oshi.api.hardware.firmware.FirmwareContainerLinux; +import oshi.api.hardware.firmware.internal.FirmwareContainerLinux; import oshi.api.hardware.firmware.internal.FirmwareQuery; import oshi.driver.ComponentDriver; import oshi.driver.RequiresRoot; diff --git a/reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java similarity index 57% rename from reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java rename to reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java index a60adf3..4aafc83 100644 --- a/reference/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver.hardware.nic; import static oshi.api.hardware.nic.internal.NicAttribute.IPV4; @@ -10,7 +33,7 @@ import java.net.NetworkInterface; import java.net.SocketException; -import oshi.api.hardware.nic.NicContainer; +import oshi.api.hardware.nic.internal.NicContainer; import oshi.api.hardware.nic.internal.NicQuery; import oshi.driver.ExtensionDriver; diff --git a/reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java similarity index 77% rename from reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java rename to reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java index 1a575e2..477ce90 100644 --- a/reference/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java @@ -1,3 +1,26 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ package oshi.driver.hardware.nic; import static oshi.api.hardware.nic.internal.NicAttribute.BROADCAST; @@ -20,7 +43,7 @@ import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_ERRORS; import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_PACKETS; -import oshi.api.hardware.nic.NicContainerLinux; +import oshi.api.hardware.nic.internal.NicContainerLinux; import oshi.api.hardware.nic.internal.NicQuery; import oshi.driver.ComponentDriver; import oshi.old.FileUtil; diff --git a/reference/oshi-core/src/main/java/oshi/example/DiskExample.java b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java new file mode 100644 index 0000000..bea1ae4 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java @@ -0,0 +1,40 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.example; + +import oshi.api.OSHI; + +public class DiskExample { + public static void main(String[] args) { + + OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.querySize()); + System.out.println("\tRead bytes: " + disk.queryReadBytes()); + System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); + System.out.println("\tQueue length: " + disk.queryQueueLength()); + System.out.println("\tTransfer time: " + disk.queryTransferTime()); + }); + } +} diff --git a/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java new file mode 100644 index 0000000..d17f976 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java @@ -0,0 +1,44 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.example; + +import oshi.api.OSHI; + +public class FirmwareExample { + + public static void main(String[] args) { + + var firmware = OSHI.getSystem().getFirmware(); + System.out.println("=== CrossPlatform Firmware ==="); + System.out.println("Name: " + firmware.getName()); + System.out.println("Description: " + firmware.getDescription()); + System.out.println("Version: " + firmware.getVersion()); + System.out.println("Revision: " + firmware.getRevision()); + System.out.println("Release: " + firmware.getReleaseDate()); + + var linuxFirmware = OSHI.getLinuxSystem().getFirmware(); + System.out.println("=== Linux Firmware ==="); + System.out.println("UEFI support: " + linuxFirmware.getUefi()); + } +} diff --git a/reference/oshi-core/src/main/java/oshi/example/NicExample.java b/reference/oshi-core/src/main/java/oshi/example/NicExample.java new file mode 100644 index 0000000..16feafa --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/example/NicExample.java @@ -0,0 +1,45 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.example; + +import java.util.Arrays; + +import oshi.api.OSHI; + +public class NicExample { + + public static void main(String[] args) throws Exception { + + OSHI.getLinuxSystem().getNicStream().forEach(nic -> { + System.out.println("NIC: " + nic.getName()); + System.out.println("\tReadBytes: " + nic.queryReadBytes()); + System.out.println("\tWriteBytes: " + nic.queryWriteBytes()); + System.out.println("\tMTU: " + nic.queryMtu()); + System.out.println("\tIPv4: " + Arrays.toString(nic.queryIpv4())); + System.out.println("\tLink Speed: " + nic.queryLinkSpeed()); + }); + + } + +} diff --git a/reference/src/main/java/oshi/old/ExecutingCommand.java b/reference/oshi-core/src/main/java/oshi/old/ExecutingCommand.java similarity index 100% rename from reference/src/main/java/oshi/old/ExecutingCommand.java rename to reference/oshi-core/src/main/java/oshi/old/ExecutingCommand.java diff --git a/reference/src/main/java/oshi/old/FileUtil.java b/reference/oshi-core/src/main/java/oshi/old/FileUtil.java similarity index 100% rename from reference/src/main/java/oshi/old/FileUtil.java rename to reference/oshi-core/src/main/java/oshi/old/FileUtil.java diff --git a/reference/src/main/java/oshi/old/ParseUtil.java b/reference/oshi-core/src/main/java/oshi/old/ParseUtil.java similarity index 100% rename from reference/src/main/java/oshi/old/ParseUtil.java rename to reference/oshi-core/src/main/java/oshi/old/ParseUtil.java diff --git a/reference/src/main/java/oshi/old/Udev.java b/reference/oshi-core/src/main/java/oshi/old/Udev.java similarity index 100% rename from reference/src/main/java/oshi/old/Udev.java rename to reference/oshi-core/src/main/java/oshi/old/Udev.java diff --git a/reference/src/main/java/oshi/old/WmiUtil.java b/reference/oshi-core/src/main/java/oshi/old/WmiUtil.java similarity index 100% rename from reference/src/main/java/oshi/old/WmiUtil.java rename to reference/oshi-core/src/main/java/oshi/old/WmiUtil.java diff --git a/reference/oshi-core/src/site/site.xml b/reference/oshi-core/src/site/site.xml new file mode 100644 index 0000000..16a056a --- /dev/null +++ b/reference/oshi-core/src/site/site.xml @@ -0,0 +1,52 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reference/oshi-demo/pom.xml b/reference/oshi-demo/pom.xml new file mode 100644 index 0000000..4b0e91f --- /dev/null +++ b/reference/oshi-demo/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-demo + jar + + oshi-demo + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + ${project.parent.basedir} + 2.9.9.2 + + + + + ${project.groupId} + oshi-core + ${project.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + diff --git a/reference/oshi-dist/LICENSE_MIT b/reference/oshi-dist/LICENSE_MIT new file mode 100644 index 0000000..7500276 --- /dev/null +++ b/reference/oshi-dist/LICENSE_MIT @@ -0,0 +1,21 @@ +OSHI (https://github.com/oshi/oshi) + +Copyright (c) 2010 - 2019 The OSHI Project Team: +https://github.com/oshi/oshi/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/reference/oshi-dist/pom.xml b/reference/oshi-dist/pom.xml new file mode 100644 index 0000000..215b4d5 --- /dev/null +++ b/reference/oshi-dist/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + + + oshi-dist + pom + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + + ${project.parent.basedir} + + + + + + ${project.groupId} + oshi-core + ${project.version} + + + ${project.groupId} + oshi-demo + ${project.version} + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + false + posix + + ${project.basedir}/src/assembly/assembly.xml + + + + + dist-assembly + package + + single + + + + + + + diff --git a/reference/oshi-dist/src/assembly/assembly.xml b/reference/oshi-dist/src/assembly/assembly.xml new file mode 100644 index 0000000..8b9e188 --- /dev/null +++ b/reference/oshi-dist/src/assembly/assembly.xml @@ -0,0 +1,76 @@ + + + + distribution + + tar.gz + tar.bz2 + zip + + + false + + + + false + true + lib + false + + ${project.groupId}:*:* + + + + + + + ${project.basedir}/LICENSE_MIT + + license.txt + + + + + + + true + + + com.github.oshi:oshi-core + com.github.oshi:oshi-demo + + + false + / + false + + + + diff --git a/reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml b/reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml new file mode 100644 index 0000000..9ca20b1 --- /dev/null +++ b/reference/oshi-dist/src/main/resources/eclipse/OSHIJavaFormatConventions.xml @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/reference/oshi-dist/src/site/site.xml b/reference/oshi-dist/src/site/site.xml new file mode 100644 index 0000000..16a056a --- /dev/null +++ b/reference/oshi-dist/src/site/site.xml @@ -0,0 +1,52 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + true + true + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reference/pom.xml b/reference/pom.xml new file mode 100644 index 0000000..6a259f6 --- /dev/null +++ b/reference/pom.xml @@ -0,0 +1,1085 @@ + + + + 4.0.0 + + com.github.oshi + oshi-parent + 5.0.0-SNAPSHOT + pom + + Operating System and Hardware Information + A JNA-based (native) operating system information library for Java that aims to provide a cross-platform implementation to retrieve system information, such as version, memory, CPU, disk, battery, etc. + https://github.com/oshi/oshi + 2010 + + oshi + https://github.com/oshi/ + + + + MIT License + https://opensource.org/licenses/MIT + repo + + + + + + dblock + Daniel Doubrovkine + dblock@dblock.org + dblock.org + http://code.dblock.org/ + + + dbwiddis + Daniel Widdis + widdis@gmail.com + sometegroup.com + https://github.com/dbwiddis/ + + + + + oshi-core + oshi-core-shaded + oshi-demo + oshi-dist + + + + scm:git:git@github.com:oshi/oshi.git + scm:git:git@github.com:oshi/oshi.git + https://github.com/oshi/oshi.git + HEAD + + + Github + https://github.com/oshi/oshi/issues + + + travis + https://travis-ci.org/oshi/oshi/ + + + + gh-pages + OSHI GitHub Pages + github:ssh://oshi.github.io/oshi/ + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + 2010 - 2019 + yyyy-MM-dd HH:mm:ss + 11 + 11 + 11 + 11 + 3.3.9 + UTF-8 + UTF-8 + UTF-8 + java18 + 1.0 + + ${project.basedir} + + 1.7.26 + 5.5.1 + + 3.1.0 + 3.8.1 + 3.0.0-M1 + 3.0.0-M2 + 1.6 + 3.0.0-M1 + 3.1.0 + 3.8.2 + 3.0.0-M3 + + 1.9 + 2.0.3 + 3.3.3 + 1.8 + + 3.0.0 + 3.0.0 + 3.1.2 + 3.2.3 + 4.2.0 + 3.2.1 + + 3.1.0 + 3.1.1 + 3.12.0 + + 1.8 + 3.1.1 + 3.1.1 + 2.5.3 + 3.1.0 + 3.1.12 + 0.8.4 + 4.3.0 + 2.3.1 + 1.1.0 + 3.0 + + 2.0 + 2.3 + 3.0.0 + 3.0.0 + 2.22.2 + 2.4 + 2.7 + + 1.11.2 + 1.11.2 + 1.1.6 + 0.1.55 + 5.4.0.201906121030-r + 3.2.1 + + 3.6.0.1398 + 2.0.0 + 1.18 + 5.2.1 + 8.23 + 1.0.0 + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-vintage-engine.version} + test + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + ${maven-clean-plugin.version} + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + + false + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + org.apache.maven.plugins + maven-install-plugin + ${maven-install-plugin.version} + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin.version} + + + org.apache.maven.doxia + doxia-module-markdown + ${doxia-module-markdown.version} + + + net.trajano.wagon + wagon-git + ${wagon-git.version} + + + org.apache.maven.wagon + wagon-ssh + ${wagon-ssh.version} + + + org.apache.maven.skins + maven-fluido-skin + ${maven-fluido-skin.version} + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + 3 + true + -Xmx1024m -XX:MaxPermSize=256m + + + + + pl.project13.maven + git-commit-id-plugin + ${git-commit-id-plugin.version} + + + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper-maven-plugin.version} + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven-jar-plugin.version} + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + true + true + + + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + true + true + + + ${buildNumber} + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + biz.aQute.bnd + bnd-maven-plugin + ${bnd-maven-plugin.version} + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + + true + true + + + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + org.apache.maven.plugins + maven-pmd-plugin + ${maven-pmd-plugin.version} + + + + org.apache.maven.plugins + maven-antrun-plugin + ${maven-antrun-plugin.version} + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + org.apache.maven.plugins + maven-dependency-plugin + ${maven-dependency-plugin.version} + + + org.apache.maven.plugins + maven-release-plugin + ${maven-release-plugin.version} + + forked-path + false + -Prelease + true + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + + true + true + + + ${maven.build.timestamp} + ${copyright} + ${git.commit.id} + ${os.name} + ${os.arch} + ${os.version} + ${maven.compiler.source} + ${maven.compiler.target} + + + 2 + ${project.name} + ${project.groupId}.${project.artifactId}.source + ${project.organization.name} + ${parsedVersion.osgiVersion} + ${project.groupId}.${project.artifactId};version="${parsedVersion.osgiVersion}";roots:="." + + + + + + + + + + + com.github.spotbugs + spotbugs-maven-plugin + ${spotbugs-maven-plugin.version} + + + + com.github.spotbugs + spotbugs + ${spotbugs-maven-plugin.version} + + + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + org.eluder.coveralls + coveralls-maven-plugin + ${coveralls-maven-plugin.version} + + + org.codehaus.mojo + tidy-maven-plugin + ${tidy-maven-plugin.version} + + + com.mycila + license-maven-plugin + ${license-maven-plugin.version} + +
${main.basedir}/LICENSE_HEADER
+ + **/*test.*.txt + **/maven-wrapper.properties + **/MavenWrapperDownloader.java + mvnw + mvnw.cmd + LICENSE_* + **/OSHIJavaFormatConventions.xml + +
+
+ + + org.codehaus.mojo + jdepend-maven-plugin + ${jdepend-maven-plugin.version} + + + org.apache.maven.plugins + maven-changelog-plugin + ${maven-changelog-plugin.version} + + + org.apache.maven.plugins + maven-jxr-plugin + ${maven-jxr-plugin.version} + + + org.apache.maven.plugins + maven-project-info-reports-plugin + ${maven-project-info-reports-plugin.version} + + + org.apache.maven.plugins + maven-surefire-report-plugin + ${maven-surefire-report-plugin.version} + + + org.codehaus.mojo + taglist-maven-plugin + ${taglist-maven-plugin.version} + + + org.codehaus.mojo + versions-maven-plugin + ${versions-maven-plugin.version} + + + + org.apache.maven.plugins + maven-scm-plugin + ${maven-scm-plugin.version} + + + org.apache.maven.scm + maven-scm-provider-jgit + ${maven-scm-provider-jgit.version} + + + com.googlecode.javaewah + JavaEWAH + ${JavaEWAH.version} + + + com.jcraft + jsch + ${jsch.version} + + + org.eclipse.jgit + org.eclipse.jgit + ${jgit.version} + + + org.codehaus.plexus + plexus-utils + ${plexus-utils.version} + + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar-maven-plugin.version} + + + + org.codehaus.mojo + wagon-maven-plugin + ${wagon-maven-plugin.version} + + + org.codehaus.mojo + animal-sniffer-maven-plugin + ${animal-sniffer-maven-plugin.version} + + + org.codehaus.mojo.signature + ${signature.artifact} + ${signature.version} + + + + + org.owasp + dependency-check-maven + ${dependency-check-maven.version} + +
+
+ + + + pl.project13.maven + git-commit-id-plugin + + .git + + + true + + true + + + + git-commit-id + + revision + + validate + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + parse-version + + + + + + biz.aQute.bnd + bnd-maven-plugin + + + + bnd-process + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + + ${maven.min-version} + + + + + + enforce-maven + + enforce + + + + enforce-clean + pre-clean + + enforce + + + + enforce-site + pre-site + + enforce + + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + + + test-sniffer + test + + check + + + + + + com.sun.management.OperatingSystemMXBean + + + + + com.mycila + license-maven-plugin + + + compile + + format + + + + + + org.jacoco + jacoco-maven-plugin + + + + pre-unit-test + + prepare-agent + + + surefireArgLine + + + + + post-unit-test + test + + report + + + + + + **/impl/** + **/common/** + **/Abstract*/** + **/platform/** + **/linux/** + **/mac/** + **/windows/** + **/unix/** + + + + + org.apache.maven.plugins + maven-surefire-plugin + + ${surefireArgLine} + + **/*Test.java + **/*Tests.java + + + + + run-unit-tests + + test + + + + + + org.eluder.coveralls + coveralls-maven-plugin + + + javax.xml.bind + jaxb-api + ${jaxb-api.version} + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.puppycrawl.tools + checkstyle + ${puppycrawl.checkstyle.version} + + + + + + + org.apache.maven.wagon + wagon-ssh + ${wagon-ssh.version} + + +
+ + + + + org.apache.maven.plugins + maven-changelog-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.github.spotbugs + spotbugs-maven-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + org.apache.maven.plugins + maven-jxr-plugin + + + org.apache.maven.plugins + maven-pmd-plugin + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + org.jacoco + jacoco-maven-plugin + + + org.codehaus.mojo + versions-maven-plugin + + + org.codehaus.mojo + taglist-maven-plugin + + + org.codehaus.mojo + jdepend-maven-plugin + + + org.owasp + dependency-check-maven + + + + aggregate + + + + + + + + + + checks + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + check + + + + + false + + + + org.apache.maven.plugins + maven-pmd-plugin + + + + check + cpd-check + + + + + false + true + + + + + org.jacoco + jacoco-maven-plugin + + + check + + check + + + + + BUNDLE + + + COMPLEXITY + COVEREDRATIO + ${jacoco.minimum.coverage} + + + + + + + + + + org.owasp + dependency-check-maven + + + + check + + + + + + + + + eclipse + + + m2e.version + + + + + + + + org.eclipse.m2e + lifecycle-mapping + ${m2e.lifecycle-mapping.version} + + + + + + com.mycila + license-maven-plugin + [3.0,) + + format + + + + + + + + + org.jacoco + jacoco-maven-plugin + [0.8.1,) + + prepare-agent + + + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + [3.0.0-M2,) + + enforce + + + + + + + + + + + + + + + + sort + + + + org.codehaus.mojo + tidy-maven-plugin + + + verify + + pom + + + + + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + attach-test-javadocs + + test-jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + +
\ No newline at end of file diff --git a/reference/src/main/java/oshi/api/DetachedContainerException.java b/reference/src/main/java/oshi/api/DetachedContainerException.java deleted file mode 100644 index 5e8983f..0000000 --- a/reference/src/main/java/oshi/api/DetachedContainerException.java +++ /dev/null @@ -1,14 +0,0 @@ -package oshi.api; - -/** - * Indicates that the attempted operation requires the container to be attached, - * but the container was detached. - * - * @author cilki - * @since 5.0.0 - */ -public class DetachedContainerException extends RuntimeException { - - private static final long serialVersionUID = 979546852734821377L; - -} diff --git a/reference/src/main/java/oshi/api/NoSuchQueryMethodException.java b/reference/src/main/java/oshi/api/NoSuchQueryMethodException.java deleted file mode 100644 index da231fc..0000000 --- a/reference/src/main/java/oshi/api/NoSuchQueryMethodException.java +++ /dev/null @@ -1,5 +0,0 @@ -package oshi.api; - -public class NoSuchQueryMethodException extends RuntimeException { - -} diff --git a/reference/src/main/java/oshi/api/OSHI.java b/reference/src/main/java/oshi/api/OSHI.java deleted file mode 100644 index 6729f96..0000000 --- a/reference/src/main/java/oshi/api/OSHI.java +++ /dev/null @@ -1,78 +0,0 @@ -package oshi.api; - -import com.sun.jna.Platform; - -import oshi.driver.SystemDriver; -import oshi.driver.SystemDriverFreeBsd; -import oshi.driver.SystemDriverLinux; -import oshi.driver.SystemDriverMac; -import oshi.driver.SystemDriverSolaris; -import oshi.driver.SystemDriverWindows; - -public final class OSHI { - - private static final PlatformEnum platform; - - static { - if (Platform.isWindows()) { - platform = PlatformEnum.WINDOWS; - } else if (Platform.isLinux()) { - platform = PlatformEnum.LINUX; - } else if (Platform.isMac()) { - platform = PlatformEnum.MACOSX; - } else if (Platform.isSolaris()) { - platform = PlatformEnum.SOLARIS; - } else if (Platform.isFreeBSD()) { - platform = PlatformEnum.FREEBSD; - } else { - platform = PlatformEnum.UNKNOWN; - throw new RuntimeException("Unsupported platform"); - } - } - - /** - * Get the system's platform type. - * - * @return The platform type - */ - public static PlatformEnum getPlatform() { - return platform; - } - - public static MultiSystem getSystem() { - if (platform == PlatformEnum.UNKNOWN) - throw new UnsupportedOperationException(); - return new SystemDriver(platform); - } - - public static WindowsSystem getWindowsSystem() { - if (platform != PlatformEnum.WINDOWS) - throw new UnsupportedOperationException(); - return new SystemDriverWindows(); - } - - public static LinuxSystem getLinuxSystem() { - if (platform != PlatformEnum.LINUX) - throw new UnsupportedOperationException(); - return new SystemDriverLinux(); - } - - public static MacSystem getMacSystem() { - if (platform != PlatformEnum.MACOSX) - throw new UnsupportedOperationException(); - return new SystemDriverMac(); - } - - public static SolarisSystem getSolarisSystem() { - if (platform != PlatformEnum.SOLARIS) - throw new UnsupportedOperationException(); - return new SystemDriverSolaris(); - } - - public static FreeBsdSystem getFreebsdSystem() { - if (platform != PlatformEnum.FREEBSD) - throw new UnsupportedOperationException(); - return new SystemDriverFreeBsd(); - } - -} diff --git a/reference/src/main/java/oshi/api/PlatformEnum.java b/reference/src/main/java/oshi/api/PlatformEnum.java deleted file mode 100644 index c54b6a1..0000000 --- a/reference/src/main/java/oshi/api/PlatformEnum.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Oshi (https://github.com/oshi/oshi) - * - * Copyright (c) 2010 - 2018 The Oshi Project Team - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Maintainers: - * dblock[at]dblock[dot]org - * widdis[at]gmail[dot]com - * enrico.bianchi[at]gmail[dot]com - * - * Contributors: - * https://github.com/oshi/oshi/graphs/contributors - */ -package oshi.api; - -/** - * Enum of supported operating systems. - * - * @author alessandro[at]perucchi[dot]org - */ -public enum PlatformEnum { - /** - * Microsoft Windows - */ - WINDOWS, - /** - * A flavor of Linux - */ - LINUX, - /** - * macOS (OS X) - */ - MACOSX, - /** - * Solaris (SunOS) - */ - SOLARIS, - /** - * FreeBSD - */ - FREEBSD, - /** - * OpenBSD, WindowsCE, or an unspecified system - */ - UNKNOWN; -} diff --git a/reference/src/main/java/oshi/driver/ExtensionDriver.java b/reference/src/main/java/oshi/driver/ExtensionDriver.java deleted file mode 100644 index b237275..0000000 --- a/reference/src/main/java/oshi/driver/ExtensionDriver.java +++ /dev/null @@ -1,12 +0,0 @@ -package oshi.driver; - -/** - * A marker class for a driver that provides additional query methods to a - * {@link ComponentDriver}. - * - * @author cilki - * @since 5.0.0 - */ -public class ExtensionDriver { - -} diff --git a/reference/src/main/java/oshi/driver/Fallback.java b/reference/src/main/java/oshi/driver/Fallback.java deleted file mode 100644 index d547643..0000000 --- a/reference/src/main/java/oshi/driver/Fallback.java +++ /dev/null @@ -1,13 +0,0 @@ -package oshi.driver; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target(METHOD) -public @interface Fallback { - public Class value(); -} diff --git a/reference/src/main/java/oshi/driver/RequiresRoot.java b/reference/src/main/java/oshi/driver/RequiresRoot.java deleted file mode 100644 index ed22113..0000000 --- a/reference/src/main/java/oshi/driver/RequiresRoot.java +++ /dev/null @@ -1,12 +0,0 @@ -package oshi.driver; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target(METHOD) -public @interface RequiresRoot { -} diff --git a/reference/src/main/java/oshi/driver/SystemDriver.java b/reference/src/main/java/oshi/driver/SystemDriver.java deleted file mode 100644 index 0cf9726..0000000 --- a/reference/src/main/java/oshi/driver/SystemDriver.java +++ /dev/null @@ -1,65 +0,0 @@ -package oshi.driver; - -import java.util.stream.Stream; - -import oshi.api.MultiSystem; -import oshi.api.PlatformEnum; -import oshi.api.hardware.disk.Disk; -import oshi.api.hardware.firmware.Firmware; -import oshi.api.hardware.nic.Nic; - -@SuppressWarnings("unchecked") -public class SystemDriver implements MultiSystem { - - private Object driver; - - public SystemDriver(PlatformEnum platform) { - switch (platform) { - case FREEBSD: - driver = new SystemDriverFreeBsd(); - break; - case LINUX: - driver = new SystemDriverLinux(); - break; - case MACOSX: - driver = new SystemDriverMac(); - break; - case SOLARIS: - driver = new SystemDriverSolaris(); - break; - case WINDOWS: - driver = new SystemDriverWindows(); - break; - default: - break; - } - } - - @Override - public Stream getNicStream() { - try { - return (Stream) driver.getClass().getMethod("getNicStream").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Stream getDiskStream() { - try { - return (Stream) driver.getClass().getMethod("getDiskStream").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Firmware getFirmware() { - try { - return (Firmware) driver.getClass().getMethod("getFirmware").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - -} diff --git a/reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java b/reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java deleted file mode 100644 index 10c4105..0000000 --- a/reference/src/main/java/oshi/driver/SystemDriverFreeBsd.java +++ /dev/null @@ -1,30 +0,0 @@ -package oshi.driver; - -import java.util.stream.Stream; - -import oshi.api.FreeBsdSystem; -import oshi.api.hardware.disk.DiskFreeBsd; -import oshi.api.hardware.firmware.FirmwareFreeBsd; -import oshi.api.hardware.nic.NicFreeBsd; - -public class SystemDriverFreeBsd implements FreeBsdSystem { - - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public FirmwareFreeBsd getFirmware() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/reference/src/main/java/oshi/driver/SystemDriverMac.java b/reference/src/main/java/oshi/driver/SystemDriverMac.java deleted file mode 100644 index 09b5352..0000000 --- a/reference/src/main/java/oshi/driver/SystemDriverMac.java +++ /dev/null @@ -1,30 +0,0 @@ -package oshi.driver; - -import java.util.stream.Stream; - -import oshi.api.MacSystem; -import oshi.api.hardware.disk.DiskMac; -import oshi.api.hardware.firmware.FirmwareMac; -import oshi.api.hardware.nic.NicMac; - -public class SystemDriverMac implements MacSystem { - - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public FirmwareMac getFirmware() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/reference/src/main/java/oshi/driver/SystemDriverSolaris.java b/reference/src/main/java/oshi/driver/SystemDriverSolaris.java deleted file mode 100644 index f7d14f1..0000000 --- a/reference/src/main/java/oshi/driver/SystemDriverSolaris.java +++ /dev/null @@ -1,30 +0,0 @@ -package oshi.driver; - -import java.util.stream.Stream; - -import oshi.api.SolarisSystem; -import oshi.api.hardware.disk.DiskSolaris; -import oshi.api.hardware.firmware.FirmwareSolaris; -import oshi.api.hardware.nic.NicSolaris; - -public class SystemDriverSolaris implements SolarisSystem { - - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public FirmwareSolaris getFirmware() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/reference/src/main/java/oshi/driver/SystemDriverWindows.java b/reference/src/main/java/oshi/driver/SystemDriverWindows.java deleted file mode 100644 index 5165c47..0000000 --- a/reference/src/main/java/oshi/driver/SystemDriverWindows.java +++ /dev/null @@ -1,30 +0,0 @@ -package oshi.driver; - -import java.util.stream.Stream; - -import oshi.api.WindowsSystem; -import oshi.api.hardware.disk.DiskWindows; -import oshi.api.hardware.firmware.FirmwareWindows; -import oshi.api.hardware.nic.NicWindows; - -public class SystemDriverWindows implements WindowsSystem { - - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } - - @Override - public FirmwareWindows getFirmware() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/reference/src/main/java/oshi/example/DiskExample.java b/reference/src/main/java/oshi/example/DiskExample.java deleted file mode 100644 index f710443..0000000 --- a/reference/src/main/java/oshi/example/DiskExample.java +++ /dev/null @@ -1,17 +0,0 @@ -package oshi.example; - -import oshi.api.OSHI; - -public class DiskExample { - public static void main(String[] args) { - - OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { - System.out.println("Disk name: " + disk.getName()); - System.out.println("\tSize: " + disk.querySize()); - System.out.println("\tRead bytes: " + disk.queryReadBytes()); - System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); - System.out.println("\tQueue length: " + disk.queryQueueLength()); - System.out.println("\tTransfer time: " + disk.queryTransferTime()); - }); - } -} diff --git a/reference/src/main/java/oshi/example/FirmwareExample.java b/reference/src/main/java/oshi/example/FirmwareExample.java deleted file mode 100644 index f4c78bf..0000000 --- a/reference/src/main/java/oshi/example/FirmwareExample.java +++ /dev/null @@ -1,21 +0,0 @@ -package oshi.example; - -import oshi.api.OSHI; - -public class FirmwareExample { - - public static void main(String[] args) { - - var firmware = OSHI.getSystem().getFirmware(); - System.out.println("=== CrossPlatform Firmware ==="); - System.out.println("Name: " + firmware.getName()); - System.out.println("Description: " + firmware.getDescription()); - System.out.println("Version: " + firmware.getVersion()); - System.out.println("Revision: " + firmware.getRevision()); - System.out.println("Release: " + firmware.getReleaseDate()); - - var linuxFirmware = OSHI.getLinuxSystem().getFirmware(); - System.out.println("=== Linux Firmware ==="); - System.out.println("UEFI support: " + linuxFirmware.getUefi()); - } -} diff --git a/reference/src/main/java/oshi/example/NicExample.java b/reference/src/main/java/oshi/example/NicExample.java deleted file mode 100644 index b6b7217..0000000 --- a/reference/src/main/java/oshi/example/NicExample.java +++ /dev/null @@ -1,22 +0,0 @@ -package oshi.example; - -import java.util.Arrays; - -import oshi.api.OSHI; - -public class NicExample { - - public static void main(String[] args) throws Exception { - - OSHI.getLinuxSystem().getNicStream().forEach(nic -> { - System.out.println("NIC: " + nic.getName()); - System.out.println("\tReadBytes: " + nic.queryReadBytes()); - System.out.println("\tWriteBytes: " + nic.queryWriteBytes()); - System.out.println("\tMTU: " + nic.queryMtu()); - System.out.println("\tIPv4: " + Arrays.toString(nic.queryIpv4())); - System.out.println("\tLink Speed: " + nic.queryLinkSpeed()); - }); - - } - -} diff --git a/reference/src/site/markdown/README.md b/reference/src/site/markdown/README.md new file mode 100644 index 0000000..353f09f --- /dev/null +++ b/reference/src/site/markdown/README.md @@ -0,0 +1,223 @@ +![OSHI](https://dl.dropboxusercontent.com/s/c82qboyvvudpvdp/oshilogo.png) + +[![Maven central](https://maven-badges.herokuapp.com/maven-central/com.github.oshi/oshi-core/badge.svg?)](https://search.maven.org/search?q=com.github.oshi) +[![Build Status](https://travis-ci.org/oshi/oshi.svg)](https://travis-ci.org/oshi/oshi) +[![Coverage Status](https://coveralls.io/repos/github/oshi/oshi/badge.svg?branch=master)](https://coveralls.io/github/oshi/oshi?branch=master) +[![codecov.io](https://codecov.io/github/oshi/oshi/coverage.svg?branch=master)](https://codecov.io/github/oshi/oshi?branch=master) +[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/9332.svg)](https://scan.coverity.com/projects/dblock-oshi) +[![Codacy Grade](https://api.codacy.com/project/badge/Grade/5370178ae91d4f56b43de2f26f7c5e7a)](https://www.codacy.com/app/widdis/oshi?utm_source=github.com&utm_medium=referral&amp;utm_content=oshi/oshi&amp;utm_campaign=Badge_Grade) +[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![Join the chat at https://gitter.im/oshi/oshi](https://badges.gitter.im/oshi/oshi.svg)](https://gitter.im/oshi/oshi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![SonarQube Bugs](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=bugs)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Maintainability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Reliability](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![SonarQube Security](https://sonarcloud.io/api/project_badges/measure?project=com.github.oshi%3Aoshi-parent&metric=security_rating)](https://sonarcloud.io/dashboard?id=com.github.oshi%3Aoshi-parent) +[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/oshi/oshi.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/oshi/oshi/context:java) +[![LGTM Stats](https://www.openhub.net/p/oshi/widgets/project_thin_badge.gif)](https://www.openhub.net/p/oshi?ref=github) +[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/) +[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/dbwiddis) + +OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java. +It doesn't require the installation of any additional native libraries and aims to provide a +cross-platform implementation to retrieve system information, such as OS version, processes, +memory & CPU usage, disks & partitions, devices, sensors, etc. + +Supported platforms +--------------------------- +Windows • Linux • Mac OS X • Unix (Solaris, FreeBSD) + +Essentials +---------- +* [API](http://oshi.github.io/oshi/apidocs/) +* [Find OSHI on Maven Central](https://search.maven.org/search?q=com.github.oshi) +* [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md) +* [Upgrading from an earlier version?](https://github.com/oshi/oshi/blob/master/UPGRADING.md) + +Supported features +-------------------------- +* Computer System and firmware, baseboard +* Operating System and Version/Build +* Physical (core) and Logical (hyperthreaded) CPUs +* System and per-processor load % and tick counters +* CPU uptime, processes, and threads +* Process uptime, cpu, memory usage +* Physical and virtual memory used/available +* Mounted filesystems (type, usable and total space) +* Disk drives (model, serial, size) and partitions +* Network interfaces (IPs, bandwidth in/out) +* Battery state (% capacity, time remaining) +* Connected displays (with EDID info) +* USB Devices +* Sensors (temperature, fan speeds, voltage) + +Downloads +--------- +| Stable Release Version | Current Development Version | Dependencies | +| ------------- | ------------- | ------------- | +| [oshi-core-3.13.0](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.github.oshi&a=oshi-core&v=3.13.0&e=jar) | [oshi-core-4.0.0-SNAPSHOT](https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=com.github.oshi&a=oshi-core&v=4.0.0-SNAPSHOT&e=jar) | [JNA](https://github.com/java-native-access/jna) • [SLF4J](http://www.slf4j.org/) | + +Output +------------- +OSHI provides output directly via java methods for each of its interfaces. +By periodically polling dynamic information (e.g., every second), users can calculate and track changes. + +The `main()` method of [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +provides sample code demonstrating the use of `oshi-core` interfaces to retrieve information and calculate additional metrics such as the below examples. + +General information about the operating system and computer system. +``` +Apple macOS 10.12.3 (Sierra) build 16D32 +manufacturer: Apple Inc. +model: MacBook Pro (MacBookPro8,2) +serialnumber: C02FG6XYDF71 +``` +Processor identification. +``` +Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz + 4 physical CPU(s) + 8 logical CPU(s) +Identifier: Intel64 Family 6 Model 42 Stepping 7 +ProcessorID: BFEBFBFF000206A7 +``` +By measuring ticks (user, nice, system, idle, iowait, and irq) between time intervals, percent usage can be calculated. +Java MXBean and per-processor information is also provided. +``` +CPU, IOWait, and IRQ ticks @ 0 sec:[967282, 15484, 195343, 124216619], 6176, [4054, 2702] +CPU, IOWait, and IRQ ticks @ 1 sec:[967308, 15484, 195346, 124216790], 6177, [4057, 2705] +User: 13.0% Nice: 0.0% System: 1.5% Idle: 85.5% +CPU load: 8.8% (counting ticks) +CPU load: 9.0% (OS MXBean) +CPU load averages: 2.69 2.47 2.38 +CPU load per processor: 23.6% 1.3% 18.2% 0.7% 12.9% 0.7% 12.1% 1.3% +``` +Process information including CPU and memory per process is available. +``` +Processes: 401, Threads: 1159 + PID %CPU %MEM VSZ RSS Name + 55977 27.9 0.2 6.8 GiB 34.3 MiB java + 51820 18.7 5.6 6.3 GiB 919.2 MiB eclipse + 39272 11.2 17.8 7.1 GiB 2.8 GiB prl_vm_app + 85316 6.5 2.9 5.6 GiB 471.4 MiB thunderbird + 35301 5.4 0.5 1.7 GiB 89.8 MiB Microsoft Excel + ``` +Memory and swapfile information is available. +``` +Memory: 2.9 GiB/16 GiB +Swap used: 90.8 MiB/1 GiB +``` +The EDID for each Display is provided. This can be parsed with various utilities for detailed information. OSHI provides a summary of selected data. +``` +Displays: + Display 0: + Manuf. ID=SAM, Product ID=2ad, Analog, Serial=HA19, ManufDate=3/2008, EDID v1.3 + 41 x 27 cm (16.1 x 10.6 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: H9FQ345476 + Display 1: + Manuf. ID=SAM, Product ID=226, Analog, Serial=HA19, ManufDate=4/2007, EDID v1.3 + 41 x 26 cm (16.1 x 10.2 in) + Preferred Timing: Clock 106MHz, Active Pixels 3840x2880 + Range Limits: Field Rate 56-75 Hz vertical, 30-81 Hz horizontal, Max clock: 140 MHz + Monitor Name: SyncMaster + Serial Number: HMCP431880 +``` +Disks and usage (reads, writes, transfer times) are shown, and partitions can be mapped to filesystems. +``` +Disks: + disk0: (model: SanDisk Ultra II 960GB - S/N: 161008800550) size: 960.2 GB, reads: 1053132 (23.0 GiB), writes: 243792 (11.1 GiB), xfer: 73424854 ms + |-- disk0s1: EFI (EFI System Partition) Maj:Min=1:1, size: 209.7 MB + |-- disk0s2: Macintosh HD (Macintosh SSD) Maj:Min=1:2, size: 959.3 GB @ / + disk1: (model: Disk Image - S/N: ) size: 960.0 GB, reads: 3678 (60.0 MiB), writes: 281 (8.6 MiB), xfer: 213627 ms + |-- disk1s1: EFI (EFI System Partition) Maj:Min=1:4, size: 209.7 MB + |-- disk1s2: Dropbox (disk image) Maj:Min=1:5, size: 959.7 GB @ /Volumes/Dropbox + +``` +Sensor readings are available for some hardware (see notes in the [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md)). +``` +Sensors: + CPU Temperature: 69.8°C + Fan Speeds:[4685, 4687] + CPU Voltage: 3.9V +``` +Attached USB devices can be listed: +``` +USB Devices: + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- IR Receiver (Apple Computer, Inc.) + |-- USB Receiver (Logitech) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- FaceTime HD Camera (Built-in) (Apple Inc.) [s/n: DJHB1V077FDH5HL0] + |-- IOUSBHostDevice + |-- Apple Internal Keyboard / Trackpad (Apple Inc.) + |-- BRCM2070 Hub (Apple Inc.) + |-- Bluetooth USB Host Controller (Apple Inc.) + AppleUSBEHCI + |-- Root Hub Simulation Simulation (Apple Inc.) + |-- IOUSBHostDevice + |-- Apple Thunderbolt Display (Apple Inc.) [s/n: 162C0C25] + |-- Display Audio (Apple Inc.) [s/n: 162C0C25] + |-- FaceTime HD Camera (Display) (Apple Inc.) [s/n: CCGCAN000TDJ7DFX] + |-- USB2.0 Hub + |-- ANT USBStick2 (Dynastream Innovations) [s/n: 051] + |-- Fitbit Base Station (Fitbit Inc.) +``` + +You can run the [SystemInfoTest](https://github.com/oshi/oshi/blob/master/oshi-core/src/test/java/oshi/SystemInfoTest.java) +and see the full output for your system by cloning the project and building it with [Maven](http://maven.apache.org/index.html). + +``` +git clone https://github.com/oshi/oshi.git && cd oshi + +mvn test-compile -pl oshi-core -q exec:java \ + -Dexec.mainClass="oshi.SystemInfoTest" \ + -Dexec.classpathScope="test" +``` + +Where are we? +------------- +[OSHI originated](http://code.dblock.org/2010/06/23/introducing-oshi-operating-system-and-hardware-information-java.html) +as a platform-independent library that did not require additional software and had a license compatible with +both open source and commercial products. We've developed a strong core of features on major Operating Systems, +but we would love *you* to help by: +* Testing! Download and test the program on different software and hardware and help identify gaps that our limited development and testing may have missed. +* Contributing ports. Have an OS that's not covered? It's likely one of the existing ports can be slightly modified. +* Contributing code. See something that's not working right or could work better? Help us fix it! New contributors welcome. +* Documenting implementation. Our Wiki is blank. Want to help new users follow in your footsteps? +* Suggesting new features. Do you need OSHI to do something it doesn't currently do? Let us know. + +Acknowledgements +------------------- +Many thanks to the following companies for providing free support of Open Source projects including OSHI: +* [SonarCloud](https://sonarcloud.io/about) for a range of code quality tools +* [Travis CI](https://travis-ci.org/) for continuous integration testing +* The [jProfile Java Profiler](https://www.ej-technologies.com/products/jprofiler/overview.html) used to eliminate cpu bottlenecks + +Projects using OSHI +------------------- +* [CAS Server](https://apereo.github.io/cas) +* [JPPF](https://jppf.org/) +* [Apache Flink](https://flink.apache.org/) +* [DeepLearning4J](https://deeplearning4j.org/) +* [PSI Probe](https://github.com/psi-probe/psi-probe) +* [openHAB Systeminfo Binding](https://github.com/openhab/openhab2-addons/tree/master/addons/binding/org.openhab.binding.systeminfo) +* [Semux](https://www.semux.org/) +* [Arthas](https://alibaba.github.io/arthas/en/) +* [Hawkular Agent](https://github.com/hawkular/hawkular-agent) +* [GeoServer](https://docs.geoserver.org/stable/en/user/community/status-monitoring/index.html) +* [UniversalMediaServer](https://github.com/UniversalMediaServer/UniversalMediaServer) +* [Dagr](https://github.com/fulcrumgenomics/dagr) +* [sys-API](https://github.com/Krillsson/sys-API) +* [NexCapMAT](http://www.nexess-solutions.com/fr/produits/application-nexcap-mat/) +* [360Suite](https://360suite.io/) +* [GoMint](https://gomint.io/) +* [Stefan's OS](https://BotCompany.de/) + +License +------- +This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). diff --git a/reference/src/site/site.xml b/reference/src/site/site.xml new file mode 100644 index 0000000..16a056a --- /dev/null +++ b/reference/src/site/site.xml @@ -0,0 +1,52 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + 1.7 + + + + true + true + + + + + + + + + + + + + + \ No newline at end of file From ebbf5517300c82df76888a92767b4be6b2ea9226 Mon Sep 17 00:00:00 2001 From: Tyler Cook Date: Tue, 6 Aug 2019 16:10:46 -0500 Subject: [PATCH 3/4] Fix formatting mistake --- .../src/main/java/oshi/ApiGenerator.java | 628 +++++++++--------- .../oshi/api/DetachedContainerException.java | 2 +- .../src/main/java/oshi/api/OSHI.java | 215 +++--- .../src/main/java/oshi/api/PlatformEnum.java | 50 +- .../api/UnsupportedPlatformException.java | 2 +- .../java/oshi/driver/ComponentDriver.java | 276 ++++---- .../src/main/java/oshi/driver/Fallback.java | 2 +- .../main/java/oshi/driver/QueryStatus.java | 24 +- .../main/java/oshi/driver/SystemDriver.java | 56 +- .../java/oshi/driver/SystemDriverFreeBsd.java | 30 +- .../java/oshi/driver/SystemDriverLinux.java | 136 ++-- .../java/oshi/driver/SystemDriverMac.java | 30 +- .../java/oshi/driver/SystemDriverSolaris.java | 30 +- .../java/oshi/driver/SystemDriverWindows.java | 30 +- .../driver/hardware/disk/DiskDriverLinux.java | 116 ++-- .../hardware/disk/DiskDriverLinuxSMART.java | 24 +- .../firmware/FirmwareDriverLinux.java | 94 +-- .../driver/hardware/nic/NicDriverJava.java | 62 +- .../driver/hardware/nic/NicDriverLinux.java | 190 +++--- .../main/java/oshi/example/DiskExample.java | 20 +- .../java/oshi/example/FirmwareExample.java | 24 +- .../main/java/oshi/example/NicExample.java | 20 +- .../src/main/java/oshi/old/FileUtil.java | 307 ++++----- 23 files changed, 1191 insertions(+), 1177 deletions(-) diff --git a/reference/oshi-core/src/main/java/oshi/ApiGenerator.java b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java index fc88a31..c46a924 100644 --- a/reference/oshi-core/src/main/java/oshi/ApiGenerator.java +++ b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java @@ -61,317 +61,319 @@ */ public final class ApiGenerator { - /** - * The output source folder. - */ - private static final Path OUTPUT = Paths.get("src/gen/java"); - - /** - * The API package prefix. - */ - private static final String API_PACKAGE = "oshi.api"; - - /** - * The driver package prefix. - */ - private static final String DRIVER_PACKAGE = "oshi.driver"; - - /** - * A comment to appear below the license header and above the package - * declaration in all generated sources. - */ - private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; - - /** - * An annotation for all generated sources. - */ - private static final AnnotationSpec GENERATOR_ANNOTATION = AnnotationSpec.builder(Generated.class) - .addMember("value", String.format("\"%s\"", ApiGenerator.class.getName())).build(); - - /** - * The supported platforms. - */ - private static final String[] PLATFORMS = { "Windows", "Mac", "Linux", "Solaris", "FreeBsd" }; - - /** - * The generator's full output which is collected and written at the end. - */ - private static List files = new ArrayList<>(); - - public static void main(String[] argv) throws Exception { - try (var in = Files.newInputStream(Paths.get("definitions.json"))) { - List json = new ObjectMapper().readValue(in, new TypeReference>() { - // The age old anonymous class trick - }); - - for (var component : json) { - generateAttributeEnums(component); - - generate(component, ""); - for (var platform : PLATFORMS) { - generate(component, platform); - } - } - - generateSystemInterface(json, ""); - for (var platform : PLATFORMS) - generateSystemInterface(json, platform); - } - - // Output files if there were no errors - for (var type : files) - type.writeTo(OUTPUT); - } - - private static void generateAttributeEnums(ComponentJson component) { - String baseName = component.getBaseName(); - String pkgName = component.getPkgName(); - - var attributeEnum = TypeSpec.enumBuilder(baseName + "Attribute").addModifiers(PUBLIC) - .addAnnotation(GENERATOR_ANNOTATION); - - for (var attribute : component.attributes) { - // Generate enum constant - attributeEnum.addEnumConstant(attribute.name.toUpperCase()); - } - - files.add(JavaFile.builder(pkgName + ".internal", attributeEnum.build()).addFileComment(GENERATOR_COMMENT) - .build()); - } - - private static void generate(ComponentJson component, String platform) { - String baseName = component.getBaseName(); - String pkgName = component.getPkgName(); - - // Build classes for component - var container = TypeSpec.classBuilder(baseName + "Container" + platform).addModifiers(PUBLIC) - .addAnnotation(GENERATOR_ANNOTATION); - var containerInterface = TypeSpec.interfaceBuilder(baseName + platform).addModifiers(PUBLIC) - .addAnnotation(GENERATOR_ANNOTATION); - var queryAnnotation = TypeSpec.annotationBuilder(baseName + "Query").addModifiers(PUBLIC) - .addAnnotation(GENERATOR_ANNOTATION) - .addAnnotation( - AnnotationSpec.builder(Retention.class) - .addMember("value", "$T.RUNTIME", - ClassName.get("java.lang.annotation", "RetentionPolicy")) - .build()) - .addAnnotation(AnnotationSpec.builder(Target.class) - .addMember("value", "$T.METHOD", ClassName.get("java.lang.annotation", "ElementType")).build()); - queryAnnotation.addMethod(MethodSpec.methodBuilder("value") - .returns(ClassName.get(pkgName + ".internal", baseName + "Attribute[]")).addModifiers(PUBLIC, ABSTRACT) - .build()); - - // Setup inheritance - container.addSuperinterface(ClassName.get(pkgName, baseName + platform)); - if (!platform.isEmpty()) { - container.superclass(ClassName.get(pkgName + ".internal", baseName + "Container")); - containerInterface.addSuperinterface(ClassName.get(pkgName, baseName)); - } else { - container.addModifiers(ABSTRACT); - } - - if (component.desc != null) - container.addJavadoc(component.desc + "\n"); - - // Add driver field - container.addField(FieldSpec - .builder(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver", PRIVATE, TRANSIENT).build()); - - // Create attach method - var attach = MethodSpec.methodBuilder("attach") - .addParameter(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver") - .addStatement("this.driver = driver").addModifiers(PUBLIC); - if (!platform.isEmpty()) - attach.addStatement("super.attach(driver)"); - attach.addComment("Query all constant attributes:"); - - // Process attributes - for (var attribute : component.attributes) { - var type = ClassName.bestGuess(attribute.type); - - if (platform.isEmpty() && attribute.compatible == null - || attribute.compatible != null && attribute.compatible.contains(platform.toLowerCase())) { - - if (attribute.constant) - attach.addStatement("driver.query($T.$L)", - ClassName.get(pkgName + ".internal", baseName + "Attribute"), attribute.name.toUpperCase()); - - // Generate container field - var containerField = FieldSpec.builder(type, camel(attribute.name), PUBLIC); - if (attribute.desc != null) - containerField.addJavadoc(attribute.desc + "\n"); - container.addField(containerField.build()); - - // Generate container getter - var containerGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) - .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) - .addAnnotation(Override.class); - container.addMethod(containerGetter.build()); - - // Generate container interface getter - var containerInterfaceGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) - .addModifiers(PUBLIC, ABSTRACT); - containerInterface.addMethod(containerInterfaceGetter.build()); - - // Generate container interface query - var containerInterfaceQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) - .addModifiers(PUBLIC, ABSTRACT); - if (!attribute.constant) - containerInterface.addMethod(containerInterfaceQuery.build()); - - // Generate container query delegate - var containerQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) - .addCode(CodeBlock.builder().beginControlFlow("if (driver == null)") - .addStatement("throw new $T()", DetachedContainerException.class).endControlFlow() - .build()) - .addStatement("driver.query($T.$L)", - ClassName.get(pkgName + ".internal", baseName + "Attribute"), - attribute.name.toUpperCase()) - .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) - .addAnnotation(Override.class); - - if (!attribute.constant) - container.addMethod(containerQuery.build()); - } - } - - container.addMethod(attach.build()); - - files.add(JavaFile.builder(pkgName + ".internal", container.build()).addFileComment(GENERATOR_COMMENT).build()); - files.add(JavaFile.builder(pkgName, containerInterface.build()).addFileComment(GENERATOR_COMMENT).build()); - files.add(JavaFile.builder(pkgName + ".internal", queryAnnotation.build()).addFileComment(GENERATOR_COMMENT) - .build()); - - } - - /** - * Generate an interface for top-level System classes for the given components - * and platform. - * - * @param components - * @param platform - */ - private static void generateSystemInterface(List components, String platform) { - var system = TypeSpec.interfaceBuilder((platform.isEmpty() ? "Multi" : platform) + "System") - .addModifiers(PUBLIC).addAnnotation(GENERATOR_ANNOTATION); - - for (var component : components) { - if (!component.root) - continue; - - String baseName = component.getBaseName(); - String pkgName = component.getPkgName(); - - var type = ClassName.get(pkgName, baseName + platform).box(); - - if (component.singular) { - var get = MethodSpec.methodBuilder(camel("get", baseName)).returns(type).addModifiers(PUBLIC, ABSTRACT); - - system.addMethod(get.build()); - } else { - type = ParameterizedTypeName.get(ClassName.get(Stream.class), type); - var get = MethodSpec.methodBuilder(camel("get", baseName, "stream")).returns(type).addModifiers(PUBLIC, - ABSTRACT); - - system.addMethod(get.build()); - } - } - - files.add(JavaFile.builder(API_PACKAGE, system.build()).addFileComment(GENERATOR_COMMENT).build()); - } - - /** - * Convert the given Strings in underscore format into CamelCase format. The - * first character of the first String will always be unchanged. - * - * @param strings - * @return A CamelCase {@code String} - */ - private static String camel(String... strings) { - if (strings.length == 0) - return ""; - if (strings[0].isEmpty()) - throw new IllegalArgumentException("First component is empty"); - - return strings[0].charAt(0) + Stream.of(strings).map(String::toLowerCase) - .flatMap(s -> Arrays.stream(s.split("_"))).map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)) - .collect(Collectors.joining()).substring(1); - } - - /** - * Represents a system attribute in the definitions file. - */ - private static class AttributeJson { - /** - * The attribute's name in lowercase underscore format. - */ - public String name; - /** - * The attribute's data type. - */ - public String type; - /** - * The attribute's short description. - */ - public String desc; - /** - * Whether the attribute's value can change over the lifetime of the system. - */ - public boolean constant; - /** - * The attribute's extension type. - */ - public String extension; - /** - * A platform compatibility whitelist. - */ - public List compatible; - } - - /** - * Represents a system component in the definitions file. - */ - private static class ComponentJson { - /** - * The component's name in dot-path notation. - */ - public String name; - /** - * Whether the component is accessible from the root of the API. - */ - public boolean root; - /** - * Whether the system can contain only one or more than one of the component. - */ - public boolean singular; - /** - * The component's short description. - */ - public String desc; - /** - * The component's attributes. - */ - public List attributes; - - /** - * Parse the last element of the component's dot-path. - * - * @return The component's base name - */ - public String getBaseName() { - return name.substring(name.lastIndexOf('.') + 1); - } - - /** - * Parse the package elements from the component's dot-path. - * - * @return The component's package - */ - public String getPkgName() { - return API_PACKAGE + "." + name.substring(0, name.lastIndexOf('.')) + "." + getBaseName().toLowerCase(); - } - } - - private ApiGenerator() { - } + /** + * The output source folder. + */ + private static final Path OUTPUT = Paths.get("src/gen/java"); + + /** + * The API package prefix. + */ + private static final String API_PACKAGE = "oshi.api"; + + /** + * The driver package prefix. + */ + private static final String DRIVER_PACKAGE = "oshi.driver"; + + /** + * A comment to appear below the license header and above the package + * declaration in all generated sources. + */ + private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; + + /** + * An annotation for all generated sources. + */ + private static final AnnotationSpec GENERATOR_ANNOTATION = AnnotationSpec.builder(Generated.class) + .addMember("value", String.format("\"%s\"", ApiGenerator.class.getName())).build(); + + /** + * The supported platforms. + */ + private static final String[] PLATFORMS = { "Windows", "Mac", "Linux", "Solaris", "FreeBsd" }; + + /** + * The generator's full output which is collected and written at the end. + */ + private static List files = new ArrayList<>(); + + public static void main(String[] argv) throws Exception { + try (var in = Files.newInputStream(Paths.get("definitions.json"))) { + List json = new ObjectMapper().readValue(in, new TypeReference>() { + // The age old anonymous class trick + }); + + for (var component : json) { + generateAttributeEnums(component); + + generate(component, ""); + for (var platform : PLATFORMS) { + generate(component, platform); + } + } + + generateSystemInterface(json, ""); + for (var platform : PLATFORMS) + generateSystemInterface(json, platform); + } + + // Output files if there were no errors + for (var type : files) + type.writeTo(OUTPUT); + } + + private static void generateAttributeEnums(ComponentJson component) { + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + var attributeEnum = TypeSpec.enumBuilder(baseName + "Attribute").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + + for (var attribute : component.attributes) { + // Generate enum constant + attributeEnum.addEnumConstant(attribute.name.toUpperCase()); + } + + files.add(JavaFile.builder(pkgName + ".internal", attributeEnum.build()).addFileComment(GENERATOR_COMMENT) + .build()); + } + + private static void generate(ComponentJson component, String platform) { + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + // Build classes for component + var container = TypeSpec.classBuilder(baseName + "Container" + platform).addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + var containerInterface = TypeSpec.interfaceBuilder(baseName + platform).addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION); + var queryAnnotation = TypeSpec.annotationBuilder(baseName + "Query").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION) + .addAnnotation( + AnnotationSpec.builder(Retention.class) + .addMember("value", "$T.RUNTIME", + ClassName.get("java.lang.annotation", "RetentionPolicy")) + .build()) + .addAnnotation(AnnotationSpec.builder(Target.class) + .addMember("value", "$T.METHOD", ClassName.get("java.lang.annotation", "ElementType")).build()); + queryAnnotation.addMethod(MethodSpec.methodBuilder("value") + .returns(ClassName.get(pkgName + ".internal", baseName + "Attribute[]")).addModifiers(PUBLIC, ABSTRACT) + .build()); + + // Setup inheritance + container.addSuperinterface(ClassName.get(pkgName, baseName + platform)); + if (!platform.isEmpty()) { + container.superclass(ClassName.get(pkgName + ".internal", baseName + "Container")); + containerInterface.addSuperinterface(ClassName.get(pkgName, baseName)); + } else { + container.addModifiers(ABSTRACT); + } + + if (component.desc != null) + container.addJavadoc(component.desc + "\n"); + + // Add driver field + container.addField(FieldSpec + .builder(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver", PRIVATE, TRANSIENT).build()); + + // Create attach method + var attach = MethodSpec.methodBuilder("attach") + .addParameter(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver") + .addStatement("this.driver = driver").addModifiers(PUBLIC); + if (!platform.isEmpty()) + attach.addStatement("super.attach(driver)"); + attach.addComment("Query all constant attributes:"); + + // Process attributes + for (var attribute : component.attributes) { + var type = ClassName.bestGuess(attribute.type); + + if (platform.isEmpty() && attribute.compatible == null + || attribute.compatible != null && attribute.compatible.contains(platform.toLowerCase())) { + + if (attribute.constant) + attach.addStatement("driver.query($T.$L)", + ClassName.get(pkgName + ".internal", baseName + "Attribute"), attribute.name.toUpperCase()); + + // Generate container field + var containerField = FieldSpec.builder(type, camel(attribute.name), PUBLIC); + if (attribute.desc != null) + containerField.addJavadoc(attribute.desc + "\n"); + container.addField(containerField.build()); + + // Generate container getter + var containerGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) + .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) + .addAnnotation(Override.class); + container.addMethod(containerGetter.build()); + + // Generate container interface getter + var containerInterfaceGetter = MethodSpec.methodBuilder(camel("get", attribute.name)).returns(type) + .addModifiers(PUBLIC, ABSTRACT); + containerInterface.addMethod(containerInterfaceGetter.build()); + + // Generate container interface query + var containerInterfaceQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) + .addModifiers(PUBLIC, ABSTRACT); + if (!attribute.constant) + containerInterface.addMethod(containerInterfaceQuery.build()); + + // Generate container query delegate + var containerQuery = MethodSpec.methodBuilder(camel("query", attribute.name)).returns(type) + .addCode(CodeBlock.builder().beginControlFlow("if (driver == null)") + .addStatement("throw new $T()", DetachedContainerException.class).endControlFlow() + .build()) + .addStatement("driver.query($T.$L)", + ClassName.get(pkgName + ".internal", baseName + "Attribute"), + attribute.name.toUpperCase()) + .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) + .addAnnotation(Override.class); + + if (!attribute.constant) + container.addMethod(containerQuery.build()); + } + } + + container.addMethod(attach.build()); + + files.add(JavaFile.builder(pkgName + ".internal", container.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName, containerInterface.build()).addFileComment(GENERATOR_COMMENT).build()); + files.add(JavaFile.builder(pkgName + ".internal", queryAnnotation.build()).addFileComment(GENERATOR_COMMENT) + .build()); + + } + + /** + * Generate an interface for top-level System classes for the given + * components and platform. + * + * @param components + * @param platform + */ + private static void generateSystemInterface(List components, String platform) { + var system = TypeSpec.interfaceBuilder((platform.isEmpty() ? "Multi" : platform) + "System") + .addModifiers(PUBLIC).addAnnotation(GENERATOR_ANNOTATION); + + for (var component : components) { + if (!component.root) + continue; + + String baseName = component.getBaseName(); + String pkgName = component.getPkgName(); + + var type = ClassName.get(pkgName, baseName + platform).box(); + + if (component.singular) { + var get = MethodSpec.methodBuilder(camel("get", baseName)).returns(type).addModifiers(PUBLIC, ABSTRACT); + + system.addMethod(get.build()); + } else { + type = ParameterizedTypeName.get(ClassName.get(Stream.class), type); + var get = MethodSpec.methodBuilder(camel("get", baseName, "stream")).returns(type).addModifiers(PUBLIC, + ABSTRACT); + + system.addMethod(get.build()); + } + } + + files.add(JavaFile.builder(API_PACKAGE, system.build()).addFileComment(GENERATOR_COMMENT).build()); + } + + /** + * Convert the given Strings in underscore format into CamelCase format. The + * first character of the first String will always be unchanged. + * + * @param strings + * @return A CamelCase {@code String} + */ + private static String camel(String... strings) { + if (strings.length == 0) + return ""; + if (strings[0].isEmpty()) + throw new IllegalArgumentException("First component is empty"); + + return strings[0].charAt(0) + Stream.of(strings).map(String::toLowerCase) + .flatMap(s -> Arrays.stream(s.split("_"))).map(s -> Character.toUpperCase(s.charAt(0)) + s.substring(1)) + .collect(Collectors.joining()).substring(1); + } + + /** + * Represents a system attribute in the definitions file. + */ + private static class AttributeJson { + /** + * The attribute's name in lowercase underscore format. + */ + public String name; + /** + * The attribute's data type. + */ + public String type; + /** + * The attribute's short description. + */ + public String desc; + /** + * Whether the attribute's value can change over the lifetime of the + * system. + */ + public boolean constant; + /** + * The attribute's extension type. + */ + public String extension; + /** + * A platform compatibility whitelist. + */ + public List compatible; + } + + /** + * Represents a system component in the definitions file. + */ + private static class ComponentJson { + /** + * The component's name in dot-path notation. + */ + public String name; + /** + * Whether the component is accessible from the root of the API. + */ + public boolean root; + /** + * Whether the system can contain only one or more than one of the + * component. + */ + public boolean singular; + /** + * The component's short description. + */ + public String desc; + /** + * The component's attributes. + */ + public List attributes; + + /** + * Parse the last element of the component's dot-path. + * + * @return The component's base name + */ + public String getBaseName() { + return name.substring(name.lastIndexOf('.') + 1); + } + + /** + * Parse the package elements from the component's dot-path. + * + * @return The component's package + */ + public String getPkgName() { + return API_PACKAGE + "." + name.substring(0, name.lastIndexOf('.')) + "." + getBaseName().toLowerCase(); + } + } + + private ApiGenerator() { + } } \ No newline at end of file diff --git a/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java b/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java index b1eda0f..2251f8a 100644 --- a/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java +++ b/reference/oshi-core/src/main/java/oshi/api/DetachedContainerException.java @@ -29,6 +29,6 @@ */ public class DetachedContainerException extends IllegalStateException { - private static final long serialVersionUID = 979546852734821377L; + private static final long serialVersionUID = 979546852734821377L; } diff --git a/reference/oshi-core/src/main/java/oshi/api/OSHI.java b/reference/oshi-core/src/main/java/oshi/api/OSHI.java index 549b78f..6002869 100644 --- a/reference/oshi-core/src/main/java/oshi/api/OSHI.java +++ b/reference/oshi-core/src/main/java/oshi/api/OSHI.java @@ -37,120 +37,121 @@ */ public final class OSHI { - private static final PlatformEnum PLATFORM; + private static final PlatformEnum PLATFORM; - static { - if (Platform.isWindows()) { - PLATFORM = PlatformEnum.WINDOWS; - } else if (Platform.isLinux()) { - PLATFORM = PlatformEnum.LINUX; - } else if (Platform.isMac()) { - PLATFORM = PlatformEnum.MACOSX; - } else if (Platform.isSolaris()) { - PLATFORM = PlatformEnum.SOLARIS; - } else if (Platform.isFreeBSD()) { - PLATFORM = PlatformEnum.FREEBSD; - } else { - PLATFORM = PlatformEnum.UNSUPPORTED; - } - } + static { + if (Platform.isWindows()) { + PLATFORM = PlatformEnum.WINDOWS; + } else if (Platform.isLinux()) { + PLATFORM = PlatformEnum.LINUX; + } else if (Platform.isMac()) { + PLATFORM = PlatformEnum.MACOSX; + } else if (Platform.isSolaris()) { + PLATFORM = PlatformEnum.SOLARIS; + } else if (Platform.isFreeBSD()) { + PLATFORM = PlatformEnum.FREEBSD; + } else { + PLATFORM = PlatformEnum.UNSUPPORTED; + } + } - /** - * Get the system's platform type. - * - * @return The platform type - */ - public static PlatformEnum getPlatform() { - return PLATFORM; - } + /** + * Get the system's platform type. + * + * @return The platform type + */ + public static PlatformEnum getPlatform() { + return PLATFORM; + } - /** - * Build a disposable handle that provides cross-platform system information. - * - * @return A new {@link MultiSystem} handle - */ - public static MultiSystem getSystem() { - switch (PLATFORM) { - case FREEBSD: - return new SystemDriver(new SystemDriverFreeBsd()); - case LINUX: - return new SystemDriver(new SystemDriverLinux()); - case MACOSX: - return new SystemDriver(new SystemDriverMac()); - case SOLARIS: - return new SystemDriver(new SystemDriverSolaris()); - case WINDOWS: - return new SystemDriver(new SystemDriverWindows()); - default: - throw new UnsupportedOperationException("OSHI is not supported on this platform"); - } - } + /** + * Build a disposable handle that provides cross-platform system + * information. + * + * @return A new {@link MultiSystem} handle + */ + public static MultiSystem getSystem() { + switch (PLATFORM) { + case FREEBSD: + return new SystemDriver(new SystemDriverFreeBsd()); + case LINUX: + return new SystemDriver(new SystemDriverLinux()); + case MACOSX: + return new SystemDriver(new SystemDriverMac()); + case SOLARIS: + return new SystemDriver(new SystemDriverSolaris()); + case WINDOWS: + return new SystemDriver(new SystemDriverWindows()); + default: + throw new UnsupportedOperationException("OSHI is not supported on this platform"); + } + } - /** - * Build a disposable handle that provides Windows system information.
- *
- * Note: for cross-platform contexts, always use {@link #getSystem()}. - * - * @return A new {@link WindowsSystem} handle - */ - public static WindowsSystem getWindowsSystem() { - if (PLATFORM != PlatformEnum.WINDOWS) - throw new UnsupportedOperationException("Cannot obtain Windows handle on this platform"); - return new SystemDriverWindows(); - } + /** + * Build a disposable handle that provides Windows system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link WindowsSystem} handle + */ + public static WindowsSystem getWindowsSystem() { + if (PLATFORM != PlatformEnum.WINDOWS) + throw new UnsupportedOperationException("Cannot obtain Windows handle on this platform"); + return new SystemDriverWindows(); + } - /** - * Build a disposable handle that provides Linux system information.
- *
- * Note: for cross-platform contexts, always use {@link #getSystem()}. - * - * @return A new {@link LinuxSystem} handle - */ - public static LinuxSystem getLinuxSystem() { - if (PLATFORM != PlatformEnum.LINUX) - throw new UnsupportedOperationException("Cannot obtain Linux handle on this platform"); - return new SystemDriverLinux(); - } + /** + * Build a disposable handle that provides Linux system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link LinuxSystem} handle + */ + public static LinuxSystem getLinuxSystem() { + if (PLATFORM != PlatformEnum.LINUX) + throw new UnsupportedOperationException("Cannot obtain Linux handle on this platform"); + return new SystemDriverLinux(); + } - /** - * Build a disposable handle that provides macOS system information.
- *
- * Note: for cross-platform contexts, always use {@link #getSystem()}. - * - * @return A new {@link MacSystem} handle - */ - public static MacSystem getMacSystem() { - if (PLATFORM != PlatformEnum.MACOSX) - throw new UnsupportedOperationException("Cannot obtain MacOS handle on this platform"); - return new SystemDriverMac(); - } + /** + * Build a disposable handle that provides macOS system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link MacSystem} handle + */ + public static MacSystem getMacSystem() { + if (PLATFORM != PlatformEnum.MACOSX) + throw new UnsupportedOperationException("Cannot obtain MacOS handle on this platform"); + return new SystemDriverMac(); + } - /** - * Build a disposable handle that provides Solaris system information.
- *
- * Note: for cross-platform contexts, always use {@link #getSystem()}. - * - * @return A new {@link SolarisSystem} handle - */ - public static SolarisSystem getSolarisSystem() { - if (PLATFORM != PlatformEnum.SOLARIS) - throw new UnsupportedOperationException("Cannot obtain Solaris handle on this platform"); - return new SystemDriverSolaris(); - } + /** + * Build a disposable handle that provides Solaris system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link SolarisSystem} handle + */ + public static SolarisSystem getSolarisSystem() { + if (PLATFORM != PlatformEnum.SOLARIS) + throw new UnsupportedOperationException("Cannot obtain Solaris handle on this platform"); + return new SystemDriverSolaris(); + } - /** - * Build a disposable handle that provides FreeBSD system information.
- *
- * Note: for cross-platform contexts, always use {@link #getSystem()}. - * - * @return A new {@link FreeBsdSystem} handle - */ - public static FreeBsdSystem getFreebsdSystem() { - if (PLATFORM != PlatformEnum.FREEBSD) - throw new UnsupportedOperationException("Cannot obtain FreeBSD handle on this platform"); - return new SystemDriverFreeBsd(); - } + /** + * Build a disposable handle that provides FreeBSD system information.
+ *
+ * Note: for cross-platform contexts, always use {@link #getSystem()}. + * + * @return A new {@link FreeBsdSystem} handle + */ + public static FreeBsdSystem getFreebsdSystem() { + if (PLATFORM != PlatformEnum.FREEBSD) + throw new UnsupportedOperationException("Cannot obtain FreeBSD handle on this platform"); + return new SystemDriverFreeBsd(); + } - private OSHI() { - } + private OSHI() { + } } diff --git a/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java b/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java index 7e7be87..834350b 100644 --- a/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java +++ b/reference/oshi-core/src/main/java/oshi/api/PlatformEnum.java @@ -28,34 +28,34 @@ */ public enum PlatformEnum { - /** - * Microsoft's Windows operating system. - */ - WINDOWS, + /** + * Microsoft's Windows operating system. + */ + WINDOWS, - /** - * An operating system built on the Linux kernel. - */ - LINUX, + /** + * An operating system built on the Linux kernel. + */ + LINUX, - /** - * Apple's macOS (OS X) operating system. - */ - MACOSX, + /** + * Apple's macOS (OS X) operating system. + */ + MACOSX, - /** - * The Solaris (SunOS) operating system. - */ - SOLARIS, + /** + * The Solaris (SunOS) operating system. + */ + SOLARIS, - /** - * The FreeBSD operating system. - */ - FREEBSD, + /** + * The FreeBSD operating system. + */ + FREEBSD, - /** - * Any unsupported operating system such as OpenBSD, AIX, WindowsCE, Android, - * etc. - */ - UNSUPPORTED; + /** + * Any unsupported operating system such as OpenBSD, AIX, WindowsCE, + * Android, etc. + */ + UNSUPPORTED; } diff --git a/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java b/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java index 9432408..bf7ab1b 100644 --- a/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java +++ b/reference/oshi-core/src/main/java/oshi/api/UnsupportedPlatformException.java @@ -25,6 +25,6 @@ public class UnsupportedPlatformException extends RuntimeException { - private static final long serialVersionUID = -5396626644287029649L; + private static final long serialVersionUID = -5396626644287029649L; } diff --git a/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java index f22916c..c4c27c0 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java +++ b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java @@ -47,141 +47,143 @@ */ public class ComponentDriver { - private static final class QueryHandle implements Comparable { - public MethodHandle handle; - public Fallback fallback; - public Class cls; - - public QueryHandle(MethodHandle handle, Fallback fallback, Class cls) { - this.handle = handle; - this.fallback = fallback; - this.cls = cls; - } - - @Override - public int compareTo(QueryHandle o) { - // TODO implement query ordering with fallbacks - return 0; - } - } - - /** - * An association between attribute enums and lists of query handles in - * descending priority order. A particular query handle can exist in multiple - * lists, but not more than once in each list. - */ - private Map, List> handles; - - /** - * A list of extensions in case they are needed in the future. - */ - private List extensions; - - public ComponentDriver() { - this.handles = new HashMap<>(); - this.extensions = new LinkedList<>(); - - registerDriver(this); - } - - /** - * Query the driver hierarchy for the value of the attribute corresponding to - * the given enum. - * - * @param attribute The attribute enum of the attribute to query - */ - public void query(Enum attribute) { - - var h = handles.get(attribute); - if (h == null) { - // TODO - } - - for (var t : h) { - try { - t.handle.invoke(); - return; - } catch (Throwable e) { - // TODO log exception and continue - continue; - } - } - } - - /** - * Query every attribute in the driver hierarchy. - */ - public void queryAll() { - // Keep track of the handles that have been queried to prevent repeats - var queried = new HashSet(); - for (var handleList : handles.values()) { - for (var h : handleList) { - if (queried.contains(h.handle)) - break; - - queried.add(h.handle); - try { - h.handle.invoke(); - break; - } catch (Throwable e) { - // TODO log exception and continue - continue; - } - } - } - } - - public void register(ExtensionDriver driver) { - registerDriver(driver); - extensions.add(driver); - } - - /** - * Iterate through the methods of the given object and build a - * {@link QueryHandle} for each one containing a query annotation. - * - * @param driver The driver instance - */ - private void registerDriver(Object driver) { - Class driverClass = driver.getClass(); - while (driverClass != Object.class) { - for (Method m : driverClass.getDeclaredMethods()) { - - // Build a list of attributes defined in the annotations - var attributes = Arrays.stream(m.getDeclaredAnnotations()).flatMap(annotation -> { - try { - return Arrays.stream((Enum[]) annotation.getClass().getMethod("value").invoke(annotation)); - } catch (NoSuchMethodException e) { - // Not the annotation we're looking for - return Arrays.stream(new Enum[0]); - } catch (Exception e) { - throw new RuntimeException(e); - } - }).collect(Collectors.toList()); - - if (attributes.size() > 0) { - // Build method handle - try { - m.setAccessible(true); - var handle = MethodHandles.lookup().unreflect(m).bindTo(driver); - - for (var attribute : attributes) { - if (!handles.containsKey(attribute)) { - handles.put(attribute, new LinkedList<>()); - } - handles.get(attribute) - .add(new QueryHandle(handle, m.getAnnotation(Fallback.class), driverClass)); - } - } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot access query method: " + m.getName()); - } - } - } - - driverClass = driverClass.getSuperclass(); - } - - // Reorder each stack - handles.values().forEach(Collections::sort); - } + private static final class QueryHandle implements Comparable { + public MethodHandle handle; + public Fallback fallback; + public Class cls; + + public QueryHandle(MethodHandle handle, Fallback fallback, Class cls) { + this.handle = handle; + this.fallback = fallback; + this.cls = cls; + } + + @Override + public int compareTo(QueryHandle o) { + // TODO implement query ordering with fallbacks + return 0; + } + } + + /** + * An association between attribute enums and lists of query handles in + * descending priority order. A particular query handle can exist in + * multiple lists, but not more than once in each list. + */ + private Map, List> handles; + + /** + * A list of extensions in case they are needed in the future. + */ + private List extensions; + + public ComponentDriver() { + this.handles = new HashMap<>(); + this.extensions = new LinkedList<>(); + + registerDriver(this); + } + + /** + * Query the driver hierarchy for the value of the attribute corresponding + * to the given enum. + * + * @param attribute + * The attribute enum of the attribute to query + */ + public void query(Enum attribute) { + + var h = handles.get(attribute); + if (h == null) { + // TODO + } + + for (var t : h) { + try { + t.handle.invoke(); + return; + } catch (Throwable e) { + // TODO log exception and continue + continue; + } + } + } + + /** + * Query every attribute in the driver hierarchy. + */ + public void queryAll() { + // Keep track of the handles that have been queried to prevent repeats + var queried = new HashSet(); + for (var handleList : handles.values()) { + for (var h : handleList) { + if (queried.contains(h.handle)) + break; + + queried.add(h.handle); + try { + h.handle.invoke(); + break; + } catch (Throwable e) { + // TODO log exception and continue + continue; + } + } + } + } + + public void register(ExtensionDriver driver) { + registerDriver(driver); + extensions.add(driver); + } + + /** + * Iterate through the methods of the given object and build a + * {@link QueryHandle} for each one containing a query annotation. + * + * @param driver + * The driver instance + */ + private void registerDriver(Object driver) { + Class driverClass = driver.getClass(); + while (driverClass != Object.class) { + for (Method m : driverClass.getDeclaredMethods()) { + + // Build a list of attributes defined in the annotations + var attributes = Arrays.stream(m.getDeclaredAnnotations()).flatMap(annotation -> { + try { + return Arrays.stream((Enum[]) annotation.getClass().getMethod("value").invoke(annotation)); + } catch (NoSuchMethodException e) { + // Not the annotation we're looking for + return Arrays.stream(new Enum[0]); + } catch (Exception e) { + throw new RuntimeException(e); + } + }).collect(Collectors.toList()); + + if (attributes.size() > 0) { + // Build method handle + try { + m.setAccessible(true); + var handle = MethodHandles.lookup().unreflect(m).bindTo(driver); + + for (var attribute : attributes) { + if (!handles.containsKey(attribute)) { + handles.put(attribute, new LinkedList<>()); + } + handles.get(attribute) + .add(new QueryHandle(handle, m.getAnnotation(Fallback.class), driverClass)); + } + } catch (IllegalAccessException e) { + throw new RuntimeException("Cannot access query method: " + m.getName()); + } + } + } + + driverClass = driverClass.getSuperclass(); + } + + // Reorder each stack + handles.values().forEach(Collections::sort); + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/Fallback.java b/reference/oshi-core/src/main/java/oshi/driver/Fallback.java index 7198dc2..0c46f24 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/Fallback.java +++ b/reference/oshi-core/src/main/java/oshi/driver/Fallback.java @@ -32,5 +32,5 @@ @Retention(RUNTIME) @Target(METHOD) public @interface Fallback { - public Class value(); + public Class value(); } diff --git a/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java b/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java index 72245d1..6a5036a 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java +++ b/reference/oshi-core/src/main/java/oshi/driver/QueryStatus.java @@ -29,18 +29,18 @@ */ public enum QueryStatus { - /** - * Indicates the query completed successfully and the corresponding container - * object has been updated. - */ - OK, + /** + * Indicates the query completed successfully and the corresponding + * container object has been updated. + */ + OK, - /** - * Indicates the query timed-out and the corresponding container object has not - * been updated. - */ - TIMEOUT, + /** + * Indicates the query timed-out and the corresponding container object has + * not been updated. + */ + TIMEOUT, - // TODO - MISSED_READING, PROCESS_TERMINATED; + // TODO + MISSED_READING, PROCESS_TERMINATED; } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java index ef5015c..5955697 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java @@ -34,37 +34,37 @@ @SuppressWarnings("unchecked") public class SystemDriver implements MultiSystem { - private Object driver; + private Object driver; - public SystemDriver(Object driver) { - this.driver = Objects.requireNonNull(driver); - } + public SystemDriver(Object driver) { + this.driver = Objects.requireNonNull(driver); + } - @Override - public Stream getNicStream() { - try { - return (Stream) driver.getClass().getMethod("getNicStream").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + @Override + public Stream getNicStream() { + try { + return (Stream) driver.getClass().getMethod("getNicStream").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - @Override - public Stream getDiskStream() { - try { - return (Stream) driver.getClass().getMethod("getDiskStream").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + @Override + public Stream getDiskStream() { + try { + return (Stream) driver.getClass().getMethod("getDiskStream").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - @Override - public Firmware getFirmware() { - try { - return (Firmware) driver.getClass().getMethod("getFirmware").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + @Override + public Firmware getFirmware() { + try { + return (Firmware) driver.getClass().getMethod("getFirmware").invoke(driver); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java index 68ec238..6a4cef1 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java @@ -32,22 +32,22 @@ public class SystemDriverFreeBsd implements FreeBsdSystem { - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public FirmwareFreeBsd getFirmware() { - // TODO Auto-generated method stub - return null; - } + @Override + public FirmwareFreeBsd getFirmware() { + // TODO Auto-generated method stub + return null; + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java index a880969..1cc1787 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java @@ -44,73 +44,73 @@ public class SystemDriverLinux implements LinuxSystem { - @Override - public Stream getNicStream() { - try { - return NetworkInterface.networkInterfaces().map(nif -> { - var container = new NicContainerLinux(); - container.name = nif.getName(); - var driver = new NicDriverLinux(container); - driver.register(new NicDriverJava(container, nif)); - - container.attach(driver); - return container; - }); - } catch (SocketException e) { - // No interfaces found or I/O error occurred - return Stream.empty(); - } - } - - @Override - public Stream getDiskStream() { - List results = new ArrayList<>(); - - Udev.UdevDevice device = null; - Udev.UdevListEntry entry; - Udev.UdevListEntry oldEntry; - - Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); - Udev.UdevEnumerate enumerate = Udev.INSTANCE.udev_enumerate_new(handle); - Udev.INSTANCE.udev_enumerate_add_match_subsystem(enumerate, "block"); - Udev.INSTANCE.udev_enumerate_scan_devices(enumerate); - - entry = Udev.INSTANCE.udev_enumerate_get_list_entry(enumerate); - while (true) { - oldEntry = entry; - device = Udev.INSTANCE.udev_device_new_from_syspath(handle, Udev.INSTANCE.udev_list_entry_get_name(entry)); - if (device == null) { - break; - } - - // Ignore loopback and ram disks; do nothing - if (!Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/loop") - && !Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/ram")) { - if ("disk".equals(Udev.INSTANCE.udev_device_get_devtype(device))) { - var container = new DiskContainerLinux(); - container.name = Udev.INSTANCE.udev_list_entry_get_name(entry); - var driver = new DiskDriverLinux(container); - // TODO SMART extension - container.attach(driver); - - results.add(container); - } - } - - entry = Udev.INSTANCE.udev_list_entry_get_next(oldEntry); - Udev.INSTANCE.udev_device_unref(device); - } - - return results.stream(); - } - - @Override - public FirmwareLinux getFirmware() { - var container = new FirmwareContainerLinux(); - var driver = new FirmwareDriverLinux(container); - - container.attach(driver); - return container; - } + @Override + public Stream getNicStream() { + try { + return NetworkInterface.networkInterfaces().map(nif -> { + var container = new NicContainerLinux(); + container.name = nif.getName(); + var driver = new NicDriverLinux(container); + driver.register(new NicDriverJava(container, nif)); + + container.attach(driver); + return container; + }); + } catch (SocketException e) { + // No interfaces found or I/O error occurred + return Stream.empty(); + } + } + + @Override + public Stream getDiskStream() { + List results = new ArrayList<>(); + + Udev.UdevDevice device = null; + Udev.UdevListEntry entry; + Udev.UdevListEntry oldEntry; + + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevEnumerate enumerate = Udev.INSTANCE.udev_enumerate_new(handle); + Udev.INSTANCE.udev_enumerate_add_match_subsystem(enumerate, "block"); + Udev.INSTANCE.udev_enumerate_scan_devices(enumerate); + + entry = Udev.INSTANCE.udev_enumerate_get_list_entry(enumerate); + while (true) { + oldEntry = entry; + device = Udev.INSTANCE.udev_device_new_from_syspath(handle, Udev.INSTANCE.udev_list_entry_get_name(entry)); + if (device == null) { + break; + } + + // Ignore loopback and ram disks; do nothing + if (!Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/loop") + && !Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/ram")) { + if ("disk".equals(Udev.INSTANCE.udev_device_get_devtype(device))) { + var container = new DiskContainerLinux(); + container.name = Udev.INSTANCE.udev_list_entry_get_name(entry); + var driver = new DiskDriverLinux(container); + // TODO SMART extension + container.attach(driver); + + results.add(container); + } + } + + entry = Udev.INSTANCE.udev_list_entry_get_next(oldEntry); + Udev.INSTANCE.udev_device_unref(device); + } + + return results.stream(); + } + + @Override + public FirmwareLinux getFirmware() { + var container = new FirmwareContainerLinux(); + var driver = new FirmwareDriverLinux(container); + + container.attach(driver); + return container; + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java index c3e54a3..61d9fad 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java @@ -32,22 +32,22 @@ public class SystemDriverMac implements MacSystem { - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public FirmwareMac getFirmware() { - // TODO Auto-generated method stub - return null; - } + @Override + public FirmwareMac getFirmware() { + // TODO Auto-generated method stub + return null; + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java index 74f7acd..e152aa3 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java @@ -32,22 +32,22 @@ public class SystemDriverSolaris implements SolarisSystem { - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public FirmwareSolaris getFirmware() { - // TODO Auto-generated method stub - return null; - } + @Override + public FirmwareSolaris getFirmware() { + // TODO Auto-generated method stub + return null; + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java index 78c16c4..c7fea4f 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java +++ b/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java @@ -32,22 +32,22 @@ public class SystemDriverWindows implements WindowsSystem { - @Override - public Stream getNicStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getNicStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public Stream getDiskStream() { - // TODO Auto-generated method stub - return null; - } + @Override + public Stream getDiskStream() { + // TODO Auto-generated method stub + return null; + } - @Override - public FirmwareWindows getFirmware() { - // TODO Auto-generated method stub - return null; - } + @Override + public FirmwareWindows getFirmware() { + // TODO Auto-generated method stub + return null; + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java index 822df4d..ddff046 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java @@ -42,63 +42,63 @@ public class DiskDriverLinux extends ComponentDriver { - private DiskContainerLinux container; - - public DiskDriverLinux(DiskContainerLinux container) { - this.container = container; - } - - /** - * The size of a logical sector in bytes. - */ - private static final int SECTOR_SIZE = 512; - - // Get a list of orders to pass to ParseUtil - private static final int[] UDEV_STAT_ORDERS = new int[] { - // - 0, // Reads - 2, // Read bytes - 4, // Writes - 6, // Write bytes - 8, // Queue length - 9 // Transfer time - }; - - // There are at least 11 elements in udev stat output. Some platforms have - // 12 but we want the last 11. ParseUtil works from the right - private static final int UDEV_STAT_LENGTH = 11; - - @DiskQuery({ MODEL, SERIAL, SIZE, NAME }) - private void diskInfo() { - Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); - Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); - - container.model = Udev.INSTANCE.udev_device_get_property_value(device, "ID_MODEL"); - container.serial = Udev.INSTANCE.udev_device_get_property_value(device, "ID_SERIAL_SHORT"); - container.size = ParseUtil.parseLongOrDefault(Udev.INSTANCE.udev_device_get_sysattr_value(device, "size"), 0L) - * 512; - - Udev.INSTANCE.udev_device_unref(device); - Udev.INSTANCE.udev_unref(handle); - } - - @DiskQuery({ READS, READ_BYTES, WRITES, WRITE_BYTES, QUEUE_LENGTH, TRANSFER_TIME }) - private void diskStats() { - Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); - Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); - - long[] deviceStats = ParseUtil.parseStringToLongArray( - Udev.INSTANCE.udev_device_get_sysattr_value(device, "stat"), UDEV_STAT_ORDERS, UDEV_STAT_LENGTH, ' '); - - container.reads = deviceStats[0]; - container.readBytes = deviceStats[1] * SECTOR_SIZE; - container.writes = deviceStats[2]; - container.writeBytes = deviceStats[3] * SECTOR_SIZE; - container.queueLength = deviceStats[4]; - container.transferTime = deviceStats[5]; - - Udev.INSTANCE.udev_device_unref(device); - Udev.INSTANCE.udev_unref(handle); - } + private DiskContainerLinux container; + + public DiskDriverLinux(DiskContainerLinux container) { + this.container = container; + } + + /** + * The size of a logical sector in bytes. + */ + private static final int SECTOR_SIZE = 512; + + // Get a list of orders to pass to ParseUtil + private static final int[] UDEV_STAT_ORDERS = new int[] { + // + 0, // Reads + 2, // Read bytes + 4, // Writes + 6, // Write bytes + 8, // Queue length + 9 // Transfer time + }; + + // There are at least 11 elements in udev stat output. Some platforms have + // 12 but we want the last 11. ParseUtil works from the right + private static final int UDEV_STAT_LENGTH = 11; + + @DiskQuery({ MODEL, SERIAL, SIZE, NAME }) + private void diskInfo() { + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); + + container.model = Udev.INSTANCE.udev_device_get_property_value(device, "ID_MODEL"); + container.serial = Udev.INSTANCE.udev_device_get_property_value(device, "ID_SERIAL_SHORT"); + container.size = ParseUtil.parseLongOrDefault(Udev.INSTANCE.udev_device_get_sysattr_value(device, "size"), 0L) + * 512; + + Udev.INSTANCE.udev_device_unref(device); + Udev.INSTANCE.udev_unref(handle); + } + + @DiskQuery({ READS, READ_BYTES, WRITES, WRITE_BYTES, QUEUE_LENGTH, TRANSFER_TIME }) + private void diskStats() { + Udev.UdevHandle handle = Udev.INSTANCE.udev_new(); + Udev.UdevDevice device = Udev.INSTANCE.udev_device_new_from_syspath(handle, container.name); + + long[] deviceStats = ParseUtil.parseStringToLongArray( + Udev.INSTANCE.udev_device_get_sysattr_value(device, "stat"), UDEV_STAT_ORDERS, UDEV_STAT_LENGTH, ' '); + + container.reads = deviceStats[0]; + container.readBytes = deviceStats[1] * SECTOR_SIZE; + container.writes = deviceStats[2]; + container.writeBytes = deviceStats[3] * SECTOR_SIZE; + container.queueLength = deviceStats[4]; + container.transferTime = deviceStats[5]; + + Udev.INSTANCE.udev_device_unref(device); + Udev.INSTANCE.udev_unref(handle); + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java index fa413ca..36131a2 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java @@ -51,18 +51,18 @@ public class DiskDriverLinuxSMART extends ExtensionDriver { - private DiskContainerLinux container; + private DiskContainerLinux container; - public DiskDriverLinuxSMART(DiskContainerLinux container) { - this.container = container; - } + public DiskDriverLinuxSMART(DiskContainerLinux container) { + this.container = container; + } - @DiskQuery({ MODEL_FAMILY, FIRMWARE_VERSION, ROTATION_RATE, READ_ERROR_RATE, SPIN_UP_TIME, START_STOP_CYCLES, - REALLOCATED_SECTORS, SEEK_ERROR_RATE, POWER_ON_TIME, SPIN_RETRIES, CALIBRATION_RETRIES, POWER_CYCLES, - POWEROFF_RETRACTS, LOAD_CYCLES, TEMPERATURE, REALLOCATED_EVENTS, CURRENT_PENDING_SECTOR, - OFFLINE_UNCORRECTABLE, CRC_ERRORS, MULTIZONE_ERROR_RATE }) - private void diskStats() { - // TODO parse command - ExecutingCommand.runNative("sudo smartctl --all " + container.name); - } + @DiskQuery({ MODEL_FAMILY, FIRMWARE_VERSION, ROTATION_RATE, READ_ERROR_RATE, SPIN_UP_TIME, START_STOP_CYCLES, + REALLOCATED_SECTORS, SEEK_ERROR_RATE, POWER_ON_TIME, SPIN_RETRIES, CALIBRATION_RETRIES, POWER_CYCLES, + POWEROFF_RETRACTS, LOAD_CYCLES, TEMPERATURE, REALLOCATED_EVENTS, CURRENT_PENDING_SECTOR, + OFFLINE_UNCORRECTABLE, CRC_ERRORS, MULTIZONE_ERROR_RATE }) + private void diskStats() { + // TODO parse command + ExecutingCommand.runNative("sudo smartctl --all " + container.name); + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java index b72cde8..9814192 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java @@ -40,62 +40,62 @@ public class FirmwareDriverLinux extends ComponentDriver { - private FirmwareContainerLinux container; + private FirmwareContainerLinux container; - public FirmwareDriverLinux(FirmwareContainerLinux container) { - this.container = container; - } + public FirmwareDriverLinux(FirmwareContainerLinux container) { + this.container = container; + } - private static final String SYSFS_SERIAL_PATH = "/sys/devices/virtual/dmi/id/"; + private static final String SYSFS_SERIAL_PATH = "/sys/devices/virtual/dmi/id/"; - @FirmwareQuery(NAME) - public void name() { - } + @FirmwareQuery(NAME) + public void name() { + } - @FirmwareQuery(MANUFACTURER) - private void manufacturer() { - container.manufacturer = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_vendor").trim(); - } + @FirmwareQuery(MANUFACTURER) + private void manufacturer() { + container.manufacturer = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_vendor").trim(); + } - @FirmwareQuery(DESCRIPTION) - private void description() { - container.description = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "modalias").trim(); - } + @FirmwareQuery(DESCRIPTION) + private void description() { + container.description = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "modalias").trim(); + } - @FirmwareQuery(VERSION) - private void version() { - container.version = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_version").trim(); - } + @FirmwareQuery(VERSION) + private void version() { + container.version = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_version").trim(); + } - @FirmwareQuery(RELEASE_DATE) - private void releaseDate() { - container.releaseDate = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_date").trim(); - } + @FirmwareQuery(RELEASE_DATE) + private void releaseDate() { + container.releaseDate = FileUtil.getStringFromFile(SYSFS_SERIAL_PATH + "bios_date").trim(); + } - @RequiresRoot - @FirmwareQuery(REVISION) - private void revision() { - final String marker = "Bios Revision:"; - for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { - if (checkLine.contains(marker)) { - container.revision = checkLine.split(marker)[1].trim(); - return; - } - } - } + @RequiresRoot + @FirmwareQuery(REVISION) + private void revision() { + final String marker = "Bios Revision:"; + for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { + if (checkLine.contains(marker)) { + container.revision = checkLine.split(marker)[1].trim(); + return; + } + } + } - @RequiresRoot - @FirmwareQuery(UEFI) - private void uefi() { - final String marker = "UEFI is supported"; - for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { - if (checkLine.contains(marker)) { - container.uefi = true; - return; - } - } + @RequiresRoot + @FirmwareQuery(UEFI) + private void uefi() { + final String marker = "UEFI is supported"; + for (final String checkLine : ExecutingCommand.runNative("dmidecode -t bios")) { + if (checkLine.contains(marker)) { + container.uefi = true; + return; + } + } - container.uefi = false; - } + container.uefi = false; + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java index 4aafc83..1b6a3d4 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java @@ -42,43 +42,43 @@ */ public class NicDriverJava extends ExtensionDriver { - protected NetworkInterface instance; - private NicContainer container; + protected NetworkInterface instance; + private NicContainer container; - public NicDriverJava(NicContainer container, NetworkInterface instance) { - this.container = container; - this.instance = instance; - } + public NicDriverJava(NicContainer container, NetworkInterface instance) { + this.container = container; + this.instance = instance; + } - @NicQuery(VIRTUAL) - private void virtual() { - container.virtual = instance.isVirtual(); - } + @NicQuery(VIRTUAL) + private void virtual() { + container.virtual = instance.isVirtual(); + } - @NicQuery(NAME) - private void name() { - container.name = instance.getName(); - } + @NicQuery(NAME) + private void name() { + container.name = instance.getName(); + } - @NicQuery(MAC) - private void mac() throws SocketException { - } + @NicQuery(MAC) + private void mac() throws SocketException { + } - @NicQuery(IPV4) - private void ipv4() { - container.ipv4 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) - .filter(address -> !address.contains(":")).toArray(String[]::new); - } + @NicQuery(IPV4) + private void ipv4() { + container.ipv4 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) + .filter(address -> !address.contains(":")).toArray(String[]::new); + } - @NicQuery(IPV6) - private void ipv6() { - container.ipv6 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) - .filter(address -> address.contains(":")).toArray(String[]::new); - } + @NicQuery(IPV6) + private void ipv6() { + container.ipv6 = instance.getInterfaceAddresses().stream().map(n -> n.getAddress().getHostAddress()) + .filter(address -> address.contains(":")).toArray(String[]::new); + } - @NicQuery(MTU) - private void mtu() throws SocketException { - container.mtu = instance.getMTU(); - } + @NicQuery(MTU) + private void mtu() throws SocketException { + container.mtu = instance.getMTU(); + } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java index 477ce90..cf0710c 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java @@ -50,124 +50,124 @@ public class NicDriverLinux extends ComponentDriver { - private NicContainerLinux container; - - public NicDriverLinux(NicContainerLinux container) { - this.container = container; - } - - @NicQuery(READ_BYTES) - private void readBytes() { - container.readBytes = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_bytes", container.name)); - } - - @NicQuery(WRITE_BYTES) - private void writeBytes() { - container.writeBytes = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_bytes", container.name)); - } + private NicContainerLinux container; + + public NicDriverLinux(NicContainerLinux container) { + this.container = container; + } + + @NicQuery(READ_BYTES) + private void readBytes() { + container.readBytes = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_bytes", container.name)); + } + + @NicQuery(WRITE_BYTES) + private void writeBytes() { + container.writeBytes = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_bytes", container.name)); + } - @NicQuery(READ_PACKETS) - private void readPackets() { - container.readPackets = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_packets", container.name)); - } + @NicQuery(READ_PACKETS) + private void readPackets() { + container.readPackets = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_packets", container.name)); + } - @NicQuery(WRITE_PACKETS) - private void writePackets() { - container.writePackets = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_packets", container.name)); - } + @NicQuery(WRITE_PACKETS) + private void writePackets() { + container.writePackets = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_packets", container.name)); + } - @NicQuery(READ_ERRORS) - private void readErrors() { - container.readErrors = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_errors", container.name)); - } + @NicQuery(READ_ERRORS) + private void readErrors() { + container.readErrors = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_errors", container.name)); + } - @NicQuery(WRITE_ERRORS) - private void writeErrors() { - container.writeErrors = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_errors", container.name)); - } + @NicQuery(WRITE_ERRORS) + private void writeErrors() { + container.writeErrors = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_errors", container.name)); + } - @NicQuery(DESCRIPTION) - private void description() { - // TODO Auto-generated method stub + @NicQuery(DESCRIPTION) + private void description() { + // TODO Auto-generated method stub - } + } - @NicQuery(BROADCAST) - private void broadcast() { - // TODO Auto-generated method stub + @NicQuery(BROADCAST) + private void broadcast() { + // TODO Auto-generated method stub - } + } - @NicQuery(NETMASK) - private void netmask() { - // TODO Auto-generated method stub + @NicQuery(NETMASK) + private void netmask() { + // TODO Auto-generated method stub - } + } - @NicQuery(READ_DROPS) - private void readDrops() { - container.readDrops = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_dropped", container.name)); + @NicQuery(READ_DROPS) + private void readDrops() { + container.readDrops = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/rx_dropped", container.name)); - } + } - @NicQuery(WRITE_DROPS) - private void writeDrops() { - container.writeDrops = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_dropped", container.name)); - } + @NicQuery(WRITE_DROPS) + private void writeDrops() { + container.writeDrops = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/tx_dropped", container.name)); + } - @NicQuery(WRITE_COLLISIONS) - private void writeCollisions() { - container.writeCollisions = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/collisions", container.name)); - } + @NicQuery(WRITE_COLLISIONS) + private void writeCollisions() { + container.writeCollisions = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/statistics/collisions", container.name)); + } - @NicQuery(LINK_SPEED) - private void linkSpeed() { - container.linkSpeed = FileUtil - .getUnsignedLongFromFile(String.format("/sys/class/net/%s/speed", container.name)); - } + @NicQuery(LINK_SPEED) + private void linkSpeed() { + container.linkSpeed = FileUtil + .getUnsignedLongFromFile(String.format("/sys/class/net/%s/speed", container.name)); + } - @NicQuery(DEFAULT_GATEWAY) - private void defaultGateway() { - // TODO Auto-generated method stub + @NicQuery(DEFAULT_GATEWAY) + private void defaultGateway() { + // TODO Auto-generated method stub - } + } - @NicQuery(FLAG_UP) - private void flagUp() { - // TODO Auto-generated method stub + @NicQuery(FLAG_UP) + private void flagUp() { + // TODO Auto-generated method stub - } + } - @NicQuery(FLAG_RUNNING) - private void flagRunning() { - // TODO Auto-generated method stub + @NicQuery(FLAG_RUNNING) + private void flagRunning() { + // TODO Auto-generated method stub - } - - @NicQuery(FLAG_LOOPBACK) - private void flagLoopback() { - // TODO Auto-generated method stub - - } + } + + @NicQuery(FLAG_LOOPBACK) + private void flagLoopback() { + // TODO Auto-generated method stub + + } - @NicQuery(FLAG_MULTICAST) - private void flagMulticast() { - // TODO Auto-generated method stub + @NicQuery(FLAG_MULTICAST) + private void flagMulticast() { + // TODO Auto-generated method stub - } + } - @NicQuery(MTU) - private void mac() { - container.mtu = FileUtil.getIntFromFile(String.format("/sys/class/net/%s/mtu", container.name)); - } + @NicQuery(MTU) + private void mac() { + container.mtu = FileUtil.getIntFromFile(String.format("/sys/class/net/%s/mtu", container.name)); + } } diff --git a/reference/oshi-core/src/main/java/oshi/example/DiskExample.java b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java index bea1ae4..075682f 100644 --- a/reference/oshi-core/src/main/java/oshi/example/DiskExample.java +++ b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java @@ -26,15 +26,15 @@ import oshi.api.OSHI; public class DiskExample { - public static void main(String[] args) { + public static void main(String[] args) { - OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { - System.out.println("Disk name: " + disk.getName()); - System.out.println("\tSize: " + disk.querySize()); - System.out.println("\tRead bytes: " + disk.queryReadBytes()); - System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); - System.out.println("\tQueue length: " + disk.queryQueueLength()); - System.out.println("\tTransfer time: " + disk.queryTransferTime()); - }); - } + OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.querySize()); + System.out.println("\tRead bytes: " + disk.queryReadBytes()); + System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); + System.out.println("\tQueue length: " + disk.queryQueueLength()); + System.out.println("\tTransfer time: " + disk.queryTransferTime()); + }); + } } diff --git a/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java index d17f976..af7c201 100644 --- a/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java +++ b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java @@ -27,18 +27,18 @@ public class FirmwareExample { - public static void main(String[] args) { + public static void main(String[] args) { - var firmware = OSHI.getSystem().getFirmware(); - System.out.println("=== CrossPlatform Firmware ==="); - System.out.println("Name: " + firmware.getName()); - System.out.println("Description: " + firmware.getDescription()); - System.out.println("Version: " + firmware.getVersion()); - System.out.println("Revision: " + firmware.getRevision()); - System.out.println("Release: " + firmware.getReleaseDate()); + var firmware = OSHI.getSystem().getFirmware(); + System.out.println("=== CrossPlatform Firmware ==="); + System.out.println("Name: " + firmware.getName()); + System.out.println("Description: " + firmware.getDescription()); + System.out.println("Version: " + firmware.getVersion()); + System.out.println("Revision: " + firmware.getRevision()); + System.out.println("Release: " + firmware.getReleaseDate()); - var linuxFirmware = OSHI.getLinuxSystem().getFirmware(); - System.out.println("=== Linux Firmware ==="); - System.out.println("UEFI support: " + linuxFirmware.getUefi()); - } + var linuxFirmware = OSHI.getLinuxSystem().getFirmware(); + System.out.println("=== Linux Firmware ==="); + System.out.println("UEFI support: " + linuxFirmware.getUefi()); + } } diff --git a/reference/oshi-core/src/main/java/oshi/example/NicExample.java b/reference/oshi-core/src/main/java/oshi/example/NicExample.java index 16feafa..3571bd4 100644 --- a/reference/oshi-core/src/main/java/oshi/example/NicExample.java +++ b/reference/oshi-core/src/main/java/oshi/example/NicExample.java @@ -29,17 +29,17 @@ public class NicExample { - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception { - OSHI.getLinuxSystem().getNicStream().forEach(nic -> { - System.out.println("NIC: " + nic.getName()); - System.out.println("\tReadBytes: " + nic.queryReadBytes()); - System.out.println("\tWriteBytes: " + nic.queryWriteBytes()); - System.out.println("\tMTU: " + nic.queryMtu()); - System.out.println("\tIPv4: " + Arrays.toString(nic.queryIpv4())); - System.out.println("\tLink Speed: " + nic.queryLinkSpeed()); - }); + OSHI.getLinuxSystem().getNicStream().forEach(nic -> { + System.out.println("NIC: " + nic.getName()); + System.out.println("\tReadBytes: " + nic.queryReadBytes()); + System.out.println("\tWriteBytes: " + nic.queryWriteBytes()); + System.out.println("\tMTU: " + nic.queryMtu()); + System.out.println("\tIPv4: " + Arrays.toString(nic.queryIpv4())); + System.out.println("\tLink Speed: " + nic.queryLinkSpeed()); + }); - } + } } diff --git a/reference/oshi-core/src/main/java/oshi/old/FileUtil.java b/reference/oshi-core/src/main/java/oshi/old/FileUtil.java index 75da965..2a3c6e9 100644 --- a/reference/oshi-core/src/main/java/oshi/old/FileUtil.java +++ b/reference/oshi-core/src/main/java/oshi/old/FileUtil.java @@ -42,161 +42,170 @@ * @author widdis[at]gmail[dot]com */ public class FileUtil { - private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class); + private static final Logger LOG = LoggerFactory.getLogger(FileUtil.class); - private FileUtil() { - } + private FileUtil() { + } - /** - * Read an entire file at one time. Intended primarily for Linux /proc - * filesystem to avoid recalculating file contents on iterative reads. - * - * @param filename The file to read - * - * @return A list of Strings representing each line of the file, or an empty - * list if file could not be read or is empty - */ - public static List readFile(String filename) { - return readFile(filename, true); - } + /** + * Read an entire file at one time. Intended primarily for Linux /proc + * filesystem to avoid recalculating file contents on iterative reads. + * + * @param filename + * The file to read + * + * @return A list of Strings representing each line of the file, or an empty + * list if file could not be read or is empty + */ + public static List readFile(String filename) { + return readFile(filename, true); + } - /** - * Read an entire file at one time. Intended primarily for Linux /proc - * filesystem to avoid recalculating file contents on iterative reads. - * - * @param filename The file to read - * @param reportError Whether to log errors reading the file - * - * @return A list of Strings representing each line of the file, or an empty - * list if file could not be read or is empty - */ - public static List readFile(String filename, boolean reportError) { - if (new File(filename).canRead()) { - if (LOG.isDebugEnabled()) { - LOG.debug("Reading file {}", filename); - } - try { - return Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8); - } catch (IOException e) { - if (reportError) { - LOG.error("Error reading file {}. {}", filename, e); - } - } - } else if (reportError) { - LOG.warn("File not found or not readable: {}", filename); - } - return new ArrayList<>(); - } + /** + * Read an entire file at one time. Intended primarily for Linux /proc + * filesystem to avoid recalculating file contents on iterative reads. + * + * @param filename + * The file to read + * @param reportError + * Whether to log errors reading the file + * + * @return A list of Strings representing each line of the file, or an empty + * list if file could not be read or is empty + */ + public static List readFile(String filename, boolean reportError) { + if (new File(filename).canRead()) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + try { + return Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8); + } catch (IOException e) { + if (reportError) { + LOG.error("Error reading file {}. {}", filename, e); + } + } + } else if (reportError) { + LOG.warn("File not found or not readable: {}", filename); + } + return new ArrayList<>(); + } - /** - * Read a file and return the long value contained therein. Intended primarily - * for Linux /sys filesystem - * - * @param filename The file to read - * @return The value contained in the file, if any; otherwise zero - */ - public static long getLongFromFile(String filename) { - if (LOG.isDebugEnabled()) { - LOG.debug("Reading file {}", filename); - } - List read = FileUtil.readFile(filename, false); - if (!read.isEmpty()) { - if (LOG.isTraceEnabled()) { - LOG.trace("Read {}", read.get(0)); - } - return ParseUtil.parseLongOrDefault(read.get(0), 0L); - } - return 0L; - } + /** + * Read a file and return the long value contained therein. Intended + * primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static long getLongFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return ParseUtil.parseLongOrDefault(read.get(0), 0L); + } + return 0L; + } - /** - * Read a file and return the unsigned long value contained therein as a long. - * Intended primarily for Linux /sys filesystem - * - * @param filename The file to read - * @return The value contained in the file, if any; otherwise zero - */ - public static long getUnsignedLongFromFile(String filename) { - if (LOG.isDebugEnabled()) { - LOG.debug("Reading file {}", filename); - } - List read = FileUtil.readFile(filename, false); - if (!read.isEmpty()) { - if (LOG.isTraceEnabled()) { - LOG.trace("Read {}", read.get(0)); - } - return ParseUtil.parseUnsignedLongOrDefault(read.get(0), 0L); - } - return 0L; - } + /** + * Read a file and return the unsigned long value contained therein as a + * long. Intended primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static long getUnsignedLongFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return ParseUtil.parseUnsignedLongOrDefault(read.get(0), 0L); + } + return 0L; + } - /** - * Read a file and return the int value contained therein. Intended primarily - * for Linux /sys filesystem - * - * @param filename The file to read - * @return The value contained in the file, if any; otherwise zero - */ - public static int getIntFromFile(String filename) { - if (LOG.isDebugEnabled()) { - LOG.debug("Reading file {}", filename); - } - try { - List read = FileUtil.readFile(filename, false); - if (!read.isEmpty()) { - if (LOG.isTraceEnabled()) { - LOG.trace("Read {}", read.get(0)); - } - return Integer.parseInt(read.get(0)); - } - } catch (NumberFormatException ex) { - LOG.warn("Unable to read value from {}. {}", filename, ex); - } - return 0; - } + /** + * Read a file and return the int value contained therein. Intended + * primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise zero + */ + public static int getIntFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + try { + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return Integer.parseInt(read.get(0)); + } + } catch (NumberFormatException ex) { + LOG.warn("Unable to read value from {}. {}", filename, ex); + } + return 0; + } - /** - * Read a file and return the String value contained therein. Intended primarily - * for Linux /sys filesystem - * - * @param filename The file to read - * @return The value contained in the file, if any; otherwise empty string - */ - public static String getStringFromFile(String filename) { - if (LOG.isDebugEnabled()) { - LOG.debug("Reading file {}", filename); - } - List read = FileUtil.readFile(filename, false); - if (!read.isEmpty()) { - if (LOG.isTraceEnabled()) { - LOG.trace("Read {}", read.get(0)); - } - return read.get(0); - } - return ""; - } + /** + * Read a file and return the String value contained therein. Intended + * primarily for Linux /sys filesystem + * + * @param filename + * The file to read + * @return The value contained in the file, if any; otherwise empty string + */ + public static String getStringFromFile(String filename) { + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List read = FileUtil.readFile(filename, false); + if (!read.isEmpty()) { + if (LOG.isTraceEnabled()) { + LOG.trace("Read {}", read.get(0)); + } + return read.get(0); + } + return ""; + } - /** - * Read a file and return a map of string keys to string values contained - * therein. Intended primarily for Linux /proc/[pid]/io - * - * @param filename The file to read - * @param separator Characters in each line of the file that separate the key - * and the value - * @return The map contained in the file, if any; otherwise empty map - */ - public static Map getKeyValueMapFromFile(String filename, String separator) { - Map map = new HashMap<>(); - if (LOG.isDebugEnabled()) { - LOG.debug("Reading file {}", filename); - } - List lines = FileUtil.readFile(filename, false); - for (String line : lines) { - String[] parts = line.split(separator); - if (parts.length == 2) { - map.put(parts[0], parts[1].trim()); - } - } - return map; - } + /** + * Read a file and return a map of string keys to string values contained + * therein. Intended primarily for Linux /proc/[pid]/io + * + * @param filename + * The file to read + * @param separator + * Characters in each line of the file that separate the key and + * the value + * @return The map contained in the file, if any; otherwise empty map + */ + public static Map getKeyValueMapFromFile(String filename, String separator) { + Map map = new HashMap<>(); + if (LOG.isDebugEnabled()) { + LOG.debug("Reading file {}", filename); + } + List lines = FileUtil.readFile(filename, false); + for (String line : lines) { + String[] parts = line.split(separator); + if (parts.length == 2) { + map.put(parts[0], parts[1].trim()); + } + } + return map; + } } From 41d05fe44c7ef16cff703e6eda5f13b590522195 Mon Sep 17 00:00:00 2001 From: Tyler Cook Date: Fri, 9 Aug 2019 21:27:50 -0500 Subject: [PATCH 4/4] Add optional AttributeKeys --- .../src/gen/java/oshi/api/FreeBsdSystem.java | 8 +- .../src/gen/java/oshi/api/LinuxSystem.java | 8 +- .../src/gen/java/oshi/api/MacSystem.java | 8 +- .../src/gen/java/oshi/api/MultiSystem.java | 6 +- .../src/gen/java/oshi/api/SolarisSystem.java | 8 +- .../src/gen/java/oshi/api/WindowsSystem.java | 8 +- .../gen/java/oshi/api/hardware/disk/Disk.java | 119 +-- .../oshi/api/hardware/disk/DiskAttribute.java | 103 ++ ...kAttribute.java => DiskAttributeEnum.java} | 65 +- .../hardware/disk/internal/DiskContainer.java | 916 ++++++++++-------- .../disk/internal/DiskContainerFreeBsd.java | 20 +- .../disk/internal/DiskContainerLinux.java | 20 +- .../disk/internal/DiskContainerMac.java | 20 +- .../disk/internal/DiskContainerSolaris.java | 20 +- .../disk/internal/DiskContainerWindows.java | 20 +- .../api/hardware/disk/internal/DiskQuery.java | 2 +- .../oshi/api/hardware/firmware/Firmware.java | 15 +- .../hardware/firmware/FirmwareAttribute.java | 64 ++ .../api/hardware/firmware/FirmwareLinux.java | 2 +- ...ribute.java => FirmwareAttributeEnum.java} | 17 +- .../firmware/internal/FirmwareContainer.java | 134 +-- .../internal/FirmwareContainerFreeBsd.java | 20 +- .../internal/FirmwareContainerLinux.java | 39 +- .../internal/FirmwareContainerMac.java | 20 +- .../internal/FirmwareContainerSolaris.java | 20 +- .../internal/FirmwareContainerWindows.java | 20 +- .../firmware/internal/FirmwareQuery.java | 2 +- .../gen/java/oshi/api/hardware/nic/Nic.java | 95 +- .../oshi/api/hardware/nic/NicAttribute.java | 148 +++ .../oshi/api/hardware/nic/NicWindows.java | 16 +- ...icAttribute.java => NicAttributeEnum.java} | 59 +- .../hardware/nic/internal/NicContainer.java | 900 +++++++++-------- .../nic/internal/NicContainerFreeBsd.java | 20 +- .../nic/internal/NicContainerLinux.java | 20 +- .../nic/internal/NicContainerMac.java | 20 +- .../nic/internal/NicContainerSolaris.java | 20 +- .../nic/internal/NicContainerWindows.java | 147 +-- .../api/hardware/nic/internal/NicQuery.java | 2 +- .../src/main/java/oshi/ApiGenerator.java | 72 +- .../src/main/java/oshi/api/AttributeKey.java | 47 + .../src/main/java/oshi/api/Container.java | 84 ++ .../src/main/java/oshi/api/OSHI.java | 52 +- .../oshi/api/internal/AbstractContainer.java | 51 + .../{Timeout.java => AttributeEnum.java} | 22 +- .../java/oshi/driver/ComponentDriver.java | 193 ++-- .../java/oshi/driver/ContainerFactory.java | 78 ++ .../java/oshi/driver/ExtensionDriver.java | 8 +- .../main/java/oshi/driver/SystemDriver.java | 70 -- .../driver/{ => annotation}/Fallback.java | 19 +- .../driver/{ => annotation}/RequiresRoot.java | 6 +- .../java/oshi/driver/annotation/Timeout.java | 57 ++ .../driver/hardware/disk/DiskDriverLinux.java | 15 +- .../hardware/disk/DiskDriverLinuxSMART.java | 116 ++- .../firmware/FirmwareDriverLinux.java | 14 +- .../driver/hardware/nic/NicDriverJava.java | 15 +- .../driver/hardware/nic/NicDriverLinux.java | 24 +- .../{ => system}/SystemDriverFreeBsd.java | 2 +- .../{ => system}/SystemDriverLinux.java | 48 +- .../driver/{ => system}/SystemDriverMac.java | 2 +- .../{ => system}/SystemDriverSolaris.java | 2 +- .../{ => system}/SystemDriverWindows.java | 2 +- .../main/java/oshi/example/DiskExample.java | 65 +- .../java/oshi/example/FirmwareExample.java | 24 +- .../main/java/oshi/example/NicExample.java | 26 +- .../src/main/java/oshi/old/GlobalConfig.java | 181 ++++ .../src/main/resources/default.properties | 35 + 66 files changed, 2905 insertions(+), 1576 deletions(-) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java rename reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/{DiskAttribute.java => DiskAttributeEnum.java} (68%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java rename reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/{FirmwareAttribute.java => FirmwareAttributeEnum.java} (88%) create mode 100644 reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java rename reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/{NicAttribute.java => NicAttributeEnum.java} (74%) create mode 100644 reference/oshi-core/src/main/java/oshi/api/AttributeKey.java create mode 100644 reference/oshi-core/src/main/java/oshi/api/Container.java create mode 100644 reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java rename reference/oshi-core/src/main/java/oshi/driver/{Timeout.java => AttributeEnum.java} (72%) create mode 100644 reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java delete mode 100644 reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java rename reference/oshi-core/src/main/java/oshi/driver/{ => annotation}/Fallback.java (76%) rename reference/oshi-core/src/main/java/oshi/driver/{ => annotation}/RequiresRoot.java (91%) create mode 100644 reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java rename reference/oshi-core/src/main/java/oshi/driver/{ => system}/SystemDriverFreeBsd.java (98%) rename reference/oshi-core/src/main/java/oshi/driver/{ => system}/SystemDriverLinux.java (72%) rename reference/oshi-core/src/main/java/oshi/driver/{ => system}/SystemDriverMac.java (98%) rename reference/oshi-core/src/main/java/oshi/driver/{ => system}/SystemDriverSolaris.java (98%) rename reference/oshi-core/src/main/java/oshi/driver/{ => system}/SystemDriverWindows.java (98%) create mode 100644 reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java create mode 100644 reference/oshi-core/src/main/resources/default.properties diff --git a/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java b/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java index f93346e..7877890 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java +++ b/reference/oshi-core/src/gen/java/oshi/api/FreeBsdSystem.java @@ -31,10 +31,10 @@ import oshi.api.hardware.nic.NicFreeBsd; @Generated("oshi.ApiGenerator") -public interface FreeBsdSystem { - Stream getNicStream(); +public interface FreeBsdSystem extends MultiSystem { + Stream getNicStream(); - Stream getDiskStream(); + Stream getDiskStream(); - FirmwareFreeBsd getFirmware(); + FirmwareFreeBsd getFirmware(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java b/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java index e761430..85ac695 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java +++ b/reference/oshi-core/src/gen/java/oshi/api/LinuxSystem.java @@ -31,10 +31,10 @@ import oshi.api.hardware.nic.NicLinux; @Generated("oshi.ApiGenerator") -public interface LinuxSystem { - Stream getNicStream(); +public interface LinuxSystem extends MultiSystem { + Stream getNicStream(); - Stream getDiskStream(); + Stream getDiskStream(); - FirmwareLinux getFirmware(); + FirmwareLinux getFirmware(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java b/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java index 762d010..0388301 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java +++ b/reference/oshi-core/src/gen/java/oshi/api/MacSystem.java @@ -31,10 +31,10 @@ import oshi.api.hardware.nic.NicMac; @Generated("oshi.ApiGenerator") -public interface MacSystem { - Stream getNicStream(); +public interface MacSystem extends MultiSystem { + Stream getNicStream(); - Stream getDiskStream(); + Stream getDiskStream(); - FirmwareMac getFirmware(); + FirmwareMac getFirmware(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java b/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java index 0b980db..1abef24 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java +++ b/reference/oshi-core/src/gen/java/oshi/api/MultiSystem.java @@ -32,9 +32,9 @@ @Generated("oshi.ApiGenerator") public interface MultiSystem { - Stream getNicStream(); + Stream getNicStream(); - Stream getDiskStream(); + Stream getDiskStream(); - Firmware getFirmware(); + Firmware getFirmware(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java b/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java index 6eb68ce..d98066c 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java +++ b/reference/oshi-core/src/gen/java/oshi/api/SolarisSystem.java @@ -31,10 +31,10 @@ import oshi.api.hardware.nic.NicSolaris; @Generated("oshi.ApiGenerator") -public interface SolarisSystem { - Stream getNicStream(); +public interface SolarisSystem extends MultiSystem { + Stream getNicStream(); - Stream getDiskStream(); + Stream getDiskStream(); - FirmwareSolaris getFirmware(); + FirmwareSolaris getFirmware(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java b/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java index 5191799..39e2425 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java +++ b/reference/oshi-core/src/gen/java/oshi/api/WindowsSystem.java @@ -31,10 +31,10 @@ import oshi.api.hardware.nic.NicWindows; @Generated("oshi.ApiGenerator") -public interface WindowsSystem { - Stream getNicStream(); +public interface WindowsSystem extends MultiSystem { + Stream getNicStream(); - Stream getDiskStream(); + Stream getDiskStream(); - FirmwareWindows getFirmware(); + FirmwareWindows getFirmware(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java index 50cbb54..23cc81d 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/Disk.java @@ -25,120 +25,123 @@ package oshi.api.hardware.disk; import javax.annotation.processing.Generated; +import oshi.api.Container; @Generated("oshi.ApiGenerator") -public interface Disk { - String getName(); +public interface Disk extends Container { + String getName(); - String getModel(); + String getPath(); - String getSerial(); + String getModel(); - Long getSize(); + String getSerial(); - Long querySize(); + Long getSize(); - Long getReads(); + Long querySize(); - Long queryReads(); + Long getReads(); - Long getReadBytes(); + Long queryReads(); - Long queryReadBytes(); + Long getReadBytes(); - Long getWrites(); + Long queryReadBytes(); - Long queryWrites(); + Long getWrites(); - Long getWriteBytes(); + Long queryWrites(); - Long queryWriteBytes(); + Long getWriteBytes(); - Long getQueueLength(); + Long queryWriteBytes(); - Long queryQueueLength(); + Long getQueueLength(); - Long getTransferTime(); + Long queryQueueLength(); - Long queryTransferTime(); + Long getTransferTime(); - String getModelFamily(); + Long queryTransferTime(); - String queryModelFamily(); + String getModelFamily(); - String getFirmwareVersion(); + String queryModelFamily(); - String queryFirmwareVersion(); + String getFirmwareVersion(); - Long getRotationRate(); + String queryFirmwareVersion(); - Long queryRotationRate(); + Long getRotationRate(); - Long getReadErrorRate(); + Long queryRotationRate(); - Long queryReadErrorRate(); + Long getReadErrorRate(); - Long getSpinUpTime(); + Long queryReadErrorRate(); - Long querySpinUpTime(); + Long getSpinUpTime(); - Long getStartStopCycles(); + Long querySpinUpTime(); - Long queryStartStopCycles(); + Long getStartStopCycles(); - Long getReallocatedSectors(); + Long queryStartStopCycles(); - Long queryReallocatedSectors(); + Long getReallocatedSectors(); - Long getSeekErrorRate(); + Long queryReallocatedSectors(); - Long querySeekErrorRate(); + Long getSeekErrorRate(); - Long getPowerOnTime(); + Long querySeekErrorRate(); - Long queryPowerOnTime(); + Long getPowerOnTime(); - Long getSpinRetries(); + Long queryPowerOnTime(); - Long querySpinRetries(); + Long getSpinRetries(); - Long getCalibrationRetries(); + Long querySpinRetries(); - Long queryCalibrationRetries(); + Long getCalibrationRetries(); - Long getPowerCycles(); + Long queryCalibrationRetries(); - Long queryPowerCycles(); + Long getPowerCycles(); - Long getPoweroffRetracts(); + Long queryPowerCycles(); - Long queryPoweroffRetracts(); + Long getPoweroffRetracts(); - Long getLoadCycles(); + Long queryPoweroffRetracts(); - Long queryLoadCycles(); + Long getLoadCycles(); - Long getTemperature(); + Long queryLoadCycles(); - Long queryTemperature(); + Long getTemperature(); - Long getReallocatedEvents(); + Long queryTemperature(); - Long queryReallocatedEvents(); + Long getReallocatedEvents(); - Long getCurrentPendingSector(); + Long queryReallocatedEvents(); - Long queryCurrentPendingSector(); + Long getCurrentPendingSector(); - Long getOfflineUncorrectable(); + Long queryCurrentPendingSector(); - Long queryOfflineUncorrectable(); + Long getOfflineUncorrectable(); - Long getCrcErrors(); + Long queryOfflineUncorrectable(); - Long queryCrcErrors(); + Long getCrcErrors(); - Long getMultizoneErrorRate(); + Long queryCrcErrors(); - Long queryMultizoneErrorRate(); + Long getMultizoneErrorRate(); + + Long queryMultizoneErrorRate(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java new file mode 100644 index 0000000..6e57bf6 --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/DiskAttribute.java @@ -0,0 +1,103 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.disk; + +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.disk.internal.DiskAttributeEnum; + +@Generated("oshi.ApiGenerator") +public class DiskAttribute { + public static final AttributeKey NAME = new AttributeKey<>(DiskAttributeEnum.NAME); + + public static final AttributeKey PATH = new AttributeKey<>(DiskAttributeEnum.PATH); + + public static final AttributeKey MODEL = new AttributeKey<>(DiskAttributeEnum.MODEL); + + public static final AttributeKey SERIAL = new AttributeKey<>(DiskAttributeEnum.SERIAL); + + /** + * The disk's total size in bytes + */ + public static final AttributeKey SIZE = new AttributeKey<>(DiskAttributeEnum.SIZE); + + public static final AttributeKey READS = new AttributeKey<>(DiskAttributeEnum.READS); + + public static final AttributeKey READ_BYTES = new AttributeKey<>(DiskAttributeEnum.READ_BYTES); + + public static final AttributeKey WRITES = new AttributeKey<>(DiskAttributeEnum.WRITES); + + public static final AttributeKey WRITE_BYTES = new AttributeKey<>(DiskAttributeEnum.WRITE_BYTES); + + public static final AttributeKey QUEUE_LENGTH = new AttributeKey<>(DiskAttributeEnum.QUEUE_LENGTH); + + public static final AttributeKey TRANSFER_TIME = new AttributeKey<>(DiskAttributeEnum.TRANSFER_TIME); + + public static final AttributeKey MODEL_FAMILY = new AttributeKey<>(DiskAttributeEnum.MODEL_FAMILY); + + public static final AttributeKey FIRMWARE_VERSION = new AttributeKey<>(DiskAttributeEnum.FIRMWARE_VERSION); + + public static final AttributeKey ROTATION_RATE = new AttributeKey<>(DiskAttributeEnum.ROTATION_RATE); + + public static final AttributeKey READ_ERROR_RATE = new AttributeKey<>(DiskAttributeEnum.READ_ERROR_RATE); + + public static final AttributeKey SPIN_UP_TIME = new AttributeKey<>(DiskAttributeEnum.SPIN_UP_TIME); + + public static final AttributeKey START_STOP_CYCLES = new AttributeKey<>(DiskAttributeEnum.START_STOP_CYCLES); + + public static final AttributeKey REALLOCATED_SECTORS = new AttributeKey<>( + DiskAttributeEnum.REALLOCATED_SECTORS); + + public static final AttributeKey SEEK_ERROR_RATE = new AttributeKey<>(DiskAttributeEnum.SEEK_ERROR_RATE); + + public static final AttributeKey POWER_ON_TIME = new AttributeKey<>(DiskAttributeEnum.POWER_ON_TIME); + + public static final AttributeKey SPIN_RETRIES = new AttributeKey<>(DiskAttributeEnum.SPIN_RETRIES); + + public static final AttributeKey CALIBRATION_RETRIES = new AttributeKey<>( + DiskAttributeEnum.CALIBRATION_RETRIES); + + public static final AttributeKey POWER_CYCLES = new AttributeKey<>(DiskAttributeEnum.POWER_CYCLES); + + public static final AttributeKey POWEROFF_RETRACTS = new AttributeKey<>(DiskAttributeEnum.POWEROFF_RETRACTS); + + public static final AttributeKey LOAD_CYCLES = new AttributeKey<>(DiskAttributeEnum.LOAD_CYCLES); + + public static final AttributeKey TEMPERATURE = new AttributeKey<>(DiskAttributeEnum.TEMPERATURE); + + public static final AttributeKey REALLOCATED_EVENTS = new AttributeKey<>( + DiskAttributeEnum.REALLOCATED_EVENTS); + + public static final AttributeKey CURRENT_PENDING_SECTOR = new AttributeKey<>( + DiskAttributeEnum.CURRENT_PENDING_SECTOR); + + public static final AttributeKey OFFLINE_UNCORRECTABLE = new AttributeKey<>( + DiskAttributeEnum.OFFLINE_UNCORRECTABLE); + + public static final AttributeKey CRC_ERRORS = new AttributeKey<>(DiskAttributeEnum.CRC_ERRORS); + + public static final AttributeKey MULTIZONE_ERROR_RATE = new AttributeKey<>( + DiskAttributeEnum.MULTIZONE_ERROR_RATE); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttributeEnum.java similarity index 68% rename from reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttributeEnum.java index f6f2d70..c9698ca 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttribute.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskAttributeEnum.java @@ -25,66 +25,69 @@ package oshi.api.hardware.disk.internal; import javax.annotation.processing.Generated; +import oshi.driver.AttributeEnum; @Generated("oshi.ApiGenerator") -public enum DiskAttribute { - NAME, +public enum DiskAttributeEnum implements AttributeEnum { + NAME, - MODEL, + PATH, - SERIAL, + MODEL, - SIZE, + SERIAL, - READS, + SIZE, - READ_BYTES, + READS, - WRITES, + READ_BYTES, - WRITE_BYTES, + WRITES, - QUEUE_LENGTH, + WRITE_BYTES, - TRANSFER_TIME, + QUEUE_LENGTH, - MODEL_FAMILY, + TRANSFER_TIME, - FIRMWARE_VERSION, + MODEL_FAMILY, - ROTATION_RATE, + FIRMWARE_VERSION, - READ_ERROR_RATE, + ROTATION_RATE, - SPIN_UP_TIME, + READ_ERROR_RATE, - START_STOP_CYCLES, + SPIN_UP_TIME, - REALLOCATED_SECTORS, + START_STOP_CYCLES, - SEEK_ERROR_RATE, + REALLOCATED_SECTORS, - POWER_ON_TIME, + SEEK_ERROR_RATE, - SPIN_RETRIES, + POWER_ON_TIME, - CALIBRATION_RETRIES, + SPIN_RETRIES, - POWER_CYCLES, + CALIBRATION_RETRIES, - POWEROFF_RETRACTS, + POWER_CYCLES, - LOAD_CYCLES, + POWEROFF_RETRACTS, - TEMPERATURE, + LOAD_CYCLES, - REALLOCATED_EVENTS, + TEMPERATURE, - CURRENT_PENDING_SECTOR, + REALLOCATED_EVENTS, - OFFLINE_UNCORRECTABLE, + CURRENT_PENDING_SECTOR, - CRC_ERRORS, + OFFLINE_UNCORRECTABLE, - MULTIZONE_ERROR_RATE + CRC_ERRORS, + + MULTIZONE_ERROR_RATE } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java index 64fec58..2d842e6 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainer.java @@ -26,478 +26,556 @@ import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.DetachedContainerException; import oshi.api.hardware.disk.Disk; +import oshi.api.internal.AbstractContainer; import oshi.driver.ComponentDriver; /** * A storage device */ @Generated("oshi.ApiGenerator") -public abstract class DiskContainer implements Disk { - private transient ComponentDriver driver; +public abstract class DiskContainer extends AbstractContainer implements Disk { + public String name; - public String name; + public String path; - public String model; + public String model; - public String serial; + public String serial; - /** - * The disk's total size in bytes - */ - public Long size; + /** + * The disk's total size in bytes + */ + public Long size; - public Long reads; + public Long reads; - public Long readBytes; + public Long readBytes; - public Long writes; + public Long writes; - public Long writeBytes; + public Long writeBytes; - public Long queueLength; + public Long queueLength; - public Long transferTime; + public Long transferTime; - public String modelFamily; + public String modelFamily; - public String firmwareVersion; + public String firmwareVersion; - public Long rotationRate; + public Long rotationRate; - public Long readErrorRate; + public Long readErrorRate; - public Long spinUpTime; + public Long spinUpTime; - public Long startStopCycles; + public Long startStopCycles; - public Long reallocatedSectors; + public Long reallocatedSectors; - public Long seekErrorRate; + public Long seekErrorRate; - public Long powerOnTime; + public Long powerOnTime; - public Long spinRetries; + public Long spinRetries; - public Long calibrationRetries; + public Long calibrationRetries; - public Long powerCycles; + public Long powerCycles; - public Long poweroffRetracts; + public Long poweroffRetracts; - public Long loadCycles; + public Long loadCycles; - public Long temperature; + public Long temperature; - public Long reallocatedEvents; + public Long reallocatedEvents; - public Long currentPendingSector; + public Long currentPendingSector; - public Long offlineUncorrectable; + public Long offlineUncorrectable; - public Long crcErrors; + public Long crcErrors; - public Long multizoneErrorRate; + public Long multizoneErrorRate; - @Override - public String getName() { - return name; - } + @Override + public String getName() { + return name; + } + + @Override + public String getPath() { + return path; + } + + @Override + public String getModel() { + return model; + } + + @Override + public String getSerial() { + return serial; + } + + @Override + public Long getSize() { + return size; + } + + @Override + public Long querySize() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SIZE); + return size; + } + + @Override + public Long getReads() { + return reads; + } + + @Override + public Long queryReads() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.READS); + return reads; + } + + @Override + public Long getReadBytes() { + return readBytes; + } + + @Override + public Long queryReadBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.READ_BYTES); + return readBytes; + } + + @Override + public Long getWrites() { + return writes; + } + + @Override + public Long queryWrites() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.WRITES); + return writes; + } + + @Override + public Long getWriteBytes() { + return writeBytes; + } + + @Override + public Long queryWriteBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.WRITE_BYTES); + return writeBytes; + } + + @Override + public Long getQueueLength() { + return queueLength; + } + + @Override + public Long queryQueueLength() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.QUEUE_LENGTH); + return queueLength; + } + + @Override + public Long getTransferTime() { + return transferTime; + } + + @Override + public Long queryTransferTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.TRANSFER_TIME); + return transferTime; + } + + @Override + public String getModelFamily() { + return modelFamily; + } + + @Override + public String queryModelFamily() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.MODEL_FAMILY); + return modelFamily; + } - @Override - public String getModel() { - return model; - } + @Override + public String getFirmwareVersion() { + return firmwareVersion; + } - @Override - public String getSerial() { - return serial; - } + @Override + public String queryFirmwareVersion() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.FIRMWARE_VERSION); + return firmwareVersion; + } - @Override - public Long getSize() { - return size; - } + @Override + public Long getRotationRate() { + return rotationRate; + } - @Override - public Long querySize() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public Long queryRotationRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.ROTATION_RATE); + return rotationRate; } - driver.query(DiskAttribute.SIZE); - return size; - } - @Override - public Long getReads() { - return reads; - } + @Override + public Long getReadErrorRate() { + return readErrorRate; + } - @Override - public Long queryReads() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public Long queryReadErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.READ_ERROR_RATE); + return readErrorRate; } - driver.query(DiskAttribute.READS); - return reads; - } - @Override - public Long getReadBytes() { - return readBytes; - } + @Override + public Long getSpinUpTime() { + return spinUpTime; + } - @Override - public Long queryReadBytes() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public Long querySpinUpTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SPIN_UP_TIME); + return spinUpTime; } - driver.query(DiskAttribute.READ_BYTES); - return readBytes; - } - @Override - public Long getWrites() { - return writes; - } + @Override + public Long getStartStopCycles() { + return startStopCycles; + } - @Override - public Long queryWrites() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public Long queryStartStopCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.START_STOP_CYCLES); + return startStopCycles; } - driver.query(DiskAttribute.WRITES); - return writes; - } - @Override - public Long getWriteBytes() { - return writeBytes; - } + @Override + public Long getReallocatedSectors() { + return reallocatedSectors; + } + + @Override + public Long queryReallocatedSectors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.REALLOCATED_SECTORS); + return reallocatedSectors; + } + + @Override + public Long getSeekErrorRate() { + return seekErrorRate; + } + + @Override + public Long querySeekErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SEEK_ERROR_RATE); + return seekErrorRate; + } - @Override - public Long queryWriteBytes() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.WRITE_BYTES); - return writeBytes; - } - - @Override - public Long getQueueLength() { - return queueLength; - } - - @Override - public Long queryQueueLength() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.QUEUE_LENGTH); - return queueLength; - } - - @Override - public Long getTransferTime() { - return transferTime; - } - - @Override - public Long queryTransferTime() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.TRANSFER_TIME); - return transferTime; - } - - @Override - public String getModelFamily() { - return modelFamily; - } - - @Override - public String queryModelFamily() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.MODEL_FAMILY); - return modelFamily; - } - - @Override - public String getFirmwareVersion() { - return firmwareVersion; - } - - @Override - public String queryFirmwareVersion() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.FIRMWARE_VERSION); - return firmwareVersion; - } - - @Override - public Long getRotationRate() { - return rotationRate; - } - - @Override - public Long queryRotationRate() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.ROTATION_RATE); - return rotationRate; - } - - @Override - public Long getReadErrorRate() { - return readErrorRate; - } - - @Override - public Long queryReadErrorRate() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.READ_ERROR_RATE); - return readErrorRate; - } - - @Override - public Long getSpinUpTime() { - return spinUpTime; - } - - @Override - public Long querySpinUpTime() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.SPIN_UP_TIME); - return spinUpTime; - } - - @Override - public Long getStartStopCycles() { - return startStopCycles; - } - - @Override - public Long queryStartStopCycles() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.START_STOP_CYCLES); - return startStopCycles; - } - - @Override - public Long getReallocatedSectors() { - return reallocatedSectors; - } - - @Override - public Long queryReallocatedSectors() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.REALLOCATED_SECTORS); - return reallocatedSectors; - } - - @Override - public Long getSeekErrorRate() { - return seekErrorRate; - } - - @Override - public Long querySeekErrorRate() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.SEEK_ERROR_RATE); - return seekErrorRate; - } - - @Override - public Long getPowerOnTime() { - return powerOnTime; - } - - @Override - public Long queryPowerOnTime() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.POWER_ON_TIME); - return powerOnTime; - } - - @Override - public Long getSpinRetries() { - return spinRetries; - } - - @Override - public Long querySpinRetries() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.SPIN_RETRIES); - return spinRetries; - } - - @Override - public Long getCalibrationRetries() { - return calibrationRetries; - } - - @Override - public Long queryCalibrationRetries() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.CALIBRATION_RETRIES); - return calibrationRetries; - } - - @Override - public Long getPowerCycles() { - return powerCycles; - } - - @Override - public Long queryPowerCycles() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.POWER_CYCLES); - return powerCycles; - } - - @Override - public Long getPoweroffRetracts() { - return poweroffRetracts; - } - - @Override - public Long queryPoweroffRetracts() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.POWEROFF_RETRACTS); - return poweroffRetracts; - } - - @Override - public Long getLoadCycles() { - return loadCycles; - } - - @Override - public Long queryLoadCycles() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.LOAD_CYCLES); - return loadCycles; - } - - @Override - public Long getTemperature() { - return temperature; - } - - @Override - public Long queryTemperature() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.TEMPERATURE); - return temperature; - } - - @Override - public Long getReallocatedEvents() { - return reallocatedEvents; - } - - @Override - public Long queryReallocatedEvents() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.REALLOCATED_EVENTS); - return reallocatedEvents; - } - - @Override - public Long getCurrentPendingSector() { - return currentPendingSector; - } - - @Override - public Long queryCurrentPendingSector() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.CURRENT_PENDING_SECTOR); - return currentPendingSector; - } - - @Override - public Long getOfflineUncorrectable() { - return offlineUncorrectable; - } - - @Override - public Long queryOfflineUncorrectable() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.OFFLINE_UNCORRECTABLE); - return offlineUncorrectable; - } - - @Override - public Long getCrcErrors() { - return crcErrors; - } - - @Override - public Long queryCrcErrors() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.CRC_ERRORS); - return crcErrors; - } - - @Override - public Long getMultizoneErrorRate() { - return multizoneErrorRate; - } - - @Override - public Long queryMultizoneErrorRate() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(DiskAttribute.MULTIZONE_ERROR_RATE); - return multizoneErrorRate; - } - - public void attach(ComponentDriver driver) { - this.driver = driver; - // Query all constant attributes: - driver.query(DiskAttribute.NAME); - driver.query(DiskAttribute.MODEL); - driver.query(DiskAttribute.SERIAL); - } + @Override + public Long getPowerOnTime() { + return powerOnTime; + } + + @Override + public Long queryPowerOnTime() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.POWER_ON_TIME); + return powerOnTime; + } + + @Override + public Long getSpinRetries() { + return spinRetries; + } + + @Override + public Long querySpinRetries() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.SPIN_RETRIES); + return spinRetries; + } + + @Override + public Long getCalibrationRetries() { + return calibrationRetries; + } + + @Override + public Long queryCalibrationRetries() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.CALIBRATION_RETRIES); + return calibrationRetries; + } + + @Override + public Long getPowerCycles() { + return powerCycles; + } + + @Override + public Long queryPowerCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.POWER_CYCLES); + return powerCycles; + } + + @Override + public Long getPoweroffRetracts() { + return poweroffRetracts; + } + + @Override + public Long queryPoweroffRetracts() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.POWEROFF_RETRACTS); + return poweroffRetracts; + } + + @Override + public Long getLoadCycles() { + return loadCycles; + } + + @Override + public Long queryLoadCycles() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.LOAD_CYCLES); + return loadCycles; + } + + @Override + public Long getTemperature() { + return temperature; + } + + @Override + public Long queryTemperature() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.TEMPERATURE); + return temperature; + } + + @Override + public Long getReallocatedEvents() { + return reallocatedEvents; + } + + @Override + public Long queryReallocatedEvents() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.REALLOCATED_EVENTS); + return reallocatedEvents; + } + + @Override + public Long getCurrentPendingSector() { + return currentPendingSector; + } + + @Override + public Long queryCurrentPendingSector() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.CURRENT_PENDING_SECTOR); + return currentPendingSector; + } + + @Override + public Long getOfflineUncorrectable() { + return offlineUncorrectable; + } + + @Override + public Long queryOfflineUncorrectable() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.OFFLINE_UNCORRECTABLE); + return offlineUncorrectable; + } + + @Override + public Long getCrcErrors() { + return crcErrors; + } + + @Override + public Long queryCrcErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.CRC_ERRORS); + return crcErrors; + } + + @Override + public Long getMultizoneErrorRate() { + return multizoneErrorRate; + } + + @Override + public Long queryMultizoneErrorRate() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(DiskAttributeEnum.MULTIZONE_ERROR_RATE); + return multizoneErrorRate; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(DiskAttributeEnum.NAME); + driver.query(DiskAttributeEnum.PATH); + driver.query(DiskAttributeEnum.MODEL); + driver.query(DiskAttributeEnum.SERIAL); + } + + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return null; + case NAME: + return (T) name; + case PATH: + return (T) path; + case MODEL: + return (T) model; + case SERIAL: + return (T) serial; + case SIZE: + return (T) size; + case READS: + return (T) reads; + case READ_BYTES: + return (T) readBytes; + case WRITES: + return (T) writes; + case WRITE_BYTES: + return (T) writeBytes; + case QUEUE_LENGTH: + return (T) queueLength; + case TRANSFER_TIME: + return (T) transferTime; + case MODEL_FAMILY: + return (T) modelFamily; + case FIRMWARE_VERSION: + return (T) firmwareVersion; + case ROTATION_RATE: + return (T) rotationRate; + case READ_ERROR_RATE: + return (T) readErrorRate; + case SPIN_UP_TIME: + return (T) spinUpTime; + case START_STOP_CYCLES: + return (T) startStopCycles; + case REALLOCATED_SECTORS: + return (T) reallocatedSectors; + case SEEK_ERROR_RATE: + return (T) seekErrorRate; + case POWER_ON_TIME: + return (T) powerOnTime; + case SPIN_RETRIES: + return (T) spinRetries; + case CALIBRATION_RETRIES: + return (T) calibrationRetries; + case POWER_CYCLES: + return (T) powerCycles; + case POWEROFF_RETRACTS: + return (T) poweroffRetracts; + case LOAD_CYCLES: + return (T) loadCycles; + case TEMPERATURE: + return (T) temperature; + case REALLOCATED_EVENTS: + return (T) reallocatedEvents; + case CURRENT_PENDING_SECTOR: + return (T) currentPendingSector; + case OFFLINE_UNCORRECTABLE: + return (T) offlineUncorrectable; + case CRC_ERRORS: + return (T) crcErrors; + case MULTIZONE_ERROR_RATE: + return (T) multizoneErrorRate; + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java index dbdf5c3..a9aa7cc 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerFreeBsd.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.disk.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.disk.DiskFreeBsd; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class DiskContainerFreeBsd extends DiskContainer implements DiskFreeBsd { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java index 20ff18a..f6867d3 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerLinux.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.disk.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.disk.DiskLinux; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class DiskContainerLinux extends DiskContainer implements DiskLinux { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java index 4c4ca66..dce1f0d 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerMac.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.disk.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.disk.DiskMac; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class DiskContainerMac extends DiskContainer implements DiskMac { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java index 2d7d9da..a158fe8 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerSolaris.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.disk.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.disk.DiskSolaris; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class DiskContainerSolaris extends DiskContainer implements DiskSolaris { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java index 21ea1e1..0307f89 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskContainerWindows.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.disk.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.disk.DiskWindows; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class DiskContainerWindows extends DiskContainer implements DiskWindows { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((DiskAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java index b12a316..c0ed5db 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/disk/internal/DiskQuery.java @@ -34,5 +34,5 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface DiskQuery { - DiskAttribute[] value(); + DiskAttributeEnum[] value(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java index e9f02ac..821d9a2 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/Firmware.java @@ -25,18 +25,19 @@ package oshi.api.hardware.firmware; import javax.annotation.processing.Generated; +import oshi.api.Container; @Generated("oshi.ApiGenerator") -public interface Firmware { - String getName(); +public interface Firmware extends Container { + String getName(); - String getManufacturer(); + String getManufacturer(); - String getDescription(); + String getDescription(); - String getVersion(); + String getVersion(); - String getRevision(); + String getRevision(); - String getReleaseDate(); + String getReleaseDate(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java new file mode 100644 index 0000000..80b3e5e --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareAttribute.java @@ -0,0 +1,64 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.firmware; + +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.firmware.internal.FirmwareAttributeEnum; + +@Generated("oshi.ApiGenerator") +public class FirmwareAttribute { + public static final AttributeKey NAME = new AttributeKey<>(FirmwareAttributeEnum.NAME); + + /** + * The BIOS manufacturer title + */ + public static final AttributeKey MANUFACTURER = new AttributeKey<>(FirmwareAttributeEnum.MANUFACTURER); + + /** + * The BIOS description + */ + public static final AttributeKey DESCRIPTION = new AttributeKey<>(FirmwareAttributeEnum.DESCRIPTION); + + /** + * The BIOS version number + */ + public static final AttributeKey VERSION = new AttributeKey<>(FirmwareAttributeEnum.VERSION); + + /** + * The BIOS revision number + */ + public static final AttributeKey REVISION = new AttributeKey<>(FirmwareAttributeEnum.REVISION); + + /** + * The BIOS release date + */ + public static final AttributeKey RELEASE_DATE = new AttributeKey<>(FirmwareAttributeEnum.RELEASE_DATE); + + /** + * Whether the BIOS supports UEFI mode + */ + public static final AttributeKey UEFI = new AttributeKey<>(FirmwareAttributeEnum.UEFI); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java index 5ff8ede..b6ccf3b 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/FirmwareLinux.java @@ -28,5 +28,5 @@ @Generated("oshi.ApiGenerator") public interface FirmwareLinux extends Firmware { - Boolean getUefi(); + Boolean getUefi(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttributeEnum.java similarity index 88% rename from reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttributeEnum.java index 23644bd..aa3ba0a 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttribute.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareAttributeEnum.java @@ -25,20 +25,21 @@ package oshi.api.hardware.firmware.internal; import javax.annotation.processing.Generated; +import oshi.driver.AttributeEnum; @Generated("oshi.ApiGenerator") -public enum FirmwareAttribute { - NAME, +public enum FirmwareAttributeEnum implements AttributeEnum { + NAME, - MANUFACTURER, + MANUFACTURER, - DESCRIPTION, + DESCRIPTION, - VERSION, + VERSION, - REVISION, + REVISION, - RELEASE_DATE, + RELEASE_DATE, - UEFI + UEFI } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java index b377511..b66f167 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainer.java @@ -26,81 +26,101 @@ import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.firmware.Firmware; +import oshi.api.internal.AbstractContainer; import oshi.driver.ComponentDriver; /** * The system's firmware */ @Generated("oshi.ApiGenerator") -public abstract class FirmwareContainer implements Firmware { - private transient ComponentDriver driver; +public abstract class FirmwareContainer extends AbstractContainer implements Firmware { + public String name; - public String name; + /** + * The BIOS manufacturer title + */ + public String manufacturer; - /** - * The BIOS manufacturer title - */ - public String manufacturer; + /** + * The BIOS description + */ + public String description; - /** - * The BIOS description - */ - public String description; + /** + * The BIOS version number + */ + public String version; - /** - * The BIOS version number - */ - public String version; + /** + * The BIOS revision number + */ + public String revision; - /** - * The BIOS revision number - */ - public String revision; + /** + * The BIOS release date + */ + public String releaseDate; - /** - * The BIOS release date - */ - public String releaseDate; + @Override + public String getName() { + return name; + } - @Override - public String getName() { - return name; - } + @Override + public String getManufacturer() { + return manufacturer; + } - @Override - public String getManufacturer() { - return manufacturer; - } + @Override + public String getDescription() { + return description; + } - @Override - public String getDescription() { - return description; - } + @Override + public String getVersion() { + return version; + } - @Override - public String getVersion() { - return version; - } + @Override + public String getRevision() { + return revision; + } - @Override - public String getRevision() { - return revision; - } + @Override + public String getReleaseDate() { + return releaseDate; + } - @Override - public String getReleaseDate() { - return releaseDate; - } + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(FirmwareAttributeEnum.NAME); + driver.query(FirmwareAttributeEnum.MANUFACTURER); + driver.query(FirmwareAttributeEnum.DESCRIPTION); + driver.query(FirmwareAttributeEnum.VERSION); + driver.query(FirmwareAttributeEnum.REVISION); + driver.query(FirmwareAttributeEnum.RELEASE_DATE); + } - public void attach(ComponentDriver driver) { - this.driver = driver; - // Query all constant attributes: - driver.query(FirmwareAttribute.NAME); - driver.query(FirmwareAttribute.MANUFACTURER); - driver.query(FirmwareAttribute.DESCRIPTION); - driver.query(FirmwareAttribute.VERSION); - driver.query(FirmwareAttribute.REVISION); - driver.query(FirmwareAttribute.RELEASE_DATE); - } + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return null; + case NAME: + return (T) name; + case MANUFACTURER: + return (T) manufacturer; + case DESCRIPTION: + return (T) description; + case VERSION: + return (T) version; + case REVISION: + return (T) revision; + case RELEASE_DATE: + return (T) releaseDate; + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java index 386602e..109752c 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerFreeBsd.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.firmware.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.firmware.FirmwareFreeBsd; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class FirmwareContainerFreeBsd extends FirmwareContainer implements FirmwareFreeBsd { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java index 8e1a3b5..e02bfb1 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerLinux.java @@ -26,6 +26,7 @@ import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.firmware.FirmwareLinux; import oshi.driver.ComponentDriver; @@ -34,22 +35,30 @@ */ @Generated("oshi.ApiGenerator") public class FirmwareContainerLinux extends FirmwareContainer implements FirmwareLinux { - private transient ComponentDriver driver; + /** + * Whether the BIOS supports UEFI mode + */ + public Boolean uefi; - /** - * Whether the BIOS supports UEFI mode - */ - public Boolean uefi; + @Override + public Boolean getUefi() { + return uefi; + } - @Override - public Boolean getUefi() { - return uefi; - } + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + driver.query(FirmwareAttributeEnum.UEFI); + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - driver.query(FirmwareAttribute.UEFI); - } + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + case UEFI: + return (T) uefi; + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java index 8fe2144..4aedc9d 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerMac.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.firmware.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.firmware.FirmwareMac; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class FirmwareContainerMac extends FirmwareContainer implements FirmwareMac { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java index 721ea7a..0e43f5d 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerSolaris.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.firmware.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.firmware.FirmwareSolaris; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class FirmwareContainerSolaris extends FirmwareContainer implements FirmwareSolaris { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java index 71b6d5c..5f1847b 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareContainerWindows.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.firmware.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.firmware.FirmwareWindows; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class FirmwareContainerWindows extends FirmwareContainer implements FirmwareWindows { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((FirmwareAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java index 58ac9b2..1d218f5 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/firmware/internal/FirmwareQuery.java @@ -34,5 +34,5 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface FirmwareQuery { - FirmwareAttribute[] value(); + FirmwareAttributeEnum[] value(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java index 461c54d..33748ad 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/Nic.java @@ -25,98 +25,99 @@ package oshi.api.hardware.nic; import javax.annotation.processing.Generated; +import oshi.api.Container; @Generated("oshi.ApiGenerator") -public interface Nic { - String getName(); +public interface Nic extends Container { + String getName(); - String getDescription(); + String getDescription(); - Integer getMtu(); + Integer getMtu(); - Integer queryMtu(); + Integer queryMtu(); - String getMac(); + String getMac(); - String queryMac(); + String queryMac(); - Boolean getVirtual(); + Boolean getVirtual(); - Boolean queryVirtual(); + Boolean queryVirtual(); - String[] getIpv4(); + String[] getIpv4(); - String[] queryIpv4(); + String[] queryIpv4(); - String[] getIpv6(); + String[] getIpv6(); - String[] queryIpv6(); + String[] queryIpv6(); - String getBroadcast(); + String getBroadcast(); - String queryBroadcast(); + String queryBroadcast(); - String getNetmask(); + String getNetmask(); - String queryNetmask(); + String queryNetmask(); - Long getReadBytes(); + Long getReadBytes(); - Long queryReadBytes(); + Long queryReadBytes(); - Long getWriteBytes(); + Long getWriteBytes(); - Long queryWriteBytes(); + Long queryWriteBytes(); - Long getReadPackets(); + Long getReadPackets(); - Long queryReadPackets(); + Long queryReadPackets(); - Long getWritePackets(); + Long getWritePackets(); - Long queryWritePackets(); + Long queryWritePackets(); - Long getReadErrors(); + Long getReadErrors(); - Long queryReadErrors(); + Long queryReadErrors(); - Long getWriteErrors(); + Long getWriteErrors(); - Long queryWriteErrors(); + Long queryWriteErrors(); - Long getReadDrops(); + Long getReadDrops(); - Long queryReadDrops(); + Long queryReadDrops(); - Long getWriteDrops(); + Long getWriteDrops(); - Long queryWriteDrops(); + Long queryWriteDrops(); - Long getWriteCollisions(); + Long getWriteCollisions(); - Long queryWriteCollisions(); + Long queryWriteCollisions(); - Long getLinkSpeed(); + Long getLinkSpeed(); - Long queryLinkSpeed(); + Long queryLinkSpeed(); - Boolean getDefaultGateway(); + Boolean getDefaultGateway(); - Boolean queryDefaultGateway(); + Boolean queryDefaultGateway(); - Boolean getFlagUp(); + Boolean getFlagUp(); - Boolean queryFlagUp(); + Boolean queryFlagUp(); - Boolean getFlagRunning(); + Boolean getFlagRunning(); - Boolean queryFlagRunning(); + Boolean queryFlagRunning(); - Boolean getFlagLoopback(); + Boolean getFlagLoopback(); - Boolean queryFlagLoopback(); + Boolean queryFlagLoopback(); - Boolean getFlagMulticast(); + Boolean getFlagMulticast(); - Boolean queryFlagMulticast(); + Boolean queryFlagMulticast(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java new file mode 100644 index 0000000..4a871aa --- /dev/null +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicAttribute.java @@ -0,0 +1,148 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// This file was automatically generated by the OSHI API generator; do not edit! +package oshi.api.hardware.nic; + +import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; +import oshi.api.hardware.nic.internal.NicAttributeEnum; + +@Generated("oshi.ApiGenerator") +public class NicAttribute { + /** + * The interface's name + */ + public static final AttributeKey NAME = new AttributeKey<>(NicAttributeEnum.NAME); + + /** + * The interface's description + */ + public static final AttributeKey DESCRIPTION = new AttributeKey<>(NicAttributeEnum.DESCRIPTION); + + /** + * The maximum transmission unit + */ + public static final AttributeKey MTU = new AttributeKey<>(NicAttributeEnum.MTU); + + public static final AttributeKey MAC = new AttributeKey<>(NicAttributeEnum.MAC); + + public static final AttributeKey VIRTUAL = new AttributeKey<>(NicAttributeEnum.VIRTUAL); + + /** + * The interface's IPv4 addresses + */ + public static final AttributeKey IPV4 = new AttributeKey<>(NicAttributeEnum.IPV4); + + /** + * The interface's IPv6 addresses + */ + public static final AttributeKey IPV6 = new AttributeKey<>(NicAttributeEnum.IPV6); + + public static final AttributeKey BROADCAST = new AttributeKey<>(NicAttributeEnum.BROADCAST); + + /** + * The interface's subnet mask + */ + public static final AttributeKey NETMASK = new AttributeKey<>(NicAttributeEnum.NETMASK); + + /** + * The number of bytes read from the interface + */ + public static final AttributeKey READ_BYTES = new AttributeKey<>(NicAttributeEnum.READ_BYTES); + + /** + * The number of bytes written to the interface + */ + public static final AttributeKey WRITE_BYTES = new AttributeKey<>(NicAttributeEnum.WRITE_BYTES); + + /** + * The number of packets read from the interface + */ + public static final AttributeKey READ_PACKETS = new AttributeKey<>(NicAttributeEnum.READ_PACKETS); + + /** + * The number of packets written to the interface + */ + public static final AttributeKey WRITE_PACKETS = new AttributeKey<>(NicAttributeEnum.WRITE_PACKETS); + + /** + * The number of read errors + */ + public static final AttributeKey READ_ERRORS = new AttributeKey<>(NicAttributeEnum.READ_ERRORS); + + /** + * The number of write errors + */ + public static final AttributeKey WRITE_ERRORS = new AttributeKey<>(NicAttributeEnum.WRITE_ERRORS); + + /** + * The number of read drops + */ + public static final AttributeKey READ_DROPS = new AttributeKey<>(NicAttributeEnum.READ_DROPS); + + /** + * The number of write drops + */ + public static final AttributeKey WRITE_DROPS = new AttributeKey<>(NicAttributeEnum.WRITE_DROPS); + + /** + * The number of write collisions + */ + public static final AttributeKey WRITE_COLLISIONS = new AttributeKey<>(NicAttributeEnum.WRITE_COLLISIONS); + + /** + * The interface's maximum speed in bytes + */ + public static final AttributeKey LINK_SPEED = new AttributeKey<>(NicAttributeEnum.LINK_SPEED); + + public static final AttributeKey DEFAULT_GATEWAY = new AttributeKey<>(NicAttributeEnum.DEFAULT_GATEWAY); + + public static final AttributeKey FLAG_UP = new AttributeKey<>(NicAttributeEnum.FLAG_UP); + + public static final AttributeKey FLAG_RUNNING = new AttributeKey<>(NicAttributeEnum.FLAG_RUNNING); + + public static final AttributeKey FLAG_LOOPBACK = new AttributeKey<>(NicAttributeEnum.FLAG_LOOPBACK); + + public static final AttributeKey FLAG_MULTICAST = new AttributeKey<>(NicAttributeEnum.FLAG_MULTICAST); + + /** + * The interface's locally unique identifier + */ + public static final AttributeKey LUID = new AttributeKey<>(NicAttributeEnum.LUID); + + /** + * The interface's globally unique identifier + */ + public static final AttributeKey GUID = new AttributeKey<>(NicAttributeEnum.GUID); + + /** + * Whether the interface is in a paused state + */ + public static final AttributeKey PAUSED = new AttributeKey<>(NicAttributeEnum.PAUSED); + + /** + * Whether the interface is in a low-power state + */ + public static final AttributeKey LOWPOWER = new AttributeKey<>(NicAttributeEnum.LOWPOWER); +} diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java index 728da10..355cb5a 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/NicWindows.java @@ -28,19 +28,19 @@ @Generated("oshi.ApiGenerator") public interface NicWindows extends Nic { - Long getLuid(); + Long getLuid(); - Long queryLuid(); + Long queryLuid(); - String getGuid(); + String getGuid(); - String queryGuid(); + String queryGuid(); - Boolean getPaused(); + Boolean getPaused(); - Boolean queryPaused(); + Boolean queryPaused(); - Boolean getLowpower(); + Boolean getLowpower(); - Boolean queryLowpower(); + Boolean queryLowpower(); } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttributeEnum.java similarity index 74% rename from reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java rename to reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttributeEnum.java index 17debb3..7870c10 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttribute.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicAttributeEnum.java @@ -25,62 +25,63 @@ package oshi.api.hardware.nic.internal; import javax.annotation.processing.Generated; +import oshi.driver.AttributeEnum; @Generated("oshi.ApiGenerator") -public enum NicAttribute { - NAME, +public enum NicAttributeEnum implements AttributeEnum { + NAME, - DESCRIPTION, + DESCRIPTION, - MTU, + MTU, - MAC, + MAC, - VIRTUAL, + VIRTUAL, - IPV4, + IPV4, - IPV6, + IPV6, - BROADCAST, + BROADCAST, - NETMASK, + NETMASK, - READ_BYTES, + READ_BYTES, - WRITE_BYTES, + WRITE_BYTES, - READ_PACKETS, + READ_PACKETS, - WRITE_PACKETS, + WRITE_PACKETS, - READ_ERRORS, + READ_ERRORS, - WRITE_ERRORS, + WRITE_ERRORS, - READ_DROPS, + READ_DROPS, - WRITE_DROPS, + WRITE_DROPS, - WRITE_COLLISIONS, + WRITE_COLLISIONS, - LINK_SPEED, + LINK_SPEED, - DEFAULT_GATEWAY, + DEFAULT_GATEWAY, - FLAG_UP, + FLAG_UP, - FLAG_RUNNING, + FLAG_RUNNING, - FLAG_LOOPBACK, + FLAG_LOOPBACK, - FLAG_MULTICAST, + FLAG_MULTICAST, - LUID, + LUID, - GUID, + GUID, - PAUSED, + PAUSED, - LOWPOWER + LOWPOWER } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java index ca641c7..a193ab9 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainer.java @@ -26,435 +26,491 @@ import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.DetachedContainerException; import oshi.api.hardware.nic.Nic; +import oshi.api.internal.AbstractContainer; import oshi.driver.ComponentDriver; /** * A network interface */ @Generated("oshi.ApiGenerator") -public abstract class NicContainer implements Nic { - private transient ComponentDriver driver; +public abstract class NicContainer extends AbstractContainer implements Nic { + /** + * The interface's name + */ + public String name; + + /** + * The interface's description + */ + public String description; + + /** + * The maximum transmission unit + */ + public Integer mtu; + + public String mac; + + public Boolean virtual; + + /** + * The interface's IPv4 addresses + */ + public String[] ipv4; + + /** + * The interface's IPv6 addresses + */ + public String[] ipv6; + + public String broadcast; + + /** + * The interface's subnet mask + */ + public String netmask; + + /** + * The number of bytes read from the interface + */ + public Long readBytes; + + /** + * The number of bytes written to the interface + */ + public Long writeBytes; + + /** + * The number of packets read from the interface + */ + public Long readPackets; + + /** + * The number of packets written to the interface + */ + public Long writePackets; + + /** + * The number of read errors + */ + public Long readErrors; + + /** + * The number of write errors + */ + public Long writeErrors; + + /** + * The number of read drops + */ + public Long readDrops; + + /** + * The number of write drops + */ + public Long writeDrops; + + /** + * The number of write collisions + */ + public Long writeCollisions; + + /** + * The interface's maximum speed in bytes + */ + public Long linkSpeed; + + public Boolean defaultGateway; + + public Boolean flagUp; + + public Boolean flagRunning; + + public Boolean flagLoopback; + + public Boolean flagMulticast; + + @Override + public String getName() { + return name; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public Integer getMtu() { + return mtu; + } + + @Override + public Integer queryMtu() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.MTU); + return mtu; + } + + @Override + public String getMac() { + return mac; + } + + @Override + public String queryMac() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.MAC); + return mac; + } + + @Override + public Boolean getVirtual() { + return virtual; + } + + @Override + public Boolean queryVirtual() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.VIRTUAL); + return virtual; + } + + @Override + public String[] getIpv4() { + return ipv4; + } + + @Override + public String[] queryIpv4() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.IPV4); + return ipv4; + } + + @Override + public String[] getIpv6() { + return ipv6; + } + + @Override + public String[] queryIpv6() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.IPV6); + return ipv6; + } + + @Override + public String getBroadcast() { + return broadcast; + } + + @Override + public String queryBroadcast() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.BROADCAST); + return broadcast; + } + + @Override + public String getNetmask() { + return netmask; + } + + @Override + public String queryNetmask() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.NETMASK); + return netmask; + } + + @Override + public Long getReadBytes() { + return readBytes; + } + + @Override + public Long queryReadBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_BYTES); + return readBytes; + } + + @Override + public Long getWriteBytes() { + return writeBytes; + } + + @Override + public Long queryWriteBytes() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_BYTES); + return writeBytes; + } + + @Override + public Long getReadPackets() { + return readPackets; + } + + @Override + public Long queryReadPackets() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_PACKETS); + return readPackets; + } + + @Override + public Long getWritePackets() { + return writePackets; + } + + @Override + public Long queryWritePackets() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_PACKETS); + return writePackets; + } - /** - * The interface's name - */ - public String name; - - /** - * The interface's description - */ - public String description; - - /** - * The maximum transmission unit - */ - public Integer mtu; - - public String mac; - - public Boolean virtual; - - /** - * The interface's IPv4 addresses - */ - public String[] ipv4; - - /** - * The interface's IPv6 addresses - */ - public String[] ipv6; - - public String broadcast; - - /** - * The interface's subnet mask - */ - public String netmask; - - /** - * The number of bytes read from the interface - */ - public Long readBytes; - - /** - * The number of bytes written to the interface - */ - public Long writeBytes; - - /** - * The number of packets read from the interface - */ - public Long readPackets; - - /** - * The number of packets written to the interface - */ - public Long writePackets; - - /** - * The number of read errors - */ - public Long readErrors; - - /** - * The number of write errors - */ - public Long writeErrors; - - /** - * The number of read drops - */ - public Long readDrops; - - /** - * The number of write drops - */ - public Long writeDrops; - - /** - * The number of write collisions - */ - public Long writeCollisions; - - /** - * The interface's maximum speed in bytes - */ - public Long linkSpeed; - - public Boolean defaultGateway; - - public Boolean flagUp; - - public Boolean flagRunning; - - public Boolean flagLoopback; - - public Boolean flagMulticast; - - @Override - public String getName() { - return name; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public Integer getMtu() { - return mtu; - } - - @Override - public Integer queryMtu() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.MTU); - return mtu; - } - - @Override - public String getMac() { - return mac; - } - - @Override - public String queryMac() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.MAC); - return mac; - } - - @Override - public Boolean getVirtual() { - return virtual; - } - - @Override - public Boolean queryVirtual() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.VIRTUAL); - return virtual; - } - - @Override - public String[] getIpv4() { - return ipv4; - } - - @Override - public String[] queryIpv4() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.IPV4); - return ipv4; - } - - @Override - public String[] getIpv6() { - return ipv6; - } - - @Override - public String[] queryIpv6() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.IPV6); - return ipv6; - } - - @Override - public String getBroadcast() { - return broadcast; - } - - @Override - public String queryBroadcast() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.BROADCAST); - return broadcast; - } - - @Override - public String getNetmask() { - return netmask; - } - - @Override - public String queryNetmask() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.NETMASK); - return netmask; - } - - @Override - public Long getReadBytes() { - return readBytes; - } - - @Override - public Long queryReadBytes() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.READ_BYTES); - return readBytes; - } - - @Override - public Long getWriteBytes() { - return writeBytes; - } - - @Override - public Long queryWriteBytes() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.WRITE_BYTES); - return writeBytes; - } - - @Override - public Long getReadPackets() { - return readPackets; - } - - @Override - public Long queryReadPackets() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.READ_PACKETS); - return readPackets; - } - - @Override - public Long getWritePackets() { - return writePackets; - } - - @Override - public Long queryWritePackets() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.WRITE_PACKETS); - return writePackets; - } - - @Override - public Long getReadErrors() { - return readErrors; - } - - @Override - public Long queryReadErrors() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.READ_ERRORS); - return readErrors; - } - - @Override - public Long getWriteErrors() { - return writeErrors; - } - - @Override - public Long queryWriteErrors() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.WRITE_ERRORS); - return writeErrors; - } - - @Override - public Long getReadDrops() { - return readDrops; - } - - @Override - public Long queryReadDrops() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.READ_DROPS); - return readDrops; - } - - @Override - public Long getWriteDrops() { - return writeDrops; - } - - @Override - public Long queryWriteDrops() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.WRITE_DROPS); - return writeDrops; - } - - @Override - public Long getWriteCollisions() { - return writeCollisions; - } - - @Override - public Long queryWriteCollisions() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.WRITE_COLLISIONS); - return writeCollisions; - } - - @Override - public Long getLinkSpeed() { - return linkSpeed; - } - - @Override - public Long queryLinkSpeed() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.LINK_SPEED); - return linkSpeed; - } - - @Override - public Boolean getDefaultGateway() { - return defaultGateway; - } - - @Override - public Boolean queryDefaultGateway() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.DEFAULT_GATEWAY); - return defaultGateway; - } - - @Override - public Boolean getFlagUp() { - return flagUp; - } - - @Override - public Boolean queryFlagUp() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.FLAG_UP); - return flagUp; - } - - @Override - public Boolean getFlagRunning() { - return flagRunning; - } - - @Override - public Boolean queryFlagRunning() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.FLAG_RUNNING); - return flagRunning; - } - - @Override - public Boolean getFlagLoopback() { - return flagLoopback; - } - - @Override - public Boolean queryFlagLoopback() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.FLAG_LOOPBACK); - return flagLoopback; - } - - @Override - public Boolean getFlagMulticast() { - return flagMulticast; - } - - @Override - public Boolean queryFlagMulticast() { - if (driver == null) { - throw new DetachedContainerException(); - } - driver.query(NicAttribute.FLAG_MULTICAST); - return flagMulticast; - } - - public void attach(ComponentDriver driver) { - this.driver = driver; - // Query all constant attributes: - driver.query(NicAttribute.NAME); - driver.query(NicAttribute.DESCRIPTION); - } + @Override + public Long getReadErrors() { + return readErrors; + } + + @Override + public Long queryReadErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_ERRORS); + return readErrors; + } + + @Override + public Long getWriteErrors() { + return writeErrors; + } + + @Override + public Long queryWriteErrors() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_ERRORS); + return writeErrors; + } + + @Override + public Long getReadDrops() { + return readDrops; + } + + @Override + public Long queryReadDrops() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.READ_DROPS); + return readDrops; + } + + @Override + public Long getWriteDrops() { + return writeDrops; + } + + @Override + public Long queryWriteDrops() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_DROPS); + return writeDrops; + } + + @Override + public Long getWriteCollisions() { + return writeCollisions; + } + + @Override + public Long queryWriteCollisions() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.WRITE_COLLISIONS); + return writeCollisions; + } + + @Override + public Long getLinkSpeed() { + return linkSpeed; + } + + @Override + public Long queryLinkSpeed() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.LINK_SPEED); + return linkSpeed; + } + + @Override + public Boolean getDefaultGateway() { + return defaultGateway; + } + + @Override + public Boolean queryDefaultGateway() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.DEFAULT_GATEWAY); + return defaultGateway; + } + + @Override + public Boolean getFlagUp() { + return flagUp; + } + + @Override + public Boolean queryFlagUp() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_UP); + return flagUp; + } + + @Override + public Boolean getFlagRunning() { + return flagRunning; + } + + @Override + public Boolean queryFlagRunning() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_RUNNING); + return flagRunning; + } + + @Override + public Boolean getFlagLoopback() { + return flagLoopback; + } + + @Override + public Boolean queryFlagLoopback() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_LOOPBACK); + return flagLoopback; + } + + @Override + public Boolean getFlagMulticast() { + return flagMulticast; + } + + @Override + public Boolean queryFlagMulticast() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.FLAG_MULTICAST); + return flagMulticast; + } + + public void attach(ComponentDriver driver) { + this.driver = driver; + // Query all constant attributes: + driver.query(NicAttributeEnum.NAME); + driver.query(NicAttributeEnum.DESCRIPTION); + } + + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return null; + case NAME: + return (T) name; + case DESCRIPTION: + return (T) description; + case MTU: + return (T) mtu; + case MAC: + return (T) mac; + case VIRTUAL: + return (T) virtual; + case IPV4: + return (T) ipv4; + case IPV6: + return (T) ipv6; + case BROADCAST: + return (T) broadcast; + case NETMASK: + return (T) netmask; + case READ_BYTES: + return (T) readBytes; + case WRITE_BYTES: + return (T) writeBytes; + case READ_PACKETS: + return (T) readPackets; + case WRITE_PACKETS: + return (T) writePackets; + case READ_ERRORS: + return (T) readErrors; + case WRITE_ERRORS: + return (T) writeErrors; + case READ_DROPS: + return (T) readDrops; + case WRITE_DROPS: + return (T) writeDrops; + case WRITE_COLLISIONS: + return (T) writeCollisions; + case LINK_SPEED: + return (T) linkSpeed; + case DEFAULT_GATEWAY: + return (T) defaultGateway; + case FLAG_UP: + return (T) flagUp; + case FLAG_RUNNING: + return (T) flagRunning; + case FLAG_LOOPBACK: + return (T) flagLoopback; + case FLAG_MULTICAST: + return (T) flagMulticast; + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java index 1e4d4ce..92ba4c9 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerFreeBsd.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.nic.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.nic.NicFreeBsd; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class NicContainerFreeBsd extends NicContainer implements NicFreeBsd { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java index 04a36f0..f1da897 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerLinux.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.nic.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.nic.NicLinux; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class NicContainerLinux extends NicContainer implements NicLinux { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java index a0d27e7..9b92772 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerMac.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.nic.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.nic.NicMac; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class NicContainerMac extends NicContainer implements NicMac { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java index 4ed1ddd..cb7b939 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerSolaris.java @@ -24,7 +24,9 @@ // This file was automatically generated by the OSHI API generator; do not edit! package oshi.api.hardware.nic.internal; +import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.hardware.nic.NicSolaris; import oshi.driver.ComponentDriver; @@ -33,11 +35,17 @@ */ @Generated("oshi.ApiGenerator") public class NicContainerSolaris extends NicContainer implements NicSolaris { - private transient ComponentDriver driver; + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: + } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java index dac1d73..2186a08 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicContainerWindows.java @@ -26,6 +26,7 @@ import java.lang.Override; import javax.annotation.processing.Generated; +import oshi.api.AttributeKey; import oshi.api.DetachedContainerException; import oshi.api.hardware.nic.NicWindows; import oshi.driver.ComponentDriver; @@ -35,87 +36,101 @@ */ @Generated("oshi.ApiGenerator") public class NicContainerWindows extends NicContainer implements NicWindows { - private transient ComponentDriver driver; + /** + * The interface's locally unique identifier + */ + public Long luid; - /** - * The interface's locally unique identifier - */ - public Long luid; + /** + * The interface's globally unique identifier + */ + public String guid; - /** - * The interface's globally unique identifier - */ - public String guid; + /** + * Whether the interface is in a paused state + */ + public Boolean paused; - /** - * Whether the interface is in a paused state - */ - public Boolean paused; + /** + * Whether the interface is in a low-power state + */ + public Boolean lowpower; - /** - * Whether the interface is in a low-power state - */ - public Boolean lowpower; + @Override + public Long getLuid() { + return luid; + } - @Override - public Long getLuid() { - return luid; - } + @Override + public Long queryLuid() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.LUID); + return luid; + } - @Override - public Long queryLuid() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public String getGuid() { + return guid; } - driver.query(NicAttribute.LUID); - return luid; - } - @Override - public String getGuid() { - return guid; - } + @Override + public String queryGuid() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.GUID); + return guid; + } - @Override - public String queryGuid() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public Boolean getPaused() { + return paused; } - driver.query(NicAttribute.GUID); - return guid; - } - @Override - public Boolean getPaused() { - return paused; - } + @Override + public Boolean queryPaused() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.PAUSED); + return paused; + } - @Override - public Boolean queryPaused() { - if (driver == null) { - throw new DetachedContainerException(); + @Override + public Boolean getLowpower() { + return lowpower; } - driver.query(NicAttribute.PAUSED); - return paused; - } - @Override - public Boolean getLowpower() { - return lowpower; - } + @Override + public Boolean queryLowpower() { + if (driver == null) { + throw new DetachedContainerException(); + } + driver.query(NicAttributeEnum.LOWPOWER); + return lowpower; + } - @Override - public Boolean queryLowpower() { - if (driver == null) { - throw new DetachedContainerException(); + public void attach(ComponentDriver driver) { + this.driver = driver; + super.attach(driver); + // Query all constant attributes: } - driver.query(NicAttribute.LOWPOWER); - return lowpower; - } - public void attach(ComponentDriver driver) { - this.driver = driver; - super.attach(driver); - // Query all constant attributes: - } + @Override + public T get(AttributeKey key) { + switch ((NicAttributeEnum) key.getAttributeEnum()) { + default: + return super.get(key); + case LUID: + return (T) luid; + case GUID: + return (T) guid; + case PAUSED: + return (T) paused; + case LOWPOWER: + return (T) lowpower; + } + } } diff --git a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java index 28df010..91f37da 100644 --- a/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java +++ b/reference/oshi-core/src/gen/java/oshi/api/hardware/nic/internal/NicQuery.java @@ -34,5 +34,5 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface NicQuery { - NicAttribute[] value(); + NicAttributeEnum[] value(); } diff --git a/reference/oshi-core/src/main/java/oshi/ApiGenerator.java b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java index c46a924..68fad23 100644 --- a/reference/oshi-core/src/main/java/oshi/ApiGenerator.java +++ b/reference/oshi-core/src/main/java/oshi/ApiGenerator.java @@ -24,9 +24,9 @@ package oshi; import static javax.lang.model.element.Modifier.ABSTRACT; -import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PUBLIC; -import static javax.lang.model.element.Modifier.TRANSIENT; +import static javax.lang.model.element.Modifier.STATIC; import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -51,8 +51,14 @@ import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterizedTypeName; import com.squareup.javapoet.TypeSpec; +import com.squareup.javapoet.TypeVariableName; +import com.squareup.javapoet.WildcardTypeName; +import oshi.api.AttributeKey; +import oshi.api.Container; import oshi.api.DetachedContainerException; +import oshi.api.internal.AbstractContainer; +import oshi.driver.AttributeEnum; /** * This class generates most of the API layer according to a global @@ -83,7 +89,7 @@ public final class ApiGenerator { private static final String GENERATOR_COMMENT = "This file was automatically generated by the OSHI API generator; do not edit!"; /** - * An annotation for all generated sources. + * An annotation to be used on all generated sources. */ private static final AnnotationSpec GENERATOR_ANNOTATION = AnnotationSpec.builder(Generated.class) .addMember("value", String.format("\"%s\"", ApiGenerator.class.getName())).build(); @@ -101,7 +107,7 @@ public final class ApiGenerator { public static void main(String[] argv) throws Exception { try (var in = Files.newInputStream(Paths.get("definitions.json"))) { List json = new ObjectMapper().readValue(in, new TypeReference>() { - // The age old anonymous class trick + // The old anonymous class trick }); for (var component : json) { @@ -127,16 +133,31 @@ private static void generateAttributeEnums(ComponentJson component) { String baseName = component.getBaseName(); String pkgName = component.getPkgName(); - var attributeEnum = TypeSpec.enumBuilder(baseName + "Attribute").addModifiers(PUBLIC) + var attributeEnum = TypeSpec.enumBuilder(baseName + "AttributeEnum").addModifiers(PUBLIC) + .addAnnotation(GENERATOR_ANNOTATION).addSuperinterface(ClassName.get(AttributeEnum.class)); + var attributeKey = TypeSpec.classBuilder(baseName + "Attribute").addModifiers(PUBLIC) .addAnnotation(GENERATOR_ANNOTATION); for (var attribute : component.attributes) { + var type = ClassName.bestGuess(attribute.type); + // Generate enum constant attributeEnum.addEnumConstant(attribute.name.toUpperCase()); + + // Generate attribute key + var field = FieldSpec.builder(ParameterizedTypeName.get(ClassName.get(AttributeKey.class), type), + attribute.name.toUpperCase(), PUBLIC, STATIC, FINAL).initializer("new $T<>($T.$L)", + AttributeKey.class, ClassName.get(pkgName + ".internal", baseName + "AttributeEnum"), + attribute.name.toUpperCase()); + if (attribute.desc != null) + field.addJavadoc(attribute.desc + "\n"); + + attributeKey.addField(field.build()); } files.add(JavaFile.builder(pkgName + ".internal", attributeEnum.build()).addFileComment(GENERATOR_COMMENT) .build()); + files.add(JavaFile.builder(pkgName, attributeKey.build()).addFileComment(GENERATOR_COMMENT).build()); } private static void generate(ComponentJson component, String platform) { @@ -158,8 +179,8 @@ private static void generate(ComponentJson component, String platform) { .addAnnotation(AnnotationSpec.builder(Target.class) .addMember("value", "$T.METHOD", ClassName.get("java.lang.annotation", "ElementType")).build()); queryAnnotation.addMethod(MethodSpec.methodBuilder("value") - .returns(ClassName.get(pkgName + ".internal", baseName + "Attribute[]")).addModifiers(PUBLIC, ABSTRACT) - .build()); + .returns(ClassName.get(pkgName + ".internal", baseName + "AttributeEnum[]")) + .addModifiers(PUBLIC, ABSTRACT).build()); // Setup inheritance container.addSuperinterface(ClassName.get(pkgName, baseName + platform)); @@ -167,16 +188,14 @@ private static void generate(ComponentJson component, String platform) { container.superclass(ClassName.get(pkgName + ".internal", baseName + "Container")); containerInterface.addSuperinterface(ClassName.get(pkgName, baseName)); } else { + container.superclass(ClassName.get(AbstractContainer.class)); container.addModifiers(ABSTRACT); + containerInterface.addSuperinterface(ClassName.get(Container.class)); } if (component.desc != null) container.addJavadoc(component.desc + "\n"); - // Add driver field - container.addField(FieldSpec - .builder(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver", PRIVATE, TRANSIENT).build()); - // Create attach method var attach = MethodSpec.methodBuilder("attach") .addParameter(ClassName.get(DRIVER_PACKAGE, "ComponentDriver"), "driver") @@ -185,6 +204,19 @@ private static void generate(ComponentJson component, String platform) { attach.addStatement("super.attach(driver)"); attach.addComment("Query all constant attributes:"); + // Create get method + var getReturn = TypeVariableName.get("T"); + var containerGet = MethodSpec.methodBuilder("get").addTypeVariable(getReturn).returns(getReturn) + .addModifiers(PUBLIC) + .addParameter(ParameterizedTypeName.get(ClassName.get(AttributeKey.class), getReturn), "key") + .addAnnotation(Override.class); + containerGet.beginControlFlow("switch(($T) key.getAttributeEnum())", + ClassName.get(pkgName + ".internal", baseName + "AttributeEnum")); + if (!platform.isEmpty()) + containerGet.addStatement("default: return super.get(key)"); + else + containerGet.addStatement("default: return null"); + // Process attributes for (var attribute : component.attributes) { var type = ClassName.bestGuess(attribute.type); @@ -194,7 +226,8 @@ private static void generate(ComponentJson component, String platform) { if (attribute.constant) attach.addStatement("driver.query($T.$L)", - ClassName.get(pkgName + ".internal", baseName + "Attribute"), attribute.name.toUpperCase()); + ClassName.get(pkgName + ".internal", baseName + "AttributeEnum"), + attribute.name.toUpperCase()); // Generate container field var containerField = FieldSpec.builder(type, camel(attribute.name), PUBLIC); @@ -225,18 +258,25 @@ private static void generate(ComponentJson component, String platform) { .addStatement("throw new $T()", DetachedContainerException.class).endControlFlow() .build()) .addStatement("driver.query($T.$L)", - ClassName.get(pkgName + ".internal", baseName + "Attribute"), + ClassName.get(pkgName + ".internal", baseName + "AttributeEnum"), attribute.name.toUpperCase()) .addStatement("return $L", camel(attribute.name)).addModifiers(PUBLIC) .addAnnotation(Override.class); if (!attribute.constant) container.addMethod(containerQuery.build()); + + // + containerGet.addStatement("case $L: return (T) $L", attribute.name.toUpperCase(), + camel(attribute.name)); } } container.addMethod(attach.build()); + containerGet.endControlFlow(); + container.addMethod(containerGet.build()); + files.add(JavaFile.builder(pkgName + ".internal", container.build()).addFileComment(GENERATOR_COMMENT).build()); files.add(JavaFile.builder(pkgName, containerInterface.build()).addFileComment(GENERATOR_COMMENT).build()); files.add(JavaFile.builder(pkgName + ".internal", queryAnnotation.build()).addFileComment(GENERATOR_COMMENT) @@ -255,6 +295,10 @@ private static void generateSystemInterface(List components, Stri var system = TypeSpec.interfaceBuilder((platform.isEmpty() ? "Multi" : platform) + "System") .addModifiers(PUBLIC).addAnnotation(GENERATOR_ANNOTATION); + if (!platform.isEmpty()) { + system.addSuperinterface(ClassName.get(API_PACKAGE, "MultiSystem")); + } + for (var component : components) { if (!component.root) continue; @@ -269,7 +313,7 @@ private static void generateSystemInterface(List components, Stri system.addMethod(get.build()); } else { - type = ParameterizedTypeName.get(ClassName.get(Stream.class), type); + type = ParameterizedTypeName.get(ClassName.get(Stream.class), WildcardTypeName.subtypeOf(type)); var get = MethodSpec.methodBuilder(camel("get", baseName, "stream")).returns(type).addModifiers(PUBLIC, ABSTRACT); diff --git a/reference/oshi-core/src/main/java/oshi/api/AttributeKey.java b/reference/oshi-core/src/main/java/oshi/api/AttributeKey.java new file mode 100644 index 0000000..bf93073 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/AttributeKey.java @@ -0,0 +1,47 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +import java.util.Objects; + +import oshi.driver.AttributeEnum; + +/** + * {@link AttributeKey}s are used to uniquely identify attributes. + * + * @param + * The data type of the corresponding attribute + */ +public final class AttributeKey { + + private AttributeEnum attributeEnum; + + public AttributeKey(AttributeEnum attributeEnum) { + this.attributeEnum = Objects.requireNonNull(attributeEnum); + } + + public AttributeEnum getAttributeEnum() { + return attributeEnum; + } +} diff --git a/reference/oshi-core/src/main/java/oshi/api/Container.java b/reference/oshi-core/src/main/java/oshi/api/Container.java new file mode 100644 index 0000000..9b6b873 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/Container.java @@ -0,0 +1,84 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api; + +import java.io.Serializable; + +import oshi.driver.ComponentDriver; + +/** + * A container class represents a particular instance of a general system + * component. Container classes have two main purposes: + *
    + *
  • Store the most recently fetched attribute values so the user doesn't have + * to manually.
  • + *
  • Provide a way for users to fetch (update) attribute values of the + * corresponding component.
  • + *
+ */ +public interface Container extends Serializable { + + public abstract void attach(ComponentDriver driver); + + /** + * Update the values of the attributes corresponding to the given + * {@link AttributeKey}s. Unlike sequentially calling the {@code query*} + * methods for each attribute, this method doesn't duplicate batched queries + * if possible.
+ *
+ * For example, + * + *
+     * disk.queryReadBytes();
+     * disk.queryWriteBytes();
+     * 
+ * + * causes each attribute to be updated twice because {@code READ_BYTES} and + * {@code WRITE_BYTES} are fetched at the same time (batch queries).
+ *
+ * This method prevents wasted queries with the following usage: + * + *
+     * disk.query(READ_BYTES, WRITE_BYTES);
+     * 
+ * + * + * @param keys + * One or more keys that uniquely identify the attributes to be + * updated + */ + public abstract void query(AttributeKey... keys); + + /** + * Return the last-fetched value of the attribute corresponding to the given + * {@link AttributeKey}. + * + * @param + * The attribute's data type + * @param key + * A key that uniquely identifies the requested attribute + * @return The attribute's value + */ + public abstract T get(AttributeKey key); +} diff --git a/reference/oshi-core/src/main/java/oshi/api/OSHI.java b/reference/oshi-core/src/main/java/oshi/api/OSHI.java index 6002869..6cfc1a9 100644 --- a/reference/oshi-core/src/main/java/oshi/api/OSHI.java +++ b/reference/oshi-core/src/main/java/oshi/api/OSHI.java @@ -25,15 +25,30 @@ import com.sun.jna.Platform; -import oshi.driver.SystemDriver; -import oshi.driver.SystemDriverFreeBsd; -import oshi.driver.SystemDriverLinux; -import oshi.driver.SystemDriverMac; -import oshi.driver.SystemDriverSolaris; -import oshi.driver.SystemDriverWindows; +import oshi.driver.system.SystemDriverFreeBsd; +import oshi.driver.system.SystemDriverLinux; +import oshi.driver.system.SystemDriverMac; +import oshi.driver.system.SystemDriverSolaris; +import oshi.driver.system.SystemDriverWindows; /** + * This factory class is used to build disposable {@link MultiSystem} instances + * that can be used to access everything in OSHI.
+ *
+ * Most users should call {@link #getSystem()} for a fully cross-platform handle + * on the system. If platform-specific features are desired, one of the + * platform-unsafe methods can be called instead (at your own risk).
+ *
* + * For example, typical usage is as follows: + * + *
+ * Firmware firmware = OSHI.getSystem().getFirmware();
+ * ...
+ * 
+ * LinuxFirmware firmware = OSHI.getLinuxSystem().getFirmware();
+ * ...
+ * 
*/ public final class OSHI { @@ -73,15 +88,15 @@ public static PlatformEnum getPlatform() { public static MultiSystem getSystem() { switch (PLATFORM) { case FREEBSD: - return new SystemDriver(new SystemDriverFreeBsd()); + return new SystemDriverFreeBsd(); case LINUX: - return new SystemDriver(new SystemDriverLinux()); + return new SystemDriverLinux(); case MACOSX: - return new SystemDriver(new SystemDriverMac()); + return new SystemDriverMac(); case SOLARIS: - return new SystemDriver(new SystemDriverSolaris()); + return new SystemDriverSolaris(); case WINDOWS: - return new SystemDriver(new SystemDriverWindows()); + return new SystemDriverWindows(); default: throw new UnsupportedOperationException("OSHI is not supported on this platform"); } @@ -90,7 +105,8 @@ public static MultiSystem getSystem() { /** * Build a disposable handle that provides Windows system information.
*
- * Note: for cross-platform contexts, always use {@link #getSystem()}. + * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. * * @return A new {@link WindowsSystem} handle */ @@ -103,7 +119,8 @@ public static WindowsSystem getWindowsSystem() { /** * Build a disposable handle that provides Linux system information.
*
- * Note: for cross-platform contexts, always use {@link #getSystem()}. + * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. * * @return A new {@link LinuxSystem} handle */ @@ -116,7 +133,8 @@ public static LinuxSystem getLinuxSystem() { /** * Build a disposable handle that provides macOS system information.
*
- * Note: for cross-platform contexts, always use {@link #getSystem()}. + * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. * * @return A new {@link MacSystem} handle */ @@ -129,7 +147,8 @@ public static MacSystem getMacSystem() { /** * Build a disposable handle that provides Solaris system information.
*
- * Note: for cross-platform contexts, always use {@link #getSystem()}. + * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. * * @return A new {@link SolarisSystem} handle */ @@ -142,7 +161,8 @@ public static SolarisSystem getSolarisSystem() { /** * Build a disposable handle that provides FreeBSD system information.
*
- * Note: for cross-platform contexts, always use {@link #getSystem()}. + * Note: for cross-platform contexts, always use {@link #getSystem()} + * instead. * * @return A new {@link FreeBsdSystem} handle */ diff --git a/reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java b/reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java new file mode 100644 index 0000000..960a2c8 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/api/internal/AbstractContainer.java @@ -0,0 +1,51 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.api.internal; + +import java.util.Arrays; + +import oshi.api.AttributeKey; +import oshi.api.Container; +import oshi.driver.AttributeEnum; +import oshi.driver.ComponentDriver; + +/** + * A superclass for all generated container classes. + */ +public abstract class AbstractContainer implements Container { + + /** + * The root driver instance associated with this container. If {@code null}, + * this container is considered to be DETACHED and all attempts to + * update its attributes will fail. Otherwise, the container is considered + * to be ATTACHED. + */ + protected transient ComponentDriver driver; + + @Override + public void query(AttributeKey... keys) { + // Translate attribute-keys into attribute-enums for the driver + driver.query(Arrays.stream(keys).map(key -> key.getAttributeEnum()).toArray(AttributeEnum[]::new)); + } +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/Timeout.java b/reference/oshi-core/src/main/java/oshi/driver/AttributeEnum.java similarity index 72% rename from reference/oshi-core/src/main/java/oshi/driver/Timeout.java rename to reference/oshi-core/src/main/java/oshi/driver/AttributeEnum.java index 6f6d3ab..b854a17 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/Timeout.java +++ b/reference/oshi-core/src/main/java/oshi/driver/AttributeEnum.java @@ -23,14 +23,18 @@ */ package oshi.driver; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -@Retention(RUNTIME) -@Target(METHOD) -public @interface Timeout { +import oshi.api.AttributeKey; +/** + * This interface marks a generated {@code enum} as an attribute-enum (which + * contains a constant for every attribute in a component). All + * {@link AttributeEnum}s are wrapped by {@link AttributeKey}s for use by the + * user.
+ *
+ * {@link AttributeEnum}s are primarily used to associate annotated query + * methods within driver classes to attributes. + * + * @see {@link AttributeKey} + */ +public interface AttributeEnum { } diff --git a/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java index c4c27c0..05dc16c 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java +++ b/reference/oshi-core/src/main/java/oshi/driver/ComponentDriver.java @@ -26,117 +26,175 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import oshi.driver.annotation.Fallback; + /** * A {@link ComponentDriver} is the root of the driver hierarchy. Containers can - * call {@link #query(Enum)} or {@link #queryAll()} to have this class update - * their state. There is a one-to-one correspondence between + * call {@link #query(AttributeEnum)} or {@link #queryAll()} to have this class + * update their state. There is a one-to-one correspondence between * {@link ComponentDriver}s and container objects.
*
* This class automatically registers all query methods in its subclasses. Query * methods in {@link ExtensionDriver}s can also be registered with * {@link #register(ExtensionDriver)}. */ -public class ComponentDriver { +public abstract class ComponentDriver { + + private static final Logger log = LoggerFactory.getLogger(ComponentDriver.class); + /** + * This class wraps a query method's {@link MethodHandle} with additional + * metadata that's useful for ordering query handles within a + * {@link QueryStack}.
+ *
+ * + * Note: this class has a natural ordering that is inconsistent with equals. + */ private static final class QueryHandle implements Comparable { + + /** + * A handle on the method that performs the query. + */ public MethodHandle handle; + + /** + * A fallback annotation for query ordering. + */ public Fallback fallback; + + /** + * The class that contributed this query handle. + */ public Class cls; - public QueryHandle(MethodHandle handle, Fallback fallback, Class cls) { - this.handle = handle; - this.fallback = fallback; - this.cls = cls; + /** + * The method name of the query method. + */ + public String name; + + public QueryHandle(MethodHandle handle, Class cls, Method method) { + this.handle = Objects.requireNonNull(handle); + this.cls = Objects.requireNonNull(cls); + this.name = method.getName(); + this.fallback = method.getAnnotation(Fallback.class); } @Override - public int compareTo(QueryHandle o) { - // TODO implement query ordering with fallbacks + public int compareTo(QueryHandle other) { + if (this == other) + return 0; + + if (this.fallback != null) { + if (this.fallback.value() == other.cls) { + if (this.fallback.method() != null) { + if (this.fallback.method().equals(other.name)) { + return -1; + } + } else { + return -1; + } + } + } else if (other.fallback != null) { + if (other.fallback.value() == this.cls) { + if (other.fallback.method() != null) { + if (other.fallback.method().equals(this.name)) { + return +1; + } + } else { + return +1; + } + } + } + + // No ordering preference return 0; } } /** - * An association between attribute enums and lists of query handles in - * descending priority order. A particular query handle can exist in - * multiple lists, but not more than once in each list. + * A {@link QueryStack} is a collection of {@link QueryHandle}s that are + * invoked sequentially upon query. A query attempt always begins with the + * top handle and continues down the stack until a handle succeeds. The + * stack can be configured to pop failed query handles if they are unlikely + * to ever succeed. */ - private Map, List> handles; + private static final class QueryStack extends ArrayList { + } + + /** + * An association between attribute-enums and query stacks (lists of query + * handles in descending priority order). A particular query handle can + * exist in multiple stacks, but not more than once in each. + */ + private Map handles; /** * A list of extensions in case they are needed in the future. */ private List extensions; - public ComponentDriver() { + public void initialize(List extensions) { + if (this.handles != null || this.extensions != null) + throw new IllegalArgumentException("The driver has already been initialized"); + + this.extensions = Objects.requireNonNull(extensions); this.handles = new HashMap<>(); - this.extensions = new LinkedList<>(); registerDriver(this); + this.extensions.forEach(this::registerDriver); + + // Reorder each stack + handles.values().forEach(Collections::sort); } /** - * Query the driver hierarchy for the value of the attribute corresponding - * to the given enum. + * Query the driver hierarchy for the value of the attributes corresponding + * to the given enums. * - * @param attribute - * The attribute enum of the attribute to query + * @param attributes + * The attribute enums of the attributes to query + */ + public void query(AttributeEnum... attributes) { + Arrays.stream(attributes).map(handles::get).distinct().forEach(this::query); + } + + /** + * Query every attribute in the driver hierarchy. */ - public void query(Enum attribute) { + public void queryAll() { + handles.values().stream().distinct().forEach(this::query); + } - var h = handles.get(attribute); - if (h == null) { + private void query(QueryStack stack) { + if (stack == null) // TODO - } + return; - for (var t : h) { + for (var queryHandle : stack) { try { - t.handle.invoke(); + queryHandle.handle.invoke(); return; } catch (Throwable e) { // TODO log exception and continue + // TODO remove if configured + e.printStackTrace(); continue; } } } - /** - * Query every attribute in the driver hierarchy. - */ - public void queryAll() { - // Keep track of the handles that have been queried to prevent repeats - var queried = new HashSet(); - for (var handleList : handles.values()) { - for (var h : handleList) { - if (queried.contains(h.handle)) - break; - - queried.add(h.handle); - try { - h.handle.invoke(); - break; - } catch (Throwable e) { - // TODO log exception and continue - continue; - } - } - } - } - - public void register(ExtensionDriver driver) { - registerDriver(driver); - extensions.add(driver); - } - /** * Iterate through the methods of the given object and build a * {@link QueryHandle} for each one containing a query annotation. @@ -152,38 +210,35 @@ private void registerDriver(Object driver) { // Build a list of attributes defined in the annotations var attributes = Arrays.stream(m.getDeclaredAnnotations()).flatMap(annotation -> { try { - return Arrays.stream((Enum[]) annotation.getClass().getMethod("value").invoke(annotation)); + return Arrays + .stream((AttributeEnum[]) annotation.getClass().getMethod("value").invoke(annotation)); } catch (NoSuchMethodException e) { // Not the annotation we're looking for - return Arrays.stream(new Enum[0]); + return Arrays.stream(new AttributeEnum[0]); } catch (Exception e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed to read query annotation", e); } }).collect(Collectors.toList()); if (attributes.size() > 0) { - // Build method handle + // Build query handle try { m.setAccessible(true); - var handle = MethodHandles.lookup().unreflect(m).bindTo(driver); + var handle = new QueryHandle(MethodHandles.lookup().unreflect(m).bindTo(driver), driverClass, + m); + var stack = new QueryStack(); + stack.add(handle); for (var attribute : attributes) { - if (!handles.containsKey(attribute)) { - handles.put(attribute, new LinkedList<>()); - } - handles.get(attribute) - .add(new QueryHandle(handle, m.getAnnotation(Fallback.class), driverClass)); + handles.put(attribute, stack); } } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot access query method: " + m.getName()); + throw new RuntimeException("Cannot access query method: " + m.getName(), e); } } } driverClass = driverClass.getSuperclass(); } - - // Reorder each stack - handles.values().forEach(Collections::sort); } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java b/reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java new file mode 100644 index 0000000..8102db2 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/ContainerFactory.java @@ -0,0 +1,78 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; + +import oshi.api.internal.AbstractContainer; + +public class ContainerFactory { + + public static C build(Class containerClass, + Consumer containerConfigurator, Class driverClass, + Consumer> driverConfigurator) { + + try { + // Build and configure container + C container = containerClass.getConstructor().newInstance(); + containerConfigurator.accept(container); + + // Build driver + D driver = driverClass.getConstructor().newInstance(); + var driverContainerField = driverClass.getDeclaredField("container"); + driverContainerField.setAccessible(true); + driverContainerField.set(driver, container); + + // Configure extensions + ArrayList extensions = new ArrayList<>(); + driverConfigurator.accept(extensions); + extensions.trimToSize(); + for (var extension : extensions) { + var extensionContainerField = extension.getClass().getDeclaredField("container"); + extensionContainerField.setAccessible(true); + extensionContainerField.set(extension, container); + } + + driver.initialize(Collections.unmodifiableList(extensions)); + container.attach(driver); + return container; + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + public static C build(Class containerClass, + Class driverClass) { + return build(containerClass, container -> { + // Do nothing + }, driverClass, extensions -> { + // Do nothing + }); + } + +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java b/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java index d7e25f7..4679b9a 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java +++ b/reference/oshi-core/src/main/java/oshi/driver/ExtensionDriver.java @@ -25,7 +25,11 @@ /** * A marker class for a driver that provides additional query methods to a - * {@link ComponentDriver}. + * {@link ComponentDriver}. Usually an {@link ExtensionDriver} is responsible + * for fetching a group of related attributes that depend on external software + * which may or may not be present. */ -public class ExtensionDriver { +public abstract class ExtensionDriver { + + public abstract boolean compatible(); } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java b/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java deleted file mode 100644 index 5955697..0000000 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriver.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * OSHI (https://github.com/oshi/oshi) - * - * Copyright (c) 2010 - 2019 The OSHI Project Team: - * https://github.com/oshi/oshi/graphs/contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package oshi.driver; - -import java.util.Objects; -import java.util.stream.Stream; - -import oshi.api.MultiSystem; -import oshi.api.hardware.disk.Disk; -import oshi.api.hardware.firmware.Firmware; -import oshi.api.hardware.nic.Nic; - -@SuppressWarnings("unchecked") -public class SystemDriver implements MultiSystem { - - private Object driver; - - public SystemDriver(Object driver) { - this.driver = Objects.requireNonNull(driver); - } - - @Override - public Stream getNicStream() { - try { - return (Stream) driver.getClass().getMethod("getNicStream").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Stream getDiskStream() { - try { - return (Stream) driver.getClass().getMethod("getDiskStream").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Firmware getFirmware() { - try { - return (Firmware) driver.getClass().getMethod("getFirmware").invoke(driver); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - -} diff --git a/reference/oshi-core/src/main/java/oshi/driver/Fallback.java b/reference/oshi-core/src/main/java/oshi/driver/annotation/Fallback.java similarity index 76% rename from reference/oshi-core/src/main/java/oshi/driver/Fallback.java rename to reference/oshi-core/src/main/java/oshi/driver/annotation/Fallback.java index 0c46f24..418557e 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/Fallback.java +++ b/reference/oshi-core/src/main/java/oshi/driver/annotation/Fallback.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.annotation; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; @@ -29,8 +29,25 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; +/** + * Indicates that the annotated query method be preferred over the query + * method(s) in the targeted class for the same attributes. + */ @Retention(RUNTIME) @Target(METHOD) public @interface Fallback { + + /** + * Get the fallback class. + * + * @return The class that contains the fallback method + */ public Class value(); + + /** + * Get the name of the fallback method for use with reflection. + * + * @return The explicit name of the fallback method + */ + public String method() default ""; } diff --git a/reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java b/reference/oshi-core/src/main/java/oshi/driver/annotation/RequiresRoot.java similarity index 91% rename from reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java rename to reference/oshi-core/src/main/java/oshi/driver/annotation/RequiresRoot.java index 6b56417..65cbf16 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/RequiresRoot.java +++ b/reference/oshi-core/src/main/java/oshi/driver/annotation/RequiresRoot.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.annotation; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; @@ -29,6 +29,10 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; +/** + * Indicates that the annotated query method requires elevated privileges to + * complete successfully. + */ @Retention(RUNTIME) @Target(METHOD) public @interface RequiresRoot { diff --git a/reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java b/reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java new file mode 100644 index 0000000..aa8c922 --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/driver/annotation/Timeout.java @@ -0,0 +1,57 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.driver.annotation; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import oshi.driver.QueryStatus; + +/** + * Indicates that the annotated query method should be allowed the given amount + * of time to execute before it's cancelled. A cancelled query method will have + * a result of {@link QueryStatus#TIMEOUT}. + */ +@Retention(RUNTIME) +@Target(METHOD) +public @interface Timeout { + + /** + * Return the timeout identifier which will be used to find the explicit + * timeout value. + * + * @return The timeout identifier or "class" + */ + public String value() default ""; + + /** + * Return the query timeout. + * + * @return The timeout in milliseconds + */ + public int milliseconds() default 0; +} diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java index ddff046..ce40b12 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinux.java @@ -23,16 +23,7 @@ */ package oshi.driver.hardware.disk; -import static oshi.api.hardware.disk.internal.DiskAttribute.MODEL; -import static oshi.api.hardware.disk.internal.DiskAttribute.NAME; -import static oshi.api.hardware.disk.internal.DiskAttribute.QUEUE_LENGTH; -import static oshi.api.hardware.disk.internal.DiskAttribute.READS; -import static oshi.api.hardware.disk.internal.DiskAttribute.READ_BYTES; -import static oshi.api.hardware.disk.internal.DiskAttribute.SERIAL; -import static oshi.api.hardware.disk.internal.DiskAttribute.SIZE; -import static oshi.api.hardware.disk.internal.DiskAttribute.TRANSFER_TIME; -import static oshi.api.hardware.disk.internal.DiskAttribute.WRITES; -import static oshi.api.hardware.disk.internal.DiskAttribute.WRITE_BYTES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.*; import oshi.api.hardware.disk.internal.DiskContainerLinux; import oshi.api.hardware.disk.internal.DiskQuery; @@ -44,10 +35,6 @@ public class DiskDriverLinux extends ComponentDriver { private DiskContainerLinux container; - public DiskDriverLinux(DiskContainerLinux container) { - this.container = container; - } - /** * The size of a logical sector in bytes. */ diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java index 36131a2..3cee73a 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/disk/DiskDriverLinuxSMART.java @@ -23,46 +23,112 @@ */ package oshi.driver.hardware.disk; -import static oshi.api.hardware.disk.internal.DiskAttribute.CALIBRATION_RETRIES; -import static oshi.api.hardware.disk.internal.DiskAttribute.CRC_ERRORS; -import static oshi.api.hardware.disk.internal.DiskAttribute.CURRENT_PENDING_SECTOR; -import static oshi.api.hardware.disk.internal.DiskAttribute.FIRMWARE_VERSION; -import static oshi.api.hardware.disk.internal.DiskAttribute.LOAD_CYCLES; -import static oshi.api.hardware.disk.internal.DiskAttribute.MODEL_FAMILY; -import static oshi.api.hardware.disk.internal.DiskAttribute.MULTIZONE_ERROR_RATE; -import static oshi.api.hardware.disk.internal.DiskAttribute.OFFLINE_UNCORRECTABLE; -import static oshi.api.hardware.disk.internal.DiskAttribute.POWEROFF_RETRACTS; -import static oshi.api.hardware.disk.internal.DiskAttribute.POWER_CYCLES; -import static oshi.api.hardware.disk.internal.DiskAttribute.POWER_ON_TIME; -import static oshi.api.hardware.disk.internal.DiskAttribute.READ_ERROR_RATE; -import static oshi.api.hardware.disk.internal.DiskAttribute.REALLOCATED_EVENTS; -import static oshi.api.hardware.disk.internal.DiskAttribute.REALLOCATED_SECTORS; -import static oshi.api.hardware.disk.internal.DiskAttribute.ROTATION_RATE; -import static oshi.api.hardware.disk.internal.DiskAttribute.SEEK_ERROR_RATE; -import static oshi.api.hardware.disk.internal.DiskAttribute.SPIN_RETRIES; -import static oshi.api.hardware.disk.internal.DiskAttribute.SPIN_UP_TIME; -import static oshi.api.hardware.disk.internal.DiskAttribute.START_STOP_CYCLES; -import static oshi.api.hardware.disk.internal.DiskAttribute.TEMPERATURE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.CALIBRATION_RETRIES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.CRC_ERRORS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.CURRENT_PENDING_SECTOR; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.FIRMWARE_VERSION; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.LOAD_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.MODEL_FAMILY; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.MULTIZONE_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.OFFLINE_UNCORRECTABLE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.POWEROFF_RETRACTS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.POWER_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.POWER_ON_TIME; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.READ_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.REALLOCATED_EVENTS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.REALLOCATED_SECTORS; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.ROTATION_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.SEEK_ERROR_RATE; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.SPIN_RETRIES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.SPIN_UP_TIME; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.START_STOP_CYCLES; +import static oshi.api.hardware.disk.internal.DiskAttributeEnum.TEMPERATURE; + +import java.io.IOException; import oshi.api.hardware.disk.internal.DiskContainerLinux; import oshi.api.hardware.disk.internal.DiskQuery; import oshi.driver.ExtensionDriver; +import oshi.driver.annotation.RequiresRoot; import oshi.old.ExecutingCommand; public class DiskDriverLinuxSMART extends ExtensionDriver { private DiskContainerLinux container; - public DiskDriverLinuxSMART(DiskContainerLinux container) { - this.container = container; + @Override + public boolean compatible() { + try { + return 127 != Runtime.getRuntime().exec("smartctl").waitFor(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; } + @RequiresRoot @DiskQuery({ MODEL_FAMILY, FIRMWARE_VERSION, ROTATION_RATE, READ_ERROR_RATE, SPIN_UP_TIME, START_STOP_CYCLES, REALLOCATED_SECTORS, SEEK_ERROR_RATE, POWER_ON_TIME, SPIN_RETRIES, CALIBRATION_RETRIES, POWER_CYCLES, POWEROFF_RETRACTS, LOAD_CYCLES, TEMPERATURE, REALLOCATED_EVENTS, CURRENT_PENDING_SECTOR, OFFLINE_UNCORRECTABLE, CRC_ERRORS, MULTIZONE_ERROR_RATE }) - private void diskStats() { - // TODO parse command - ExecutingCommand.runNative("sudo smartctl --all " + container.name); + private void diskStats() throws IOException { + var output = ExecutingCommand.runNative("sudo smartctl --attributes " + container.path); + for (int i = 7; i < 24; i++) { + String[] line = output.get(i).trim().split("\\s+"); + switch (Integer.parseInt(line[0])) { + case 1: + container.readErrorRate = Long.parseLong(line[9]); + break; + case 3: + container.spinUpTime = Long.parseLong(line[9]); + break; + case 4: + container.startStopCycles = Long.parseLong(line[9]); + break; + case 5: + container.reallocatedSectors = Long.parseLong(line[9]); + break; + case 7: + container.seekErrorRate = Long.parseLong(line[9]); + break; + case 9: + container.powerOnTime = Long.parseLong(line[9]); + break; + case 10: + container.spinRetries = Long.parseLong(line[9]); + break; + case 11: + container.calibrationRetries = Long.parseLong(line[9]); + break; + case 12: + container.powerCycles = Long.parseLong(line[9]); + break; + case 192: + container.poweroffRetracts = Long.parseLong(line[9]); + break; + case 193: + container.loadCycles = Long.parseLong(line[9]); + break; + case 194: + container.temperature = Long.parseLong(line[9]); + break; + case 196: + container.reallocatedEvents = Long.parseLong(line[9]); + break; + case 197: + container.currentPendingSector = Long.parseLong(line[9]); + break; + case 198: + container.offlineUncorrectable = Long.parseLong(line[9]); + break; + case 199: + container.crcErrors = Long.parseLong(line[9]); + break; + case 200: + container.multizoneErrorRate = Long.parseLong(line[9]); + break; + } + } } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java index 9814192..a1cebb6 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/firmware/FirmwareDriverLinux.java @@ -23,18 +23,12 @@ */ package oshi.driver.hardware.firmware; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.DESCRIPTION; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.MANUFACTURER; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.NAME; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.RELEASE_DATE; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.REVISION; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.UEFI; -import static oshi.api.hardware.firmware.internal.FirmwareAttribute.VERSION; +import static oshi.api.hardware.firmware.internal.FirmwareAttributeEnum.*; import oshi.api.hardware.firmware.internal.FirmwareContainerLinux; import oshi.api.hardware.firmware.internal.FirmwareQuery; import oshi.driver.ComponentDriver; -import oshi.driver.RequiresRoot; +import oshi.driver.annotation.RequiresRoot; import oshi.old.ExecutingCommand; import oshi.old.FileUtil; @@ -42,10 +36,6 @@ public class FirmwareDriverLinux extends ComponentDriver { private FirmwareContainerLinux container; - public FirmwareDriverLinux(FirmwareContainerLinux container) { - this.container = container; - } - private static final String SYSFS_SERIAL_PATH = "/sys/devices/virtual/dmi/id/"; @FirmwareQuery(NAME) diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java index 1b6a3d4..e0a4eb7 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverJava.java @@ -23,12 +23,7 @@ */ package oshi.driver.hardware.nic; -import static oshi.api.hardware.nic.internal.NicAttribute.IPV4; -import static oshi.api.hardware.nic.internal.NicAttribute.IPV6; -import static oshi.api.hardware.nic.internal.NicAttribute.MAC; -import static oshi.api.hardware.nic.internal.NicAttribute.MTU; -import static oshi.api.hardware.nic.internal.NicAttribute.NAME; -import static oshi.api.hardware.nic.internal.NicAttribute.VIRTUAL; +import static oshi.api.hardware.nic.internal.NicAttributeEnum.*; import java.net.NetworkInterface; import java.net.SocketException; @@ -45,8 +40,7 @@ public class NicDriverJava extends ExtensionDriver { protected NetworkInterface instance; private NicContainer container; - public NicDriverJava(NicContainer container, NetworkInterface instance) { - this.container = container; + public NicDriverJava(NetworkInterface instance) { this.instance = instance; } @@ -81,4 +75,9 @@ private void mtu() throws SocketException { container.mtu = instance.getMTU(); } + @Override + public boolean compatible() { + return true; + } + } diff --git a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java index cf0710c..29a0def 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/hardware/nic/NicDriverLinux.java @@ -23,25 +23,7 @@ */ package oshi.driver.hardware.nic; -import static oshi.api.hardware.nic.internal.NicAttribute.BROADCAST; -import static oshi.api.hardware.nic.internal.NicAttribute.DEFAULT_GATEWAY; -import static oshi.api.hardware.nic.internal.NicAttribute.DESCRIPTION; -import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_LOOPBACK; -import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_MULTICAST; -import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_RUNNING; -import static oshi.api.hardware.nic.internal.NicAttribute.FLAG_UP; -import static oshi.api.hardware.nic.internal.NicAttribute.LINK_SPEED; -import static oshi.api.hardware.nic.internal.NicAttribute.MTU; -import static oshi.api.hardware.nic.internal.NicAttribute.NETMASK; -import static oshi.api.hardware.nic.internal.NicAttribute.READ_BYTES; -import static oshi.api.hardware.nic.internal.NicAttribute.READ_DROPS; -import static oshi.api.hardware.nic.internal.NicAttribute.READ_ERRORS; -import static oshi.api.hardware.nic.internal.NicAttribute.READ_PACKETS; -import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_BYTES; -import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_COLLISIONS; -import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_DROPS; -import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_ERRORS; -import static oshi.api.hardware.nic.internal.NicAttribute.WRITE_PACKETS; +import static oshi.api.hardware.nic.internal.NicAttributeEnum.*; import oshi.api.hardware.nic.internal.NicContainerLinux; import oshi.api.hardware.nic.internal.NicQuery; @@ -52,10 +34,6 @@ public class NicDriverLinux extends ComponentDriver { private NicContainerLinux container; - public NicDriverLinux(NicContainerLinux container) { - this.container = container; - } - @NicQuery(READ_BYTES) private void readBytes() { container.readBytes = FileUtil diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverFreeBsd.java similarity index 98% rename from reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java rename to reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverFreeBsd.java index 6a4cef1..dd0b908 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverFreeBsd.java +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverFreeBsd.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.system; import java.util.stream.Stream; diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverLinux.java similarity index 72% rename from reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java rename to reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverLinux.java index 1cc1787..84616ed 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverLinux.java +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverLinux.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.system; import java.net.NetworkInterface; import java.net.SocketException; @@ -36,10 +36,13 @@ import oshi.api.hardware.firmware.internal.FirmwareContainerLinux; import oshi.api.hardware.nic.NicLinux; import oshi.api.hardware.nic.internal.NicContainerLinux; +import oshi.driver.ContainerFactory; import oshi.driver.hardware.disk.DiskDriverLinux; +import oshi.driver.hardware.disk.DiskDriverLinuxSMART; import oshi.driver.hardware.firmware.FirmwareDriverLinux; import oshi.driver.hardware.nic.NicDriverJava; import oshi.driver.hardware.nic.NicDriverLinux; +import oshi.old.GlobalConfig; import oshi.old.Udev; public class SystemDriverLinux implements LinuxSystem { @@ -48,13 +51,12 @@ public class SystemDriverLinux implements LinuxSystem { public Stream getNicStream() { try { return NetworkInterface.networkInterfaces().map(nif -> { - var container = new NicContainerLinux(); - container.name = nif.getName(); - var driver = new NicDriverLinux(container); - driver.register(new NicDriverJava(container, nif)); - - container.attach(driver); - return container; + return ContainerFactory.build(NicContainerLinux.class, container -> { + container.name = nif.getName(); + }, NicDriverLinux.class, extensions -> { + if (GlobalConfig.get("oshi.driver.extension.networkinterface", true)) + extensions.add(new NicDriverJava(nif)); + }); }); } catch (SocketException e) { // No interfaces found or I/O error occurred @@ -78,22 +80,26 @@ public Stream getDiskStream() { entry = Udev.INSTANCE.udev_enumerate_get_list_entry(enumerate); while (true) { oldEntry = entry; - device = Udev.INSTANCE.udev_device_new_from_syspath(handle, Udev.INSTANCE.udev_list_entry_get_name(entry)); + String name = Udev.INSTANCE.udev_list_entry_get_name(entry); + device = Udev.INSTANCE.udev_device_new_from_syspath(handle, name); if (device == null) { break; } + String path = Udev.INSTANCE.udev_device_get_devnode(device); + // Ignore loopback and ram disks; do nothing - if (!Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/loop") - && !Udev.INSTANCE.udev_device_get_devnode(device).startsWith("/dev/ram")) { + if (!path.startsWith("/dev/loop") && !path.startsWith("/dev/ram")) { if ("disk".equals(Udev.INSTANCE.udev_device_get_devtype(device))) { - var container = new DiskContainerLinux(); - container.name = Udev.INSTANCE.udev_list_entry_get_name(entry); - var driver = new DiskDriverLinux(container); - // TODO SMART extension - container.attach(driver); - - results.add(container); + var c = ContainerFactory.build(DiskContainerLinux.class, container -> { + container.name = name; + container.path = path; + }, DiskDriverLinux.class, extensions -> { + if (GlobalConfig.get("oshi.driver.extension.smart", true)) + extensions.add(new DiskDriverLinuxSMART()); + }); + + results.add(c); } } @@ -106,11 +112,7 @@ public Stream getDiskStream() { @Override public FirmwareLinux getFirmware() { - var container = new FirmwareContainerLinux(); - var driver = new FirmwareDriverLinux(container); - - container.attach(driver); - return container; + return ContainerFactory.build(FirmwareContainerLinux.class, FirmwareDriverLinux.class); } } diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverMac.java similarity index 98% rename from reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java rename to reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverMac.java index 61d9fad..99563b8 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverMac.java +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverMac.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.system; import java.util.stream.Stream; diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverSolaris.java similarity index 98% rename from reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java rename to reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverSolaris.java index e152aa3..6e09a2e 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverSolaris.java +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverSolaris.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.system; import java.util.stream.Stream; diff --git a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverWindows.java similarity index 98% rename from reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java rename to reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverWindows.java index c7fea4f..a5e03a2 100644 --- a/reference/oshi-core/src/main/java/oshi/driver/SystemDriverWindows.java +++ b/reference/oshi-core/src/main/java/oshi/driver/system/SystemDriverWindows.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package oshi.driver; +package oshi.driver.system; import java.util.stream.Stream; diff --git a/reference/oshi-core/src/main/java/oshi/example/DiskExample.java b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java index 075682f..faadde7 100644 --- a/reference/oshi-core/src/main/java/oshi/example/DiskExample.java +++ b/reference/oshi-core/src/main/java/oshi/example/DiskExample.java @@ -23,18 +23,79 @@ */ package oshi.example; +import static oshi.api.hardware.disk.DiskAttribute.POWER_CYCLES; +import static oshi.api.hardware.disk.DiskAttribute.POWER_ON_TIME; +import static oshi.api.hardware.disk.DiskAttribute.READ_BYTES; +import static oshi.api.hardware.disk.DiskAttribute.SIZE; +import static oshi.api.hardware.disk.DiskAttribute.TEMPERATURE; +import static oshi.api.hardware.disk.DiskAttribute.WRITE_BYTES; + import oshi.api.OSHI; public class DiskExample { public static void main(String[] args) { + example1(); + example2(); + example3(); + example4(); + } + + private static void example1() { + System.out.println("Cross-platform access that makes one query"); + + OSHI.getSystem().getDiskStream().forEach(disk -> { + disk.query(SIZE, READ_BYTES, WRITE_BYTES); + + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.getSize()); + System.out.println("\tRead bytes: " + disk.getReadBytes()); + System.out.println("\tWrite bytes: " + disk.getWriteBytes()); + }); + + System.out.println(); + } + + private static void example2() { + System.out.println("Platform-specific access that makes one query"); + OSHI.getLinuxSystem().getDiskStream().forEach(disk -> { + disk.query(SIZE, READ_BYTES, WRITE_BYTES); + + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tSize: " + disk.getSize()); + System.out.println("\tRead bytes: " + disk.getReadBytes()); + System.out.println("\tWrite bytes: " + disk.getWriteBytes()); + }); + + System.out.println(); + } + + private static void example3() { + System.out.println("Cross-platform access that makes three queries"); + + OSHI.getSystem().getDiskStream().forEach(disk -> { System.out.println("Disk name: " + disk.getName()); System.out.println("\tSize: " + disk.querySize()); System.out.println("\tRead bytes: " + disk.queryReadBytes()); System.out.println("\tWrite bytes: " + disk.queryWriteBytes()); - System.out.println("\tQueue length: " + disk.queryQueueLength()); - System.out.println("\tTransfer time: " + disk.queryTransferTime()); }); + + System.out.println(); + } + + private static void example4() { + System.out.println("Cross-platform access for SMART attributes"); + + OSHI.getSystem().getDiskStream().forEach(disk -> { + disk.query(POWER_CYCLES, POWER_ON_TIME, TEMPERATURE); + + System.out.println("Disk name: " + disk.getName()); + System.out.println("\tPower cycles: " + disk.getPowerCycles()); + System.out.println("\tPower on hours: " + disk.getPowerOnTime()); + System.out.println("\tTemperature: " + disk.getTemperature()); + }); + + System.out.println(); } } diff --git a/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java index af7c201..f22ce12 100644 --- a/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java +++ b/reference/oshi-core/src/main/java/oshi/example/FirmwareExample.java @@ -24,21 +24,35 @@ package oshi.example; import oshi.api.OSHI; +import oshi.api.hardware.firmware.Firmware; +import oshi.api.hardware.firmware.FirmwareLinux; public class FirmwareExample { public static void main(String[] args) { + example1(); + example2(); + } + + private static void example1() { + System.out.println("Cross-platform access"); - var firmware = OSHI.getSystem().getFirmware(); - System.out.println("=== CrossPlatform Firmware ==="); + Firmware firmware = OSHI.getSystem().getFirmware(); System.out.println("Name: " + firmware.getName()); System.out.println("Description: " + firmware.getDescription()); System.out.println("Version: " + firmware.getVersion()); System.out.println("Revision: " + firmware.getRevision()); System.out.println("Release: " + firmware.getReleaseDate()); - var linuxFirmware = OSHI.getLinuxSystem().getFirmware(); - System.out.println("=== Linux Firmware ==="); - System.out.println("UEFI support: " + linuxFirmware.getUefi()); + System.out.println(); + } + + private static void example2() { + System.out.println("Platform-specific access"); + + FirmwareLinux firmware = OSHI.getLinuxSystem().getFirmware(); + System.out.println("UEFI support: " + firmware.getUefi()); + + System.out.println(); } } diff --git a/reference/oshi-core/src/main/java/oshi/example/NicExample.java b/reference/oshi-core/src/main/java/oshi/example/NicExample.java index 3571bd4..250797e 100644 --- a/reference/oshi-core/src/main/java/oshi/example/NicExample.java +++ b/reference/oshi-core/src/main/java/oshi/example/NicExample.java @@ -23,6 +23,12 @@ */ package oshi.example; +import static oshi.api.hardware.nic.NicAttribute.IPV4; +import static oshi.api.hardware.nic.NicAttribute.LINK_SPEED; +import static oshi.api.hardware.nic.NicAttribute.MTU; +import static oshi.api.hardware.nic.NicAttribute.READ_BYTES; +import static oshi.api.hardware.nic.NicAttribute.WRITE_BYTES; + import java.util.Arrays; import oshi.api.OSHI; @@ -30,16 +36,24 @@ public class NicExample { public static void main(String[] args) throws Exception { + example1(); + } + + private static void example1() { + System.out.println("Cross-platform usage that makes one query"); + + OSHI.getSystem().getNicStream().forEach(nic -> { + nic.query(READ_BYTES, WRITE_BYTES, MTU, IPV4, LINK_SPEED); - OSHI.getLinuxSystem().getNicStream().forEach(nic -> { System.out.println("NIC: " + nic.getName()); - System.out.println("\tReadBytes: " + nic.queryReadBytes()); - System.out.println("\tWriteBytes: " + nic.queryWriteBytes()); - System.out.println("\tMTU: " + nic.queryMtu()); - System.out.println("\tIPv4: " + Arrays.toString(nic.queryIpv4())); - System.out.println("\tLink Speed: " + nic.queryLinkSpeed()); + System.out.println("\tReadBytes: " + nic.getReadBytes()); + System.out.println("\tWriteBytes: " + nic.getWriteBytes()); + System.out.println("\tMTU: " + nic.getMtu()); + System.out.println("\tIPv4: " + Arrays.toString(nic.getIpv4())); + System.out.println("\tLink Speed: " + nic.getLinkSpeed()); }); + System.out.println(); } } diff --git a/reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java b/reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java new file mode 100644 index 0000000..4dab27d --- /dev/null +++ b/reference/oshi-core/src/main/java/oshi/old/GlobalConfig.java @@ -0,0 +1,181 @@ +/** + * OSHI (https://github.com/oshi/oshi) + * + * Copyright (c) 2010 - 2019 The OSHI Project Team: + * https://github.com/oshi/oshi/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package oshi.old; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The global configuration utility. See + * {@code src/main/resources/default.properties} for default values. + */ +public final class GlobalConfig { + + private static final Logger LOG = LoggerFactory.getLogger(GlobalConfig.class); + + private static final Properties configuration = new Properties(); + + static { + try (InputStream in = GlobalConfig.class.getResourceAsStream("/default.properties")) { + if (in != null) { + configuration.load(in); + } + } catch (IOException e) { + LOG.warn("Failed to load default configuration"); + } + } + + /** + * Get the {@code String} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static String get(String key, String def) { + return configuration.getProperty(key, def); + } + + /** + * Get the {@code int} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static int get(String key, int def) { + String value = configuration.getProperty(key); + return value == null ? def : ParseUtil.parseIntOrDefault(value, def); + } + + /** + * Get the {@code double} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static double get(String key, double def) { + String value = configuration.getProperty(key); + return value == null ? def : ParseUtil.parseDoubleOrDefault(value, def); + } + + /** + * Get the {@code boolean} property associated with the given key. + * + * @param key + * The property key + * @param def + * The default value + * @return The property value or the given default if not found + */ + public static boolean get(String key, boolean def) { + String value = configuration.getProperty(key); + return value == null ? def : Boolean.parseBoolean(value); + } + + /** + * Set the given property, overwriting any existing value. If the given + * value is {@code null}, the property is removed. + * + * @param key + * The property key + * @param val + * The new value + */ + public static void set(String key, Object val) { + if (val == null) { + configuration.remove(key); + } else { + configuration.setProperty(key, val.toString()); + } + } + + /** + * Reset the given property to its default value. + * + * @param key + * The property key + */ + public static void remove(String key) { + configuration.remove(key); + } + + /** + * Clear the configuration. + */ + public static void clear() { + configuration.clear(); + } + + /** + * Load the given {@link java.util.Properties} into the global + * configuration. + * + * @param properties + * The new properties + */ + public static void load(Properties properties) { + configuration.putAll(properties); + } + + /** + * Indicates that a configuration value is invalid. + */ + public static class PropertyException extends RuntimeException { + + private static final long serialVersionUID = -7482581936621748005L; + + /** + * @param property + * The property name + */ + public PropertyException(String property) { + super("Invalid property: \"" + property + "\" = " + GlobalConfig.get(property, null)); + } + + /** + * @param property + * The property name + * @param message + * An exception message + */ + public PropertyException(String property, String message) { + super("Invalid property \"" + property + "\": " + message); + } + } + + private GlobalConfig() { + } +} diff --git a/reference/oshi-core/src/main/resources/default.properties b/reference/oshi-core/src/main/resources/default.properties new file mode 100644 index 0000000..f181262 --- /dev/null +++ b/reference/oshi-core/src/main/resources/default.properties @@ -0,0 +1,35 @@ +# +# OSHI (https://github.com/oshi/oshi) +# +# Copyright (c) 2010 - 2019 The OSHI Project Team: +# https://github.com/oshi/oshi/graphs/contributors +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# The /proc filesystem location +oshi.util.proc.path=/proc + +# The WMI query timeout in milliseconds (where -1 indicates no timeout) +oshi.util.wmi.timeout=-1 + +# Whether the S.M.A.R.T. extension will be loaded for disk information +oshi.driver.extension.smart=true + +# Whether Java's NetworkInterface class will be loaded for network information +oshi.driver.extension.networkinterface=true \ No newline at end of file