Class AbstractInstalledLocalContainer

    • Method Detail

      • setLogger

        public void setLogger​(Logger logger)
        Overriden in order to set the logger on ancillary components.
        Specified by:
        setLogger in interface Loggable
        Overrides:
        setLogger in class LoggedObject
        Parameters:
        logger - the logger to set and set in the ancillary objects
      • getHttpUtils

        protected final HttpUtils getHttpUtils()
        Returns:
        the HTTP utility class
      • getAntUtils

        protected final AntUtils getAntUtils()
        Returns:
        the Ant utility class
      • getResourceUtils

        protected final ResourceUtils getResourceUtils()
        Returns:
        the Resource utility class
      • setHome

        public void setHome​(String home)
        Specified by:
        setHome in interface InstalledLocalContainer
        Parameters:
        home - the directory where the container is installed. Note that we're passing a String instead of a File because we want to leave the possibility of using URIs for specifying the home location. IMPORTANT: While some containers can deal with this parameter being set as a relative path, some others require this path to be set to an absolute directory. Please refer to the documentation of the server to ensure you give the path in the appropriate way. If in doubt, you can use absolute paths -that is known to work with all containers.
      • setExtraClasspath

        public void setExtraClasspath​(String[] classpath)
        Specified by:
        setExtraClasspath in interface SpawnedContainer
        Parameters:
        classpath - the extra classpath that is added to the container's classpath when it is started.
      • getExtraClasspath

        public String[] getExtraClasspath()
        Specified by:
        getExtraClasspath in interface SpawnedContainer
        Returns:
        the extra classpath that is added to the container's classpath when it is started.
      • setSharedClasspath

        public void setSharedClasspath​(String[] classpath)
        Specified by:
        setSharedClasspath in interface SpawnedContainer
        Parameters:
        classpath - the shared classpath that is shared by the container applications.
      • getHome

        public String getHome()
        Specified by:
        getHome in interface InstalledLocalContainer
        Returns:
        the directory where the container is installed. Note that we're returning a String instead of a File because we want to leave the possibility of using URIs for specifying the home location.
      • setJvmLauncherFactory

        public void setJvmLauncherFactory​(JvmLauncherFactory jvmLauncherFactory)
        Sets the factory used to spawn the container JVM.
        Specified by:
        setJvmLauncherFactory in interface SpawnedContainer
        Parameters:
        jvmLauncherFactory - The factory used to spawn the container JVM, must not be null.
      • doStart

        protected abstract void doStart​(JvmLauncher java)
                                 throws Exception
        Implementation of RunnableContainer.start() that all containers extending this class must implement.
        Parameters:
        java - the predefined JVM launcher to use to start the container
        Throws:
        Exception - if any error is raised during the container start
      • doStop

        protected abstract void doStop​(JvmLauncher java)
                                throws Exception
        Implementation of RunnableContainer.stop() that all containers extending this class must implement.
        Parameters:
        java - the predefined JVM launcher to use to stop the container
        Throws:
        Exception - if any error is raised during the container stop
      • startInternal

        protected void startInternal()
                              throws Exception
        Installed and Embedded containers do not have the same signature for their doStart method. Thus we need to abstract it.
        Specified by:
        startInternal in class AbstractLocalContainer
        Throws:
        Exception - if any error is raised during the container start
      • stopInternal

        protected void stopInternal()
                             throws Exception
        Installed and Embedded containers do not have the same signature for their doStop method. Thus we need to abstract it.
        Specified by:
        stopInternal in class AbstractLocalContainer
        Throws:
        Exception - if any error is raised during the container stop
      • forceStopInternal

        protected final void forceStopInternal()
        Some containers may not fully stop and need to be forcibly stopped. This method should be overridden for containers that support forcibly stopping the container.
        Overrides:
        forceStopInternal in class AbstractLocalContainer
      • createJvmLauncher

        protected JvmLauncher createJvmLauncher​(boolean server)
        Creates a preinitialized instance of a JVM launcher to be used for starting, stopping and controlling the container.
        Parameters:
        server - true to launch a server process, false to launch a client/utility process.
        Returns:
        The created JVM launcher, never null.
      • getJavaHome

        protected String getJavaHome()
        Gets the Java home directory to use for this container.
        Returns:
        The Java home directory to use, never null.
      • setJvmToLaunchContainerIn

        public void setJvmToLaunchContainerIn​(JvmLauncher java)
        Determines which java virtual machine will run the container.
        Parameters:
        java - the java command that will start the container
      • addToolsJarToClasspath

        protected final void addToolsJarToClasspath​(JvmLauncher java)
                                             throws FileNotFoundException
        Adds the tools.jar to the classpath, except for Mac OSX and Java 9 or above - As these JVMs do not need the tools.jar.
        Parameters:
        java - the JVM launcher to which to add the tools.jar
        Throws:
        FileNotFoundException - in case the tools.jar file cannot be found
      • addExtraClasspath

        protected void addExtraClasspath​(JvmLauncher java)
        Add extra container classpath entries specified by the user.
        Parameters:
        java - the java command used to start/stop the container
      • addRuntimeArgs

        protected void addRuntimeArgs​(JvmLauncher java)
        Add command line arguments to the java command.
        Parameters:
        java - The java command
      • addMemoryArguments

        protected void addMemoryArguments​(JvmLauncher java)
        Adds the JVM memory arguments.
        Parameters:
        java - the predefined JVM launcher on which to add memory-related arguments
      • verify

        protected void verify()
        Verify required properties have been set before executing any action.
        Overrides:
        verify in class AbstractLocalContainer
      • addExtraClasspath

        public void addExtraClasspath​(String location)
        Specified by:
        addExtraClasspath in interface SpawnedContainer
        Parameters:
        location - the extra classpath that is added to the container's classpath when it is started.
      • addSharedClasspath

        public void addSharedClasspath​(String location)
        Specified by:
        addSharedClasspath in interface SpawnedContainer
        Parameters:
        location - the shared classpath that is added to the container's classpath when it is started.
      • ifPresentAddPathToList

        public void ifPresentAddPathToList​(String location,
                                           List<String> list)
        adds the location to the list, if the file exists.
        Parameters:
        location - path to add to the list
        list - where to append this path