Package me.legrange.service
Class RuntimeEnvironment
java.lang.Object
me.legrange.service.RuntimeEnvironment
A utility class that provides access to OS/runtime environment relate information and operations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of 'thought to be supported' operating systems. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturn the path of the JAR file containing the running application.static StringgetArch()Get the CPU architecture.static Stringstatic intgetCores()Return the number of CPU cores.static RuntimeEnvironment.TypeApply heuristics to determine the OS type from the os.name system property.static Stringstatic booleanDetect if the application is running inside a container.static booleanReturn if IPv4 is supported.static booleanReturn if IPv6 is supported.
-
Method Details
-
isInContainer
public static boolean isInContainer()Detect if the application is running inside a container. This is heuristic based and will need to be expanded for different container framerworks.- Returns:
- True if we thinkk it is in a container
-
getArch
Get the CPU architecture.- Returns:
- The CPU architeture
-
getCores
public static int getCores()Return the number of CPU cores.- Returns:
- The number of cores
-
isIpv6Supported
Return if IPv6 is supported.- Returns:
- True if it is
- Throws:
EnvironmentDetectionException
-
isIpv4Supported
Return if IPv4 is supported.- Returns:
- True if it is
- Throws:
EnvironmentDetectionException
-
getApplicationJarName
Return the path of the JAR file containing the running application.- Returns:
- The path to the JAR
- Throws:
EnvironmentDetectionException
-
getTempDir
-
getComputerName
-
getOsType
Apply heuristics to determine the OS type from the os.name system property.- Returns:
- The OS Type
-