留言板

How to disable cache in *.properties in hook

xun ren,修改在12 年前。

How to disable cache in *.properties in hook

Junior Member 帖子: 81 加入日期: 08-4-1 最近的帖子
Hello everybody,

I create a hook and I override the portal's properties with mine.
And there is one line like this:
"user.import.version=1.0"

If I increase "1.0" to "1.1" and redeploy the hook, the value got from the java code has not been changed. It seems that there is a cache on it.
Can you tell me how can I disable the "cache"?

Thanks in advance.
thumbnail
Samuel Kong,修改在12 年前。

RE: How to disable cache in *.properties in hook

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
user.import.version is not built in portal property, so I'm assuming this is a custom property that you added. I'm also guessing that the caching issue is related to the custom code you're using to read the property's value. Plugin hooks can only be used to override some properties (user.import.version is not one of them). Please refer to liferay-hook_6_0_0.dtd for a complete list of the portal properties that can be overridden via a hook.
xun ren,修改在12 年前。

RE: How to disable cache in *.properties in hook

Junior Member 帖子: 81 加入日期: 08-4-1 最近的帖子
Samuel Kong:
user.import.version is not built in portal property, so I'm assuming this is a custom property that you added. I'm also guessing that the caching issue is related to the custom code you're using to read the property's value. Plugin hooks can only be used to override some properties (user.import.version is not one of them). Please refer to liferay-hook_6_0_0.dtd for a complete list of the portal properties that can be overridden via a hook.


Thanks Samuel Kong,
Yes, You're right. It's a custom properties. So if I want to add a custom properties what I need to do to avoid the problem of cache, please?
I need to include another properties file like we do in Ext? "include-and-override=portal-ext.${user.name}.properties".

Thanks again.
thumbnail
Jay Patel,修改在12 年前。

RE: How to disable cache in *.properties in hook

Regular Member 帖子: 118 加入日期: 10-2-24 最近的帖子
xun ren:
Samuel Kong:
user.import.version is not built in portal property, so I'm assuming this is a custom property that you added. I'm also guessing that the caching issue is related to the custom code you're using to read the property's value. Plugin hooks can only be used to override some properties (user.import.version is not one of them). Please refer to liferay-hook_6_0_0.dtd for a complete list of the portal properties that can be overridden via a hook.


Thanks Samuel Kong,
Yes, You're right. It's a custom properties. So if I want to add a custom properties what I need to do to avoid the problem of cache, please?
I need to include another properties file like we do in Ext? "include-and-override=portal-ext.${user.name}.properties".

Thanks again.


Hi Xun,
I still did not get your reuirement exactly.
The main use of hook is to override language keys, portal JSPs, some of the portal properties, some struts events etc.
From your answer, it seems you have custom property defined, then question is where have you declared this? And then do you want to override this at run time? What is your exact requirement?

Best,
Jay.
xun ren,修改在12 年前。

RE: How to disable cache in *.properties in hook

Junior Member 帖子: 81 加入日期: 08-4-1 最近的帖子
Thanks Jay Patel,

In fact, I wrote a hook for importing some users into liferay through an xml file.
So this hook is only used once. It will be removed after the importation.

In your mind, it is not a good manner to do this in hook? Could you give me a suggestion what is the best way to to this? Thanks a lot!
thumbnail
Jay Patel,修改在12 年前。

RE: How to disable cache in *.properties in hook

Regular Member 帖子: 118 加入日期: 10-2-24 最近的帖子
xun ren:
Thanks Jay Patel,

In fact, I wrote a hook for importing some users into liferay through an xml file.
So this hook is only used once. It will be removed after the importation.

In your mind, it is not a good manner to do this in hook? Could you give me a suggestion what is the best way to to this? Thanks a lot!


Hi Xun,

If this is only one time import event then try to use existing portal.properties from below:

#
# Application startup event that runs once for every web site instance of
# the portal that initializes.
#
application.startup.events=com.liferay.portal.events.AppStartupAction

You can override this property in your hook & can declare your custom event java class with it. In that class you may write your importing logic.

Also if this is repetitive task or cron job then you can try declaring your own scheduler class like follows:

#
# Set this to false to disable all scheduler classes defined in
# liferay-portlet.xml and in the property "scheduler.classes".
#
scheduler.enabled=true

#
# Input a list of comma delimited class names that implement
# com.liferay.portal.kernel.job.Scheduler. These classes allow jobs to be
# scheduled on startup. These classes are not associated to any one portlet.
#
scheduler.classes=

But as per "liferay-hook_5_2_0.dtd", property "scheduler.classes" can not be overriden by hook, so you need to check your Liferay version's DTD.

Cheers,
Jay.