Class ProcessorService

java.lang.Object
io.github.eggy03.ferrumx.windows.service.processor.ProcessorService
All Implemented Interfaces:
CommonServiceInterface<Processor>

public class ProcessorService extends Object implements CommonServiceInterface<Processor>
Service class for fetching CPU information from the system.

This class executes the CimQuery.PROCESSOR_QUERY PowerShell command and maps the resulting JSON into Processor objects.

Thread safety

Methods of class are not thread safe.

Usage examples


 // Convenience API (creates its own short-lived session)
 ProcessorService processorService = new ProcessorService();
 List<Processor> processors = processorService.getManaged();

 // API with re-usable session (caller manages session lifecycle)
 try (PowerShell session = PowerShell.openSession()) {
     ProcessorService processorService = new ProcessorService();
     List<Processor> processors = processorService.get(session);
 }
 
Since:
2.0.0
Author:
Egg-03
  • Constructor Details

    • ProcessorService

      public ProcessorService()
  • Method Details

    • get

      @NotNull public @NotNull List<Processor> get()
      Retrieves a non-null list of processor entries present in the system.

      Each invocation creates and uses a short-lived PowerShell session internally.

      Specified by:
      get in interface CommonServiceInterface<Processor>
      Returns:
      a list of Processor objects representing the CPU(s). Returns an empty list if no processors are detected.
    • get

      @NotNull public @NotNull List<Processor> get(com.profesorfalken.jpowershell.PowerShell powerShell)
      Retrieves a non-null list of processor entries using the caller's PowerShell session.
      Specified by:
      get in interface CommonServiceInterface<Processor>
      Parameters:
      powerShell - an existing PowerShell session managed by the caller
      Returns:
      a list of Processor objects representing the CPU(s). Returns an empty list if no processors are detected.