Class OperatingSystemService
java.lang.Object
io.github.eggy03.ferrumx.windows.service.os.OperatingSystemService
- All Implemented Interfaces:
CommonServiceInterface<OperatingSystem>
public class OperatingSystemService
extends Object
implements CommonServiceInterface<OperatingSystem>
Service class for fetching operating system information from the system.
This class executes the CimQuery.OPERATING_SYSTEM_QUERY
PowerShell command
and maps the resulting JSON into a list of OperatingSystem
objects.
Thread safety
Methods of class are not thread safe.Usage examples
// Convenience API (creates its own short-lived session)
OperatingSystemService osService = new OperatingSystemService();
List<OperatingSystem> operatingSystems = osService.get();
// API with re-usable session (caller manages session lifecycle)
try (PowerShell session = PowerShell.openSession()) {
OperatingSystemService osService = new OperatingSystemService();
List<OperatingSystem> operatingSystems = osService.get(session);
}
- Since:
- 2.0.0
- Author:
- Egg-03
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull List
<OperatingSystem> get()
Retrieves a list of operating systems present on the system.@NotNull List
<OperatingSystem> get
(com.profesorfalken.jpowershell.PowerShell powerShell) Retrieves a list of operating systems using the caller'sPowerShell
session.
-
Constructor Details
-
OperatingSystemService
public OperatingSystemService()
-
-
Method Details
-
get
Retrieves a list of operating systems present on the system.Each invocation creates and uses a short-lived PowerShell session internally.
- Specified by:
get
in interfaceCommonServiceInterface<OperatingSystem>
- Returns:
- a list of
OperatingSystem
objects representing the system's operating systems. Returns an empty list if none are detected.
-
get
@NotNull public @NotNull List<OperatingSystem> get(com.profesorfalken.jpowershell.PowerShell powerShell) Retrieves a list of operating systems using the caller'sPowerShell
session.- Specified by:
get
in interfaceCommonServiceInterface<OperatingSystem>
- Parameters:
powerShell
- an existing PowerShell session managed by the caller- Returns:
- a list of
OperatingSystem
objects representing the system's operating systems. Returns an empty list if none are detected.
-