public class

Customizations

extends Observable
implements Observer
java.lang.Object
   ↳ java.util.Observable
     ↳ com.microstrategy.utils.Customizations

Class Overview

This class is responsible for searching Customizations in MicroStrategy Web. This class is a singleton. Therefore, all classes in the application use the same instance.
This class searches for customizations in the application's root folder, based on two parameters:

  1. baseFolder: Indicates the subfolder within the application where customizations folders must be included. By default, the application's root folder.
  2. folderPrefix: Indicates a prefix in a folder's name used to identify that the folder is indeed a customization folder. "_custom" is used by default.
This class also accepts a Comparator used to sort the customization folders. This comparator can indicate the exact order in which the customizations should be applied to avoid conflicts among them. If no Comparator is specified, customizations will be applied in alphabetical order.
All of these parameters can be set either programatically or through the "webcustomizations.properties" file, which needs to be inside the classpath.

Summary

Constants
String CUSTOMIZATION_PROPERTIES_FILE Represents the name of the properties file used to configure this class.
Public Methods
String getBaseFolder()
Represents the base folder (relative to the application's root folder) this class searches for customization folders.
ClassLoader getClassLoader()
Returns a ClassLoader capable of loading classes/resources from all customization folders.
Comparator getComparator()
Represents the Java class used to compare the current CustomizationInfo instances to sort them.
Logger getConflictsLogger()
Returns the Logger instance used to log conflicts.
CustomizationInfo getCustomization(String name)
Returns the CustomizationInfo with the given name;
CustomizationInfo[] getCustomizations()
Returns a list of CustomizationInfo classes.
String getFolderPrefix()
Represents the prefix that identifies a folder as a customization folder.
static Customizations getInstance()
The method to return the singleton instance of this class.
String getRealPath(String relativePath)
Returns the full absolute path within the file sytem for a given relative path.
boolean hasCustomization(String name)
Returns the CustomizationInfo with the given name;
static void logConflict(Level level, String className, String methodName, String message, CustomizationInfo c1, CustomizationInfo c2)
Logs a conflict message into the log using the conflicts logger.
CustomizationInfo newCustomization(String name)
Returns a list of CustomizationInfo classes.
synchronized void reload()
This method triggers the class to check for changes in the base folder for new customizations.
void setBaseFolder(String value)
Represents the base folder (relative to the application's root folder) this class searches for customization folders.
void setComparator(Comparator comparator)
Sets the Comparator used to compare two CustomizationInfo instances to sort them.
void setFolderPrefix(String value)
Represents the prefix that identifies a folder as a customization folder.
void update(Observable o, Object arg)
This class observes the FileLoader, whenever the FileLoader instances changes this class wants to be notified so it can remove its internal caches.
Protected Methods
String[] getCustomFolders()
Returns a list of customization folders based on the base folder and the folder prefix.
static void loadProperties(String propertiesFile)
Loads and initializes this class based on the Properties file (if found).
[Expand]
Inherited Methods
From class java.util.Observable
From class java.lang.Object
From interface java.util.Observer

Constants

public static final String CUSTOMIZATION_PROPERTIES_FILE

Represents the name of the properties file used to configure this class.

Constant Value: "webcustomizations.properties"

Public Methods

public String getBaseFolder ()

Represents the base folder (relative to the application's root folder) this class searches for customization folders.

public ClassLoader getClassLoader ()

Returns a ClassLoader capable of loading classes/resources from all customization folders.

public Comparator getComparator ()

Represents the Java class used to compare the current CustomizationInfo instances to sort them. If no Comparator has been explicitly set, or the properties file didn't include a Comparator name this method returns a string comparator (in which case, customizations are applied in alphabetical order).
The Comparator will be asked to compare two CustomizationInfo instances to determine the order in which they should be applied. It must return -1 if the first CustomizationInfo is to be applied before the second, and 1 if the second CustomizationInfo is to be applied before the first.

See Also
  • Comparator

public Logger getConflictsLogger ()

Returns the Logger instance used to log conflicts.

public CustomizationInfo getCustomization (String name)

Returns the CustomizationInfo with the given name;

public CustomizationInfo[] getCustomizations ()

Returns a list of CustomizationInfo classes. Each CustomizationInfo represents a single customization folder, which can be used to query whether there is a customization for a given file in the folder, or to retrieve a ClassLoader that searches for classes/resources only in that customization folder.

public String getFolderPrefix ()

Represents the prefix that identifies a folder as a customization folder. A folder is identified as a customization folder when its name within the base folder starts with this prefix.

public static Customizations getInstance ()

The method to return the singleton instance of this class.

public String getRealPath (String relativePath)

Returns the full absolute path within the file sytem for a given relative path.

public boolean hasCustomization (String name)

Returns the CustomizationInfo with the given name;

public static void logConflict (Level level, String className, String methodName, String message, CustomizationInfo c1, CustomizationInfo c2)

Logs a conflict message into the log using the conflicts logger. To log a conflict, please specify the level of conflict, the class and method where the conflict was detected, a detailed message explaining what the conflict is and the action taken, and the pair of customizations among which the conflict was detected.
For the conflict level, use the following convention:

  • Level.SEVERE: When two customizations modify the same parameter with different values.
  • Level.WARNING: When two customizations modify the same parameter, but use the same value.

public CustomizationInfo newCustomization (String name)

Returns a list of CustomizationInfo classes. Each CustomizationInfo represents a single customization folder, which can be used to query whether there is a customization for a given file in the folder, or to retrieve a ClassLoader that searches for classes/resources only in that customization folder.

public synchronized void reload ()

This method triggers the class to check for changes in the base folder for new customizations.

public void setBaseFolder (String value)

Represents the base folder (relative to the application's root folder) this class searches for customization folders.

public void setComparator (Comparator comparator)

Sets the Comparator used to compare two CustomizationInfo instances to sort them.

See Also

public void setFolderPrefix (String value)

Represents the prefix that identifies a folder as a customization folder. A folder is identified as a customization folder when its name within the base folder starts with this prefix.

public void update (Observable o, Object arg)

This class observes the FileLoader, whenever the FileLoader instances changes this class wants to be notified so it can remove its internal caches.

Protected Methods

protected String[] getCustomFolders ()

Returns a list of customization folders based on the base folder and the folder prefix.

See Also

protected static void loadProperties (String propertiesFile)

Loads and initializes this class based on the Properties file (if found). If the file is not found, the current values are used.

Throws
FileNotFoundException