Class MonitorService
java.lang.Object
io.github.eggy03.ferrumx.windows.service.display.MonitorService
- All Implemented Interfaces:
CommonServiceInterface<Monitor>
Service class for fetching monitor information from the system.
This class executes the CimQuery.MONITOR_QUERY PowerShell command
and maps the resulting JSON into a list of Monitor objects.
Thread safety
Methods of class are not thread safe.Usage examples
// Convenience API (creates its own short-lived session)
MonitorService monitorService = new MonitorService();
List<Monitor> monitors = monitorService.get();
// API with re-usable session (caller manages session lifecycle)
try (PowerShell session = PowerShell.openSession()) {
List<Monitor> monitors = monitorService.get(session);
}
- Since:
- 2.0.0
- Author:
- Egg-03
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
MonitorService
public MonitorService()
-
-
Method Details
-
get
Retrieves a list of monitors connected to the system.Each invocation creates and uses a short-lived PowerShell session internally.
- Specified by:
getin interfaceCommonServiceInterface<Monitor>- Returns:
- a list of
Monitorobjects representing connected monitors. Returns an empty list if no monitors are detected. - Throws:
com.google.gson.JsonSyntaxException- if there is an error executing the PowerShell command or parsing the output.
-
get
Retrieves a list of monitors connected to the system using the caller'sPowerShellsession.- Specified by:
getin interfaceCommonServiceInterface<Monitor>- Parameters:
powerShell- an existing PowerShell session managed by the caller- Returns:
- a list of
Monitorobjects representing connected monitors. Returns an empty list if no monitors are detected. - Throws:
com.google.gson.JsonSyntaxException- if there is an error executing the PowerShell command or parsing the output.
-