Class Win32AssociatedProcessorMemoryService
java.lang.Object
io.github.eggy03.ferrumx.windows.service.processor.Win32AssociatedProcessorMemoryService
- All Implemented Interfaces:
CommonServiceInterface<Win32AssociatedProcessorMemory>
public class Win32AssociatedProcessorMemoryService
extends Object
implements CommonServiceInterface<Win32AssociatedProcessorMemory>
Service class for fetching the association between a Processor, and it's Cache information from the system.
This class executes the Cimv2.WIN32_ASSOCIATED_PROCESSOR_MEMORY PowerShell command
and maps the resulting JSON into an immutable list of Win32AssociatedProcessorMemory objects.
Usage examples
// Convenience API (creates its own short-lived session)
Win32AssociatedProcessorMemoryService service = new Win32AssociatedProcessorMemoryService();
List<Win32AssociatedProcessorMemory> apm = service.get();
// API with re-usable session (caller manages session lifecycle)
try (PowerShell session = PowerShell.openSession()) {
Win32AssociatedProcessorMemoryService service = new Win32AssociatedProcessorMemoryService();
List<Win32AssociatedProcessorMemory> apm = service.get(session);
}
// API with execution timeout (auto-created session is terminated if the timeout is exceeded)
Win32AssociatedProcessorMemoryService service = new Win32AssociatedProcessorMemoryService();
List<Win32AssociatedProcessorMemory> apm = service.get(10);
Execution models and concurrency
This service supports multiple PowerShell execution strategies:
-
jPowerShell-based execution via
get()andget(PowerShell):
These methods rely onjPowerShellsessions. Due to internal global configuration ofjPowerShell, the PowerShell sessions launched by it is not safe to use concurrently across multiple threads or executors. Running these methods in parallel may result in runtime exceptions. -
Isolated PowerShell execution via
get(long timeout):
This method doesn't rely onjPowerShelland instead, launches a standalone PowerShell process per invocation usingTerminalUtility. Each call is fully isolated and safe to use in multithreaded and executor-based environments.
For concurrent or executor-based workloads, prefer get(long timeout).
- Since:
- 3.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull @Unmodifiable List<Win32AssociatedProcessorMemory> get()Retrieves an immutable list ofWin32AssociatedProcessorMemoryentities present in the system.@NotNull @Unmodifiable List<Win32AssociatedProcessorMemory> get(long timeout) Retrieves an immutable list ofWin32AssociatedProcessorMemoryentities using an isolated PowerShell process with a configurable timeout.@NotNull @Unmodifiable List<Win32AssociatedProcessorMemory> get(@NonNull com.profesorfalken.jpowershell.PowerShell powerShell) Retrieves an immutable list ofWin32AssociatedProcessorMemoryentities using the caller'sPowerShellsession.
-
Constructor Details
-
Win32AssociatedProcessorMemoryService
public Win32AssociatedProcessorMemoryService()
-
-
Method Details
-
get
Retrieves an immutable list ofWin32AssociatedProcessorMemoryentities present in the system.Each invocation creates and uses a short-lived PowerShell session internally.
- Specified by:
getin interfaceCommonServiceInterface<Win32AssociatedProcessorMemory>- Returns:
- an immutable list of
Win32AssociatedProcessorMemoryobjects representing the association between aWin32Processorand it'sWin32CacheMemory. Returns an empty list if none are detected. - Since:
- 3.0.0
-
get
@UsesJPowerShell @NotNull public @NotNull @Unmodifiable List<Win32AssociatedProcessorMemory> get(@NonNull @NonNull com.profesorfalken.jpowershell.PowerShell powerShell) Retrieves an immutable list ofWin32AssociatedProcessorMemoryentities using the caller'sPowerShellsession.Each invocation creates and uses a short-lived PowerShell session internally.
- Specified by:
getin interfaceCommonServiceInterface<Win32AssociatedProcessorMemory>- Parameters:
powerShell- the caller-managed PowerShell session passed to the method- Returns:
- an immutable list of
Win32AssociatedProcessorMemoryobjects representing the association between aWin32Processorand it'sWin32CacheMemory. Returns an empty list if none are detected. - Since:
- 3.0.0
-
get
@IsolatedPowerShell @NotNull public @NotNull @Unmodifiable List<Win32AssociatedProcessorMemory> get(long timeout) Retrieves an immutable list ofWin32AssociatedProcessorMemoryentities using an isolated PowerShell process with a configurable timeout.Each invocation creates an isolated PowerShell process, which is pre-maturely terminated if execution exceeds the specified timeout.
- Specified by:
getin interfaceCommonServiceInterface<Win32AssociatedProcessorMemory>- Parameters:
timeout- the maximum time (in seconds) to wait for the PowerShell command to complete before terminating the process- Returns:
- an immutable list of
Win32AssociatedProcessorMemoryobjects representing the association between aWin32Processorand it'sWin32CacheMemory. Returns an empty list if none are detected. - Since:
- 3.1.0
-