Hi All,
Currently we are loading super tenant themes to the registry in each server
startup, when the themes-mgt bundle start. Since this involves registry
calls this cause considerable startup delay. So here we are proposing a
configuration which we can enable to stop loading themes.
Here is the configuration which we will be adding to the carbon.xml
<ReloadThemes>true</ReloadThemes>
There can be several cases,
1. Configuration is not in carbon.xml - This will consider this
configuration value as true and will reload the themes every time start the
server
2. Configuration value true - This will reload the themes every time
start the server
3. Configuration value false - This will stop updating the themes in
registry every time start the server
4. Configuration value other than true/false - This will consider this
configuration value as false and won't reload the themes.
5. Theme not in the registry - If the theme which is in the file system
is not there in the registry, it will ignore the ReloadThemes configuration
value and add that theme to registry.
Thoughts?
Patch attached.
thanks
Eranda
--
*Eranda Sooriyabandara*Senior Software Engineer;
Integration Technologies Team;
WSO2 Inc.; http://wso2.com
Lean . Enterprise . Middleware
E-mail: eranda AT wso2.com
Mobile: +94 716 472 816
Linked-In: http://www.linkedin.com/in/erandasooriyabandara
Blog: http://emsooriyabandara.blogspot.com/
Index: src/main/java/org/wso2/carbon/theme/mgt/util/ThemeUtil.java
===================================================================
--- src/main/java/org/wso2/carbon/theme/mgt/util/ThemeUtil.java (revision 24226)
+++ src/main/java/org/wso2/carbon/theme/mgt/util/ThemeUtil.java (working copy)
@@ -17,6 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.registry.core.Collection;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.RegistryConstants;
@@ -46,6 +47,7 @@
private static final String CURRENT_THEME_KEY = "current-theme";
private static final String THEME_PATH = "/repository/theme";
private static final String THEME_ADMIN_PATH = THEME_PATH + "/admin";
+ private static final String RELOAD_THEMES = "ReloadThemes";
public static synchronized void setRegistryService(RegistryService service) {
if (registryService == null) {
@@ -172,12 +174,33 @@
.separator + "resources" + File.separator + "allthemes";
// we are always making this accessible from anyware
File themeRootFile = new File(themeRootFileName);
- ThemeUtil.transferAllThemesToRegistry(themeRootFile, systemRegistry, StratosConstants.ALL_THEMES_PATH);
- CommonUtil.setAnonAuthorization(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + StratosConstants.ALL_THEMES_PATH,
- systemRegistry.getUserRealm());
+
+ File[] themeDirs = themeRootFile.listFiles();
+ if (themeDirs == null) {
+ return;
+ }
+ List<File> themes = Arrays.asList(themeDirs);
+ boolean reloadThemes = getReloadThemes();
+ for (File themeDir : themes) {
+ String themeDirName = themeDir.getName();
+ String fileRegistryPath = StratosConstants.ALL_THEMES_PATH + RegistryConstants.PATH_SEPARATOR + themeDirName;
+ if (reloadThemes || !systemRegistry.resourceExists(fileRegistryPath)) {
+ ThemeUtil.transferAllThemesToRegistry(themeDir, systemRegistry, StratosConstants.ALL_THEMES_PATH);
+ CommonUtil.setAnonAuthorization(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + StratosConstants.ALL_THEMES_PATH,
+ systemRegistry.getUserRealm());
+ }
+ }
}
+ public static boolean getReloadThemes () {
+ String proxyContextPath = ServerConfiguration.getInstance().getFirstProperty(RELOAD_THEMES);
+ if (proxyContextPath == null) {
+ return true;
+ }
+ return Boolean.valueOf(proxyContextPath);
+ }
+
public static String[] getAvailableThemes() throws RegistryException {
Registry systemRegistry = registryService.getGovernanceSystemRegistry();
if (!systemRegistry.resourceExists(StratosConstants.ALL_THEMES_PATH)) {
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev