Class MsftNetAdapterToIpAndDnsAndProfileService

java.lang.Object
io.github.eggy03.ferrumx.windows.service.compounded.MsftNetAdapterToIpAndDnsAndProfileService
All Implemented Interfaces:
CommonServiceInterface<MsftNetAdapterToIpAndDnsAndProfile>

public class MsftNetAdapterToIpAndDnsAndProfileService extends Object implements CommonServiceInterface<MsftNetAdapterToIpAndDnsAndProfile>
Service class for fetching net adapter, ip, dns and profile configuration information from the system.

This class executes the ScriptEnum.MSFT_NET_ADAPTER_TO_IP_AND_DNS_AND_PROFILE script and maps the resulting JSON into an immutable list of MsftNetAdapterToIpAndDnsAndProfile objects.

Usage examples

// Convenience API (creates its own short-lived session)
MsftNetAdapterToIpAndDnsAndProfileService service = new MsftNetAdapterToIpAndDnsAndProfileService();
List<MsftNetAdapterToIpAndDnsAndProfile> compoundAdapters = service.get();

// API with re-usable session (caller manages session lifecycle)
try (PowerShell session = PowerShell.openSession()) {
    List<MsftNetAdapterToIpAndDnsAndProfile> compoundAdapters = service.get(session);
}

// API with execution timeout (auto-created session is terminated if the timeout is exceeded)
MsftNetAdapterToIpAndDnsAndProfileService service = new MsftNetAdapterToIpAndDnsAndProfileService();
List<MsftNetAdapterToIpAndDnsAndProfile> compoundAdapters = service.get(10);

Execution models and concurrency

This service supports multiple PowerShell execution strategies:

  • jPowerShell-based execution via get() and get(PowerShell):
    These methods rely on jPowerShell sessions. Due to internal global configuration of jPowerShell, 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 on jPowerShell and instead, launches a standalone PowerShell process per invocation using TerminalUtility. 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
See Also: