Class AbstractStandaloneLocalConfiguration

    • Method Detail

      • performXmlReplacements

        protected void performXmlReplacements​(LocalContainer container)
        Perform the XML replacements for the specified container.
        Parameters:
        container - the container to configure
      • setupConfigurationDir

        protected void setupConfigurationDir()
                                      throws IOException
        Set up the configuration directory (create it and clean it). We clean it because we want to be sure the container starts with the same set up every time and there's no side effects introduced by a previous run or someone modifying some files in there.

        Note: We only clean the configuration directory if it's empty or if there is a Cargo timestamp file. This is to prevent deleting not empty directories if the user has mistakenly pointed the configuration dir to an existing location.

        Throws:
        IOException - if the directory cannot be created
      • addXmlReplacement

        public void addXmlReplacement​(String filename,
                                      String xpathExpression,
                                      String configurationPropertyName)
        Adds an XML replacement.
        Specified by:
        addXmlReplacement in interface StandaloneLocalConfiguration
        Parameters:
        filename - File in which to replace.
        xpathExpression - XPath expression to look for.
        configurationPropertyName - Name of the configuration property to set. The XML replacement will be ignored if the property is set to null.
      • addXmlReplacement

        public void addXmlReplacement​(String filename,
                                      String xpathExpression,
                                      String attributeName,
                                      String configurationPropertyName)
        Adds an XML replacement.
        Specified by:
        addXmlReplacement in interface StandaloneLocalConfiguration
        Parameters:
        filename - File in which to replace.
        xpathExpression - XPath expression to look for.
        attributeName - Attribute name to modify. If null, the node's contents will be modified.
        configurationPropertyName - Name of the configuration property to set. The XML replacement will be ignored if the property is set to null.
      • addXmlReplacement

        public void addXmlReplacement​(String filename,
                                      String xpathExpression,
                                      String attributeName,
                                      String configurationPropertyName,
                                      XmlReplacement.ReplacementBehavior replacementBehavior)
        Adds an XML replacement.
        Specified by:
        addXmlReplacement in interface StandaloneLocalConfiguration
        Parameters:
        filename - File in which to replace.
        xpathExpression - XPath expression to look for.
        attributeName - Attribute name to modify. If null, the node's contents will be modified.
        configurationPropertyName - Name of the configuration property to set. The XML replacement will be ignored if the property is set to null.
        replacementBehavior - Behavior if XPath expression doesn't match anything.
      • removeXmlReplacement

        public void removeXmlReplacement​(String filename,
                                         String xpathExpression)
        Removes an XML replacement.
        Specified by:
        removeXmlReplacement in interface StandaloneLocalConfiguration
        Parameters:
        filename - File in which to replace.
        xpathExpression - XPath expression to look for.
      • removeXmlReplacement

        public void removeXmlReplacement​(String filename,
                                         String xpathExpression,
                                         String attributeName)
        Removes an XML replacement.
        Specified by:
        removeXmlReplacement in interface StandaloneLocalConfiguration
        Parameters:
        filename - File in which to replace.
        xpathExpression - XPath expression to look for.
        attributeName - Attribute name to modify. If null, the node's contents will be modified.
      • verify

        public void verify()
        Verify that the configuration is valid. The checks to be performed may vay whether this is standalone or existing configuration. This method should also be used to verify that the configuration properties specified by the user are valid and that the required ones are set.
        Specified by:
        verify in interface ContainerConfiguration
        Overrides:
        verify in class AbstractLocalConfiguration
      • configureFiles

        protected void configureFiles​(org.apache.tools.ant.types.FilterChain filterChain,
                                      LocalContainer container)
        Copy the customized configuration files into the cargo home directory.
        Overrides:
        configureFiles in class AbstractLocalConfiguration
        Parameters:
        filterChain - the filter chain to use during the copy
        container - local container
      • replaceInFile

        protected void replaceInFile​(String file,
                                     Map<String,​String> replacements,
                                     Charset encoding)
                              throws CargoException
        Replaces using a map of replacements in a given file.
        Parameters:
        file - File to replace in.
        replacements - Map containing replacements.
        encoding - The character encoding to use, may be null or empty to use the platform's default encoding.
        Throws:
        CargoException - If anything fails, most notably if one of the replacements does not exist in the file.