Package com.microstrategy.web.app.utils
Class JavaScriptDependencyAnalyzer
- java.lang.Object
-
- com.microstrategy.web.app.utils.JavaScriptDependencyAnalyzer
-
- Direct Known Subclasses:
JavaScriptDependencyAnalyserHelper
public class JavaScriptDependencyAnalyzer extends java.lang.ObjectThis 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.FiledependencyFileprotected java.lang.StringverboseLevel
-
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 voidadd(java.lang.String jsFilePath)Adds a file dependency to the dependency graph.voidaddInterScriptDependencyEdge(java.lang.String fromJsFileName, java.lang.String toJsFileName)Add an Inter-JavaScript dependency relationship.voidclear()Clear the current dependency graph.static voiddestroy()Destroy the HashSet and other caches, will be called when destroying the sevletstatic 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.StringgetFileImplementingClass(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 voidloadClassInformation(AppContext appContext, java.lang.String bundleName)Load the JavaScript class information from the specified "bundle name".static voidloadFileDependencies(AppContext appContext, java.lang.String bundleName)Load the file dependencies from the specified "bundle name".protected voidloadFileDependenciesFile(java.io.File depPropFile, java.lang.String resFolderPrefix)protected booleanparseCommandLine(java.lang.String[] args)protected voidprocessCommands(java.io.InputStream in, java.io.PrintStream out)voidsetMessageRouter(MessageRouter msgRouter)Returns the MessageRouter instance used by the JavaScriptDependencyAnalyzer instance (and on the underlying Dependency Graph).
-
-
-
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- TheAppContextinstance 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- TheAppContextinstance 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
Iteratorof 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- AMessageRouterinstance.
-
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
-
-