Class Bootstrap

  • Direct Known Subclasses:
    InstallerBootstrap

    public abstract class Bootstrap
    extends Object
    Bootstrap application for starting OpenNMS.
    • Constructor Detail

      • Bootstrap

        public Bootstrap()
    • Method Detail

      • loadClasses

        public static ClassLoader loadClasses​(String dirStr,
                                              boolean recursive,
                                              boolean append)
                                       throws MalformedURLException
        Create a ClassLoader with the JARs found in dirStr.
        Parameters:
        dirStr - List of directories to search for JARs, separated by File.pathSeparator.
        recursive - Whether to recurse into subdirectories of the directories in dirStr.
        append - Append the URLs of the current {@link java.lang.Thread#getContextClassLoader()) to this classloader.
        Returns:
        a ClassLoader object.
        Throws:
        MalformedURLException - if any.
      • loadClasses

        public static ClassLoader loadClasses​(File dir,
                                              boolean recursive)
                                       throws MalformedURLException
        Create a ClassLoader with the JARs found in dir.
        Parameters:
        dir - Directory to search for JARs
        recursive - Whether to recurse into subdirectories of dir
        Returns:
        a ClassLoader object.
        Throws:
        MalformedURLException - if any.
      • newClassLoader

        public static ClassLoader newClassLoader​(List<URL> urls)
        Create a ClassLoader with the list of URLs found in urls.
        Parameters:
        urls - List of URLs to add to the ClassLoader's search list.
        Returns:
        a ClassLoader object.
      • loadClasses

        public static void loadClasses​(File dir,
                                       boolean recursive,
                                       List<URL> urls)
                                throws MalformedURLException
        Add JARs found in dir to the LinkedList urls.
        Parameters:
        dir - Directory to search for JARs
        recursive - Whether to recurse into subdirectories of the directory in dir
        urls - LinkedList to append found JARs onto
        Throws:
        MalformedURLException - if any.
      • getPropertiesFiles

        protected static List<File> getPropertiesFiles​(File opennmsHome)
        Retrieves the list of configuration files containing system properties to be set. The system properties must be set in the same order as they are returned here.
        Parameters:
        opennmsHome - the OpenNMS home directory
        Returns:
        a list of property files
      • loadSystemProperties

        protected static void loadSystemProperties​(File opennmsHome)
                                            throws IOException
        Load default properties from the specified OpenNMS home into the system properties.
        Parameters:
        opennmsHome - the OpenNMS home directory
        Throws:
        IOException
      • isValidOpenNMSHome

        protected static boolean isValidOpenNMSHome​(File opennmsHome)
        Validates the OpenNMS home directory by checking for known mandatory files.
        Parameters:
        opennmsHome - the OpenNMS home directory
        Returns:
        true is the opennmsHome folder is a valid OpenNMS home directory
      • findOpenNMSHome

        protected static File findOpenNMSHome()
                                       throws Exception
        Find the OpenNMS home directory.
        Throws:
        Exception
      • findOpenNMSHomeUsingJarPath

        public static File findOpenNMSHomeUsingJarPath()
        Determine the OpenNMS home directory based on the location of the JAR file containing this code. Finds the JAR file containing this code, and if it is found, the file name of the JAR (e.g.: opennms_bootstrap.jar) and its parent directory (e.g.: the lib directory) are removed from the path and the resulting path (e.g.: /opt/OpenNMS) is returned.
        Returns:
        Home directory or null if it couldn't be found
      • main

        public static void main​(String[] args)
                         throws Exception
        Bootloader main method. Takes the following steps to initialize a ClassLoader, set properties, and start OpenNMS:
        • Checks for existence of opennms.home system property, and loads properties file located at ${opennms.home}/etc/bootstrap.properties if it exists.
        • Calls findOpenNMSHome to determine the OpenNMS home directory if the bootstrap.properties file has not yet been loaded. Sets the opennms.home system property to the path returned from findOpenNMSHome.
        • Calls loadClasses to create a new ClassLoader. ${opennms.home}/etc and ${opennms.home}/lib are passed to loadClasses.
        • Determines the proper default value for configuration options when overriding system properties have not been set. Below are the default values.
          • opennms.library.jicmp: ClassLoader.getResource(System.mapLibraryName("jicmp"))
          • opennms.library.jrrd: ClassLoader.getResource(System.mapLibraryName("jrrd"))
          • log4j.configuration: "log4j.properties"
          • jcifs.properties: ClassLoader.getResource("jcifs.properties")
        • Finally, the main method of org.opennms.netmgt.vmmgr.Controller is invoked with the parameters passed in argv.
        Parameters:
        args - Command line arguments
        Throws:
        Exception - if any.