Class AbstractLocalConfiguration

    • Field Detail

      • RESOURCE_PATH

        public static final String RESOURCE_PATH
        The path under which the container resources are stored in the JAR.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractLocalConfiguration

        public AbstractLocalConfiguration​(String home)
        Parameters:
        home - the home directory where the container will be set up to start and where it will deploy its deployables. 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.
    • 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
      • setFileHandler

        public void setFileHandler​(FileHandler fileHandler)
        Specified by:
        setFileHandler in interface LocalConfiguration
        Parameters:
        fileHandler - the file utility class to use for performing all file I/O.
      • getAntUtils

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

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

        public void setFileProperty​(FileConfig fileConfig)
        set the file property for a configuration.
        Specified by:
        setFileProperty in interface LocalConfiguration
        Parameters:
        fileConfig - The FileConfig to use
      • setConfigFileProperty

        public void setConfigFileProperty​(FileConfig fileConfig)
        set the config file property for a configuration.
        Specified by:
        setConfigFileProperty in interface LocalConfiguration
        Parameters:
        fileConfig - The FileConfig to use
      • getHome

        public String getHome()
        Specified by:
        getHome in interface LocalConfiguration
        Returns:
        the configuration home directory. 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.
      • configure

        public void configure​(LocalContainer container)
        Setup the container which means setting up a valid directory structure, setting up configuration files and deploying static deployables.
        Specified by:
        configure in interface LocalConfiguration
        Parameters:
        container - the container to configure
      • createFilterChain

        protected final org.apache.tools.ant.types.FilterChain createFilterChain()
        Creates the default filter chain that should be applied while copying container configuration files to the working directory from which the container is started.
        Returns:
        The default filter chain
      • getFilterChain

        protected org.apache.tools.ant.types.FilterChain getFilterChain()
        Returns (while, if necessary, creating) the default filter chain that should be applied while copying container configuration files to the working directory from which the container is started.
        Returns:
        The default filter chain
      • configureFiles

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

        protected String getDestFileLocation​(String file,
                                             String toDir,
                                             String toFile)
        Determines the correct path for the destination file.
        Parameters:
        file - The path of the original file
        toDir - The directory for the copied file
        toFile - The file name for the copied file
        Returns:
        The path for the destination file
      • getDestDirectoryLocation

        protected String getDestDirectoryLocation​(String file,
                                                  String toDir)
        Determines the correct path for the destination directory.
        Parameters:
        file - The path of the original file
        toDir - The directory for the copied file
        Returns:
        The path for the destination file
      • 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 AbstractConfiguration
      • collectUnsupportedResourcesAndThrowException

        public void collectUnsupportedResourcesAndThrowException()
        Warn user and throw an Exception if any unsupported Resources are setup for this configuration.
      • collectUnsupportedDataSourcesAndThrowException

        public void collectUnsupportedDataSourcesAndThrowException()
        Warn user and throw an Exception if any unsupported DataSources are setup for this configuration.
      • parsePropertiesForPendingConfiguration

        public void parsePropertiesForPendingConfiguration()
        Some configuration can be specified as encoded properties. Parse properties and apply what is found to the appropriate pending configuration list.
      • addResourcesFromProperties

        protected void addResourcesFromProperties()
        Parse properties and add any Resources to pending configuration. Resources will be found if their property name starts with: ResourcePropertySet.RESOURCE
      • addDataSourcesFromProperties

        protected void addDataSourcesFromProperties()
        Parse properties and add any DataSources to pending configuration. DataSources will be found if their property name starts with: DatasourcePropertySet.DATASOURCE
      • addUsersFromProperties

        protected void addUsersFromProperties()
        Parse properties and add any users to pending configuration. Users will be retrieved from their property: ServletPropertySet.USERS
      • doConfigure

        protected abstract void doConfigure​(LocalContainer container)
                                     throws Exception
        Implementation of LocalConfiguration.configure(LocalContainer) that all local configuration using this class must implement. This provides the ability to perform generic actions before and after the container-specific implementation. Another way would be to use AOP...
        Parameters:
        container - the container to configure
        Throws:
        Exception - if any error is raised during the configuration
      • addResource

        public void addResource​(Resource resource)
        Add resources the container can take advantage of. I.e. datasources.
        Specified by:
        addResource in interface LocalConfiguration
        Parameters:
        resource - the Resource to add.
      • applyPortOffset

        public void applyPortOffset()
        This method should only be called once all the properties has been set. Apply the port offset to the configuration port properties.
        Specified by:
        applyPortOffset in interface LocalConfiguration
      • revertPortOffset

        public void revertPortOffset()
        Revert the port offset on the configuration port properties. This method should only be called once all the properties has been set.
        Specified by:
        revertPortOffset in interface LocalConfiguration
      • applyPortOffset

        protected void applyPortOffset​(String name)
        Apply the port offset on the specified property
        Parameters:
        name - the property name
      • revertPortOffset

        protected void revertPortOffset​(String name)
        Revert the port offset on the specified property
        Parameters:
        name - the property name
      • isOffsetApplied

        public boolean isOffsetApplied()
        Checks whether the offset is already applied or not.
        Specified by:
        isOffsetApplied in interface LocalConfiguration
        Returns:
        true if the offset is already applied
      • isOffsetApplied

        protected boolean isOffsetApplied​(String name)
        Checks whether the offset is already applied or not
        Parameters:
        name - the name of the property to be checked
        Returns:
        true if the offset is already applied
      • flagOffsetApplied

        protected void flagOffsetApplied​(String name,
                                         boolean offsetApplied)
        Flags whether offset has been applied to a given property or not.
        Parameters:
        name - name of the property to be flagged.
        offsetApplied - true if the offset is applied, else false.