public class

JavaScriptDependencyAnalyzer

extends Object
java.lang.Object
   ↳ com.microstrategy.web.app.utils.JavaScriptDependencyAnalyzer
Known Direct Subclasses

Class Overview

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.

Summary

Fields
protected File dependencyFile
protected String verboseLevel
Public Constructors
JavaScriptDependencyAnalyzer()
Creates an instance of a JavaScript Dependency Analyzer.
Public Methods
void add(String jsFilePath)
Adds a file dependency to the dependency graph.
void addInterScriptDependencyEdge(String fromJsFileName, String toJsFileName)
Add an Inter-JavaScript dependency relationship.
void clear()
Clear the current dependency graph.
static List<String> getClassesInFile(String fileName)
Returns the list of JavaScript classes defined for a given JavaScript file.
static String getFileImplementingClass(String className)
Returns the path to the JavaScript file that implements the specified JavaScript class.
Iterator<String> getSortedList()
Returns a list of required JavaScript files, sorted in order of increasing dependencies.
static void loadClassInformation(AppContext appContext, String bundleName)
Load the JavaScript class information from the specified "bundle name".
static void loadFileDependencies(AppContext appContext, String bundleName)
Load the file dependencies from the specified "bundle name".
void setMessageRouter(MessageRouter msgRouter)
Returns the MessageRouter instance used by the JavaScriptDependencyAnalyzer instance (and on the underlying Dependency Graph).
Protected Methods
void loadFileDependenciesFile(File depPropFile, String resFolderPrefix)
boolean parseCommandLine(String[] args)
void processCommands(InputStream in, PrintStream out)
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected File dependencyFile

protected String verboseLevel

Public Constructors

public JavaScriptDependencyAnalyzer ()

Creates an instance of a JavaScript Dependency Analyzer.

Public Methods

public void add (String jsFilePath)

Adds a file dependency to the dependency graph.

Parameters
jsFilePath The path to the JS file to include.

public void addInterScriptDependencyEdge (String fromJsFileName, 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.

public void clear ()

Clear the current dependency graph.

public static List<String> getClassesInFile (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.

public static String getFileImplementingClass (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.

public Iterator<String> getSortedList ()

Returns a list of required JavaScript files, sorted in order of increasing dependencies.

Returns
  • An Iterator of String instances.

public static void loadClassInformation (AppContext appContext, String bundleName)

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
MissingResourceException If we are unable to find the specified bundle.

public static void loadFileDependencies (AppContext appContext, String bundleName)

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
MissingResourceException If we are unable to find the specified bundle.

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.

Protected Methods

protected void loadFileDependenciesFile (File depPropFile, String resFolderPrefix)

Throws
IOException

protected boolean parseCommandLine (String[] args)

protected void processCommands (InputStream in, PrintStream out)