Class SystemManagerLinux

java.lang.Object
  extended by SystemManager
      extended by SystemManagerLinux

public class SystemManagerLinux
extends SystemManager

Linux implementation of SystemManager.

Noone should now about this class unless one intends to port it to another operating system.

Use SystemManager.getSystemManager to get OS-specific implementation.

See Also:
SystemManager

Constructor Summary
protected SystemManagerLinux()
           
 
Method Summary
 void closeProcessHandle(int handle)
          Closes a process handle (which was opened by openProcessHandle).
 int fetchProcessIDs(int[] pids)
          Fills the integer array with PIDs (process identifiers) of currently running processes.
 boolean fetchProcessStatus(int h, ProcessStatus ps)
          Fills the ps structure with process status information.
 boolean fetchSystemMemoryStatus(SystemMemoryStatus sms)
          Fills the sms structure with system memory status information.
 String getProcessName(int hProcess)
          Retrieves the name of executable referenced by process handle.
 int openProcessHandle(int processID)
          Opens a handle to a process with given identifier.
 
Methods inherited from class SystemManager
getProcessStatus, getSystemManager, getSystemMemoryStatus, loadTmpLibrary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemManagerLinux

protected SystemManagerLinux()
Method Detail

fetchSystemMemoryStatus

public boolean fetchSystemMemoryStatus(SystemMemoryStatus sms)
Description copied from class: SystemManager
Fills the sms structure with system memory status information. The method call may fail due to sms being null, or for technical implementation reasons. sms structure will not reflect the system status if the call fails.

Specified by:
fetchSystemMemoryStatus in class SystemManager
Parameters:
sms - the SystemMemoryStatus object, should not be null.
Returns:
true if successfull, otherwise false.
See Also:
SystemMemoryStatus

fetchProcessStatus

public boolean fetchProcessStatus(int h,
                                  ProcessStatus ps)
Description copied from class: SystemManager
Fills the ps structure with process status information. After the succesfull call, ps structure reflects the status information about given process. The call may fail due to bad handle, ps being null or other technical implementation reasons (e.g. security).

Specified by:
fetchProcessStatus in class SystemManager
Parameters:
h - (OS specific) handle to a process, created from openProcessHandle.
ps - ProcessStatus object, should not be null.
Returns:
true if successfull, otherwise false.
See Also:
SystemManager.openProcessHandle(int), ProcessStatus

openProcessHandle

public int openProcessHandle(int processID)
Description copied from class: SystemManager
Opens a handle to a process with given identifier. Some OSs (e.g. Windows) provide access to process information through handles, which is a nice feature since it keeps the status information available even if the process has terminated. The handle should be closed with closeProcessHandle when it's no longer needed.

Specified by:
openProcessHandle in class SystemManager
Parameters:
processID - (host OS specific) process identifier.
Returns:
integer representing process handle upon success, 0 otherwise.
See Also:
SystemManager.closeProcessHandle(int)

closeProcessHandle

public void closeProcessHandle(int handle)
Description copied from class: SystemManager
Closes a process handle (which was opened by openProcessHandle).

Specified by:
closeProcessHandle in class SystemManager
Parameters:
handle - the open process handle.
See Also:
SystemManager.openProcessHandle(int)

fetchProcessIDs

public int fetchProcessIDs(int[] pids)
Description copied from class: SystemManager
Fills the integer array with PIDs (process identifiers) of currently running processes. The array should not be null but initialized with a length of estimated maximum number of processes. It is difficult to predict exact number of running processes (this is the official position of Windows API) so the array should be large enough to incorporate them all. The excess PIDs will be trimmed, so if the return value is the same as the length of the array, then consider enlarging the array and calling again.

Specified by:
fetchProcessIDs in class SystemManager
Parameters:
pids - non-null array of integers to be filled with PIDs.
Returns:
the number of PIDs put into arrray.

getProcessName

public String getProcessName(int hProcess)
Description copied from class: SystemManager
Retrieves the name of executable referenced by process handle. The call may fail if invalid handle is given or there are technical problems (e.g. security obstacles) while retrieving the information.

Specified by:
getProcessName in class SystemManager
Parameters:
hProcess - is a handle to a process created by openProcessHandle.
Returns:
the name of a process executable upon success, null otherwise.


© 2007 Marius Mikucionis