Package io.microsphere.management
Class ManagementUtils
- java.lang.Object
-
- io.microsphere.management.ManagementUtils
-
- All Implemented Interfaces:
Utils
public abstract class ManagementUtils extends java.lang.Object implements Utils
Utility class for management-related operations- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ProcessIdResolver
,ServiceLoaderUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
getCurrentProcessId()
Get the process ID of current JVM
-
-
-
Method Detail
-
getCurrentProcessId
public static long getCurrentProcessId()
Get the process ID of current JVMExample Usage
// Get the current process ID long pid = ManagementUtils.getCurrentProcessId(); if (pid != -1) { System.out.println("Current Process ID: " + pid); } else { System.out.println("Failed to resolve process ID."); }
This class uses the ServiceLoader pattern to discover and load all available implementations of
ProcessIdResolver
, and selects the most appropriate one based on support and priority. If no resolver can determine the process ID, it defaults toProcessIdResolver.UNKNOWN_PROCESS_ID
.- Returns:
- If can't get the process ID , return
-1
-
-