Class ApplicationUtils


  • public abstract class ApplicationUtils
    extends java.lang.Object
    This class provides functionality for starting applications.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int EXCEPTION_WHEN_ADDING_MANAGEMENT
      System.exit() value for the case where the management registration for the application could not be started.
      static int EXCEPTION_WHEN_ADDING_SHUTDOWN_HOOK
      System.exit() value for the case where the Shutdown Hook for the application could not be added.
      static int EXCEPTION_WHILE_INSTANTIATING
      System.exit() value for the case where the application class could not be instantiated.
      static int NO_FACTORY_METHOD
      System.exit() value for the case where the application does not have a factory method.
      static int WRONG_ARGUMENTS
      System.exit() value for the case where wrong arguments are given.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void dirMustExist​(java.io.File dir)
      Ensure that a directory is available and writable.
      static void startApp​(LifeCycleComponent component)
      Starts up an LifeCycleComponent.
      static void startApp​(java.lang.Class c, java.lang.String[] args)
      Starts up an application.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • startApp

        public static void startApp​(java.lang.Class c,
                                    java.lang.String[] args)
        Starts up an application. The applications class must: (i) Have a static getInstance() method which returns a an instance of itself. (ii) Implement CleanupIF. If the class cannot be started and a shutdown hook added, the JVM exits with a return code depending on the problem: 1 means wrong arguments 2 means no factory method exists for class 3 means couldn't instantiate class 4 means couldn't add shutdown hook 5 means couldn't add liveness logger 6 means couldn't add remote management
        Parameters:
        c - The class to be started.
        args - The arguments to the application (should be empty).
      • startApp

        public static void startApp​(LifeCycleComponent component)
        Starts up an LifeCycleComponent.
        Parameters:
        component - The component to start.
      • dirMustExist

        public static void dirMustExist​(java.io.File dir)
        Ensure that a directory is available and writable. Will warn if the directory doesn't already exist (it ought to be created by the install script) and throws a PermissionDenied exception if the directory cannot be created.
        Parameters:
        dir - A File object denoting a directory.
        Throws:
        PermissionDenied - if the directory doesn't exist and cannot be created/written to, or if the File object indicates an existing non-directory.