Is it possible to reflect changes in portal-ext.properties without restarting whole Liferay portal?

Viewed 4331

My problem is every time after changing the Liferay portal-properties (and this is frequent especially at beginning of a new portal project) I need to restart the whole portal.

Some properties I can set over hook and these values will be changed after redeployment. Also that must be possible to change most portal properties at run time.

However, do you know some approach to reflect changes in portal-ext.properties without restarting Liferay portal?

6 Answers

I know it is a very old thread but it may be helpful for someone who is looking for some type of work around
As we know there is no straight forward way for this but I did this by using java reflection and class loader.
Liferay Version : 6.x

//Loading the PropsUtil class by using PortalClassLoader
Class<?> prospsUtilClass = PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.util.PropsUtil");
//getting the reload method of PropsUtil class
Method reloadMethod = prospsUtilClass.getMethod("reload", null);
//Invoking the static reload method 
reloadMethod.invoke(null, null);

Reload method (re)loads the portal-ext properties to the portal so we can use new properties without restarting Liferay server.

Some of the Liferay classes read their properties when initialising static field constants. E.g.:

public static final boolean ENABLED = GetterUtil.getBoolean(
    PropsUtil.get(DynamicCSSFilter.class.getName()));

Basically, it is possible to reload the properties (eg via script in control-panel), but all those static constants will remain.

Related