Class Environment

java.lang.Object
clazzfish.monitor.util.Environment

public class Environment extends Object
This class provides some utilities for the access to the environment (e.g. the system properties).

If you need different environments (e.g. for testing) this class is no longer final to be able to derive from it. This class was copied from PatternTesting.

Author:
oliver
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    System property to disable multithreading.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    To be able to use different "environment" this class can now be sub-classed.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    In some JEE environment like Google's App Engine (GAE) it is not allowed to use multi threading.
    static File
    Normally you'll find the local Maven repository at ~/.m2/repository.
    static String
    The name of an environment is derived from the classloader.
    static boolean
    If we are in a Google App Engine (GAE) environment we will return true here.
    static boolean
    Returns true if the given property is set as System property and the value of it is not false.
    static boolean
    If we are inside a Weblogic Server (WLS) we will return true here.
    static boolean
    matchesOneOf(String... props)
    Looks if one of the given properties matches a system property.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DISABLE_THREADS

      public static final String DISABLE_THREADS
      System property to disable multithreading.
      See Also:
  • Constructor Details

    • Environment

      protected Environment()
      To be able to use different "environment" this class can now be sub-classed.
  • Method Details

    • getName

      public static String getName()
      The name of an environment is derived from the classloader. I.e. on a Tomcat server the name is "org.apache.catalina".
      Returns:
      e.g. "com.google.apphosting" for Google App Enginge
    • matchesOneOf

      public static boolean matchesOneOf(String... props)
      Looks if one of the given properties matches a system property. If one system property is found and this system property is not "false" true is returned.
      Parameters:
      props - the properties to be checked
      Returns:
      true if one of the given properties exist (and are not "false")
    • isPropertyEnabled

      public static boolean isPropertyEnabled(String key)
      Returns true if the given property is set as System property and the value of it is not false.
      Parameters:
      key - e.g. "clazzfish.runTestsParallel"
      Returns:
      true if property is set
    • areThreadsAllowed

      public static boolean areThreadsAllowed()
      In some JEE environment like Google's App Engine (GAE) it is not allowed to use multi threading. But you can also disable multi threading by setting the system property DISABLE_THREADS.
      Returns:
      normally true
    • isGoogleAppEngine

      public static boolean isGoogleAppEngine()
      If we are in a Google App Engine (GAE) environment we will return true here.
      Returns:
      true if application runs on GAE
    • isWeblogicServer

      public static boolean isWeblogicServer()
      If we are inside a Weblogic Server (WLS) we will return true here. We look only for the system property "weblogic.Name" here. Another possibility (not realized) would be to look at the classloader.
      Returns:
      true inside Weblogic Server
    • getLocalMavenRepositoryDir

      public static File getLocalMavenRepositoryDir() throws IOException
      Normally you'll find the local Maven repository at ~/.m2/repository. But on cloudbees it is the local .repository directory. So we try to find out here which one we should use.
      Returns:
      the root dir of the local Maven repository
      Throws:
      IOException - Signals that an I/O exception has occurred.