Package me.legrange.service
Class RuntimeEnvironment
- java.lang.Object
-
- me.legrange.service.RuntimeEnvironment
-
public final class RuntimeEnvironment extends Object
A utility class that provides access to OS/runtime environment relate information and operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRuntimeEnvironment.TypeTypes of 'thought to be supported' operating systems.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetApplicationJarName()Return the path of the JAR file containing the running application.static StringgetArch()Get the CPU architecture.static StringgetComputerName()static intgetCores()Return the number of CPU cores.static RuntimeEnvironment.TypegetOsType()Apply heuristics to determine the OS type from the os.name system property.static StringgetTempDir()static booleanisInContainer()Detect if the application is running inside a container.static booleanisIpv4Supported()Return if IPv4 is supported.static booleanisIpv6Supported()Return if IPv6 is supported.
-
-
-
Method Detail
-
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
public static String 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
public static boolean isIpv6Supported() throws EnvironmentDetectionExceptionReturn if IPv6 is supported.- Returns:
- True if it is
- Throws:
EnvironmentDetectionException
-
isIpv4Supported
public static boolean isIpv4Supported() throws EnvironmentDetectionExceptionReturn if IPv4 is supported.- Returns:
- True if it is
- Throws:
EnvironmentDetectionException
-
getApplicationJarName
public static String getApplicationJarName() throws EnvironmentDetectionException
Return the path of the JAR file containing the running application.- Returns:
- The path to the JAR
- Throws:
EnvironmentDetectionException
-
getTempDir
public static String getTempDir()
-
getComputerName
public static String getComputerName()
-
getOsType
public static RuntimeEnvironment.Type getOsType()
Apply heuristics to determine the OS type from the os.name system property.- Returns:
- The OS Type
-
-