Package com.microstrategy.utils
Class Customizations
- java.lang.Object
- 
- java.util.Observable
- 
- com.microstrategy.utils.Customizations
 
 
- 
- All Implemented Interfaces:
- java.util.Observer
 
 public class Customizations extends java.util.Observable implements java.util.ObserverThis 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:- baseFolder: Indicates the subfolder within the application where customizations folders must be included. By default, the application's root folder.
- 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.
 Comparatorused 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 noComparatoris 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.- Since:
- MicroStrategy Web 9.0.0
 
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringCUSTOMIZATION_PROPERTIES_FILERepresents the name of the properties file used to configure this class.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAppRelativePathPrefix()java.lang.StringgetBaseFolder()Represents the base folder (relative to the application's root folder) this class searches for customization folders.java.lang.ClassLoadergetClassLoader()Returns aClassLoadercapable of loading classes/resources from all customization folders.java.util.ComparatorgetComparator()Represents the Java class used to compare the currentCustomizationInfoinstances to sort them.LoggergetConflictsLogger()Returns the Logger instance used to log conflicts.protected java.lang.String[]getCustomFolders()Returns a list of customization folders based on the base folder and the folder prefix.CustomizationInfogetCustomization(java.lang.String name)Returns the CustomizationInfo with the given name;CustomizationInfo[]getCustomizations()Returns a list ofCustomizationInfoclasses.java.lang.StringgetFolderPrefix()Represents the prefix that identifies a folder as a customization folder.static CustomizationsgetInstance()The method to return the singleton instance of this class.java.lang.StringgetRealPath(java.lang.String relativePath)Returns the full absolute path within the file sytem for a given relative path.booleanhasCustomization(java.lang.String name)Returns the CustomizationInfo with the given name;protected static voidloadProperties(java.lang.String propertiesFile)Loads and initializes this class based on the Properties file (if found).static voidlogConflict(Level level, java.lang.String className, java.lang.String methodName, java.lang.String message, CustomizationInfo c1, CustomizationInfo c2)Logs a conflict message into the log using the conflicts logger.CustomizationInfonewCustomization(java.lang.String name)Returns a list ofCustomizationInfoclasses.voidreload()This method triggers the class to check for changes in the base folder for new customizations.voidsetAppRelativePathPrefix(java.lang.String prefix)voidsetBaseFolder(java.lang.String value)Represents the base folder (relative to the application's root folder) this class searches for customization folders.voidsetComparator(java.util.Comparator comparator)Sets theComparatorused to compare two CustomizationInfo instances to sort them.voidsetFolderPrefix(java.lang.String value)Represents the prefix that identifies a folder as a customization folder.voidupdate(java.util.Observable o, java.lang.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.
 
- 
- 
- 
Field Detail- 
CUSTOMIZATION_PROPERTIES_FILEpublic static final java.lang.String CUSTOMIZATION_PROPERTIES_FILE Represents the name of the properties file used to configure this class.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getInstancepublic static Customizations getInstance() The method to return the singleton instance of this class.
 - 
setBaseFolderpublic void setBaseFolder(java.lang.String value) Represents the base folder (relative to the application's root folder) this class searches for customization folders.
 - 
getBaseFolderpublic java.lang.String getBaseFolder() Represents the base folder (relative to the application's root folder) this class searches for customization folders.
 - 
setAppRelativePathPrefixpublic void setAppRelativePathPrefix(java.lang.String prefix) 
 - 
getAppRelativePathPrefixpublic java.lang.String getAppRelativePathPrefix() 
 - 
setFolderPrefixpublic void setFolderPrefix(java.lang.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.
 - 
getFolderPrefixpublic java.lang.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.
 - 
getComparatorpublic java.util.Comparator getComparator() Represents the Java class used to compare the currentCustomizationInfoinstances to sort them. If noComparatorhas been explicitly set, or the properties file didn't include aComparatorname this method returns a string comparator (in which case, customizations are applied in alphabetical order).
 TheComparatorwill be asked to compare twoCustomizationInfoinstances to determine the order in which they should be applied. It must return -1 if the firstCustomizationInfois to be applied before the second, and 1 if the secondCustomizationInfois to be applied before the first.- See Also:
- Comparator
 
 - 
setComparatorpublic void setComparator(java.util.Comparator comparator) Sets theComparatorused to compare two CustomizationInfo instances to sort them.- See Also:
- getComparator()
 
 - 
getRealPathpublic java.lang.String getRealPath(java.lang.String relativePath) Returns the full absolute path within the file sytem for a given relative path.
 - 
reloadpublic void reload() This method triggers the class to check for changes in the base folder for new customizations.
 - 
getCustomizationspublic CustomizationInfo[] getCustomizations() Returns a list ofCustomizationInfoclasses. EachCustomizationInforepresents 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.
 - 
newCustomizationpublic CustomizationInfo newCustomization(java.lang.String name) Returns a list ofCustomizationInfoclasses. EachCustomizationInforepresents 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.
 - 
getCustomizationpublic CustomizationInfo getCustomization(java.lang.String name) Returns the CustomizationInfo with the given name;
 - 
hasCustomizationpublic boolean hasCustomization(java.lang.String name) Returns the CustomizationInfo with the given name;
 - 
getCustomFoldersprotected java.lang.String[] getCustomFolders() Returns a list of customization folders based on the base folder and the folder prefix.- See Also:
- Customizations
 
 - 
getClassLoaderpublic java.lang.ClassLoader getClassLoader() Returns aClassLoadercapable of loading classes/resources from all customization folders.
 - 
loadPropertiesprotected static void loadProperties(java.lang.String propertiesFile) throws java.io.FileNotFoundExceptionLoads and initializes this class based on the Properties file (if found). If the file is not found, the current values are used.- Throws:
- java.io.FileNotFoundException
 
 - 
logConflictpublic static void logConflict(Level level, java.lang.String className, java.lang.String methodName, java.lang.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.
 
 - 
getConflictsLoggerpublic Logger getConflictsLogger() Returns the Logger instance used to log conflicts.
 - 
updatepublic void update(java.util.Observable o, java.lang.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.- Specified by:
- updatein interface- java.util.Observer
 
 
- 
 
-