public abstract class AbstractOS extends Object implements OperatingSystem
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractOS.FamilyVersionInfo |
OperatingSystem.OSVersionInfo, OperatingSystem.ProcessSort| Constructor and Description |
|---|
AbstractOS() |
| Modifier and Type | Method and Description |
|---|---|
int |
getBitness()
Gets the bitness (32 or 64) of the operating system.
|
String |
getFamily()
Operating system family.
|
String |
getManufacturer()
Manufacturer.
|
OSProcess |
getProcess(int pid)
Gets information on a currently running process
|
OSProcess[] |
getProcesses()
Gets currently running processes.
|
List<OSProcess> |
getProcesses(Collection<Integer> pids)
Gets information on a currently running processes.
|
List<OSProcess> |
getProcesses(Collection<Integer> pids,
boolean slowFields)
Gets information on a currently running processes.
|
OSProcess[] |
getProcesses(int limit,
OperatingSystem.ProcessSort sort)
Gets currently running processes, optionally limited to the top "N" for a
particular sorting order.
|
OSService[] |
getServices()
Gets the all services on the system.
|
OperatingSystem.OSVersionInfo |
getVersionInfo()
Operating system version information.
|
boolean |
isElevated()
Determine whether the current process has elevated permissions such as sudo /
Administrator
|
protected List<OSProcess> |
processSort(List<OSProcess> processes,
int limit,
OperatingSystem.ProcessSort sort)
Sorts an array of processes using the specified sorting, returning an array
with the top limit results if positive.
|
protected abstract int |
queryBitness(int jvmBitness)
Backup OS-specific query to determine bitness if previous checks fail
|
protected abstract boolean |
queryElevated() |
protected abstract AbstractOS.FamilyVersionInfo |
queryFamilyVersionInfo() |
protected abstract String |
queryManufacturer() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetChildProcesses, getFileSystem, getNetworkParams, getProcess, getProcessAffinityMask, getProcessCount, getProcesses, getProcessId, getSystemBootTime, getSystemUptime, getThreadCountpublic String getManufacturer()
OperatingSystemgetManufacturer in interface OperatingSystemprotected abstract String queryManufacturer()
public String getFamily()
OperatingSystemgetFamily in interface OperatingSystempublic OperatingSystem.OSVersionInfo getVersionInfo()
OperatingSystemgetVersionInfo in interface OperatingSystemprotected abstract AbstractOS.FamilyVersionInfo queryFamilyVersionInfo()
public int getBitness()
OperatingSystemgetBitness in interface OperatingSystemprotected abstract int queryBitness(int jvmBitness)
jvmBitness - The bitness of the JVMpublic boolean isElevated()
OperatingSystemisElevated in interface OperatingSystempublic OSService[] getServices()
OperatingSystemgetServices in interface OperatingSystemOSService objectsprotected abstract boolean queryElevated()
protected List<OSProcess> processSort(List<OSProcess> processes, int limit, OperatingSystem.ProcessSort sort)
processes - The array to sortlimit - The number of results to return if positive; if zero returns all
resultssort - The sorting to use, or nullpublic OSProcess[] getProcesses()
OperatingSystemgetProcesses in interface OperatingSystemOSProcess objects for the
specified number (or all) of currently running processes, sorted as
specified. The array may contain null elements if a process
terminates during iteration. Some fields that are slow to retrieve
(e.g., commandlines and group information on Windows, open files on
Unix and Linux) will be skipped.public OSProcess[] getProcesses(int limit, OperatingSystem.ProcessSort sort)
OperatingSystemgetProcesses in interface OperatingSystemlimit - Max number of results to return, or 0 to return all resultssort - If not null, determines sorting of resultsOSProcess objects for the
specified number (or all) of currently running processes, sorted as
specified. The array may contain null elements if a process
terminates during iteration. Some fields that are slow to retrieve
(e.g., group information on Windows, open files on Unix and Linux)
will be skipped.public List<OSProcess> getProcesses(Collection<Integer> pids)
OperatingSystemgetProcesses in interface OperatingSystempids - A collection of process IDsOSProcess object for the specified
process ids if it is runningpublic List<OSProcess> getProcesses(Collection<Integer> pids, boolean slowFields)
OperatingSystemgetProcesses in interface OperatingSystempids - A collection of process IDsslowFields - If false, skip OSProcess fields that are
slow to retrieve (e.g., group information on Windows, open files
on Unix and Linux). If true, include all fields, regardless of how
long it takes to retrieve the data.OSProcess object for the specified
process ids if it is runningpublic OSProcess getProcess(int pid)
OperatingSystemgetProcess in interface OperatingSystempid - A process IDOSProcess object for the specified
process id if it is running; null otherwiseCopyright © 2019. All rights reserved.