Class ImportControlCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable, ExternalResourceHolder

    public class ImportControlCheck
    extends AbstractCheck
    implements ExternalResourceHolder
    Check that controls what packages can be imported in each package. Useful for ensuring that application layering is not violated. Ideas on how the check can be improved include support for:
    • Change the default policy that if a package being checked does not match any guards, then it is allowed. Currently defaults to disallowed.
    Author:
    Oliver Burn
    • Method Detail

      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Description copied from class: AbstractCheck
        The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.
        Specified by:
        getAcceptableTokens in class AbstractCheck
        Returns:
        the token set this check is designed for.
        See Also:
        TokenTypes
      • beginTree

        public void beginTree​(DetailAST rootAST)
        Description copied from class: AbstractCheck
        Called before the starting to process a tree. Ideal place to initialize information that is to be collected whilst processing a tree.
        Overrides:
        beginTree in class AbstractCheck
        Parameters:
        rootAST - the root of the tree
      • setFile

        public void setFile​(URI uri)
        Set the name for the file containing the import control configuration. It can also be a URL or resource in the classpath. It will cause the file to be loaded.
        Parameters:
        uri - the uri of the file to load.
        Throws:
        IllegalArgumentException - on error loading the file.
      • setPath

        public void setPath​(Pattern pattern)
        Set the file path pattern that this check applies to.
        Parameters:
        pattern - the file path regex this check should apply to.
      • setUrl

        @Deprecated
        public void setUrl​(URI uri)
        Deprecated.
        use setFile(URI uri) to load URLs instead
        Set the parameter for the url containing the import control configuration. It will cause the url to be loaded.
        Parameters:
        uri - the uri of the file to load.
        Throws:
        org.apache.commons.beanutils.ConversionException - on error loading the file.