Class JavaScriptDependencyAnalyzer

  • Direct Known Subclasses:
    JavaScriptDependencyAnalyserHelper

    public class JavaScriptDependencyAnalyzer
    extends java.lang.Object
    This class is used to provide dependency analysis of JavaScript files. The caller is expected to specify any number of required JavaScript files and this class can produce a complete list of JavaScript files (implicitly adding all dependent JavaScript files) and sort them in order of increasing dependencies.
    Since:
    MicroStrategy Web 9.0.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.File dependencyFile  
      protected java.lang.String verboseLevel  
    • Constructor Summary

      Constructors 
      Constructor Description
      JavaScriptDependencyAnalyzer()
      Creates an instance of a JavaScript Dependency Analyzer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String jsFilePath)
      Adds a file dependency to the dependency graph.
      void addInterScriptDependencyEdge​(java.lang.String fromJsFileName, java.lang.String toJsFileName)
      Add an Inter-JavaScript dependency relationship.
      void clear()
      Clear the current dependency graph.
      static void destroy()
      Destroy the HashSet and other caches, will be called when destroying the sevlet
      static java.util.List<java.lang.String> getClassesInFile​(java.lang.String fileName)
      Returns the list of JavaScript classes defined for a given JavaScript file.
      static java.lang.String getFileImplementingClass​(java.lang.String className)
      Returns the path to the JavaScript file that implements the specified JavaScript class.
      java.util.Iterator<java.lang.String> getSortedList()
      Returns a list of required JavaScript files, sorted in order of increasing dependencies.
      static void loadClassInformation​(AppContext appContext, java.lang.String bundleName)
      Load the JavaScript class information from the specified "bundle name".
      static void loadFileDependencies​(AppContext appContext, java.lang.String bundleName)
      Load the file dependencies from the specified "bundle name".
      protected void loadFileDependenciesFile​(java.io.File depPropFile, java.lang.String resFolderPrefix)  
      protected boolean parseCommandLine​(java.lang.String[] args)  
      protected void processCommands​(java.io.InputStream in, java.io.PrintStream out)  
      void setMessageRouter​(MessageRouter msgRouter)
      Returns the MessageRouter instance used by the JavaScriptDependencyAnalyzer instance (and on the underlying Dependency Graph).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • dependencyFile

        protected java.io.File dependencyFile
      • verboseLevel

        protected java.lang.String verboseLevel
    • Constructor Detail

      • JavaScriptDependencyAnalyzer

        public JavaScriptDependencyAnalyzer()
        Creates an instance of a JavaScript Dependency Analyzer.
    • Method Detail

      • getFileImplementingClass

        public static java.lang.String getFileImplementingClass​(java.lang.String className)
        Returns the path to the JavaScript file that implements the specified JavaScript class.
        Parameters:
        className - The name of the JavaScript class to investigate.
        Returns:
        The JavaScript file that implements this class, if it exists. Otherwise, it returns null.
      • getClassesInFile

        public static java.util.List<java.lang.String> getClassesInFile​(java.lang.String fileName)
        Returns the list of JavaScript classes defined for a given JavaScript file.
        Parameters:
        fileName - The path to the JavaScript file.
        Returns:
        The List of JavaScript classes that a file implements, if any. If the file does not exist or does not implement any files, then null is returned.
      • loadFileDependencies

        public static void loadFileDependencies​(AppContext appContext,
                                                java.lang.String bundleName)
                                         throws java.util.MissingResourceException
        Load the file dependencies from the specified "bundle name". This should only be done at application startup.
        Parameters:
        appContext - The AppContext instance which provides application runtime context.
        bundleName - The name of the bundle that holds our dependency information.
        Throws:
        java.util.MissingResourceException - If we are unable to find the specified bundle.
      • loadClassInformation

        public static void loadClassInformation​(AppContext appContext,
                                                java.lang.String bundleName)
                                         throws java.util.MissingResourceException
        Load the JavaScript class information from the specified "bundle name". This should only be done at application startup.
        Parameters:
        appContext - The AppContext instance which provides application runtime context.
        bundleName - The name of the bundle that holds our JavaScript class information.
        Throws:
        java.util.MissingResourceException - If we are unable to find the specified bundle.
      • add

        public void add​(java.lang.String jsFilePath)
        Adds a file dependency to the dependency graph.
        Parameters:
        jsFilePath - The path to the JS file to include.
      • getSortedList

        public java.util.Iterator<java.lang.String> getSortedList()
        Returns a list of required JavaScript files, sorted in order of increasing dependencies.
        Returns:
        An Iterator of String instances.
      • clear

        public void clear()
        Clear the current dependency graph.
      • destroy

        public static void destroy()
        Destroy the HashSet and other caches, will be called when destroying the sevlet
      • setMessageRouter

        public void setMessageRouter​(MessageRouter msgRouter)
        Returns the MessageRouter instance used by the JavaScriptDependencyAnalyzer instance (and on the underlying Dependency Graph).
        Parameters:
        msgRouter - A MessageRouter instance.
      • parseCommandLine

        protected boolean parseCommandLine​(java.lang.String[] args)
      • processCommands

        protected void processCommands​(java.io.InputStream in,
                                       java.io.PrintStream out)
      • addInterScriptDependencyEdge

        public void addInterScriptDependencyEdge​(java.lang.String fromJsFileName,
                                                 java.lang.String toJsFileName)
        Add an Inter-JavaScript dependency relationship. This dependence is represented as an edge in our dependency DAG.
        Parameters:
        fromJsFileName - String the "parent" JavaScript file name that should appear before the toJSFileName in the page.
        toJsFileName - String the "dependent" JavaScript file name that should appear after the fromJSFileName in the page.
        Since:
        MicroStrategy Web 9.0.1
      • loadFileDependenciesFile

        protected void loadFileDependenciesFile​(java.io.File depPropFile,
                                                java.lang.String resFolderPrefix)
                                         throws java.io.IOException
        Throws:
        java.io.IOException