Forums de discussion
Hook that runs once
Lior Hadaya, modifié il y a 11 années.
Hook that runs once
Regular Member Publications: 138 Date d'inscription: 24/01/12 Publications récentes
Hi,
Is it possible to create a hook that runs only once? the closest thing I know is to create a hook that implements a startup action and runs each time the server starts up, but I wonder if there's a way to create a hook that will run just once upon deployment and that's it.
I want to write a hook that creates a few layouts and run it on newly installed servers.
(I'm using Liferay EE 6.1.10)
Thanks,
Lior
Is it possible to create a hook that runs only once? the closest thing I know is to create a hook that implements a startup action and runs each time the server starts up, but I wonder if there's a way to create a hook that will run just once upon deployment and that's it.
I want to write a hook that creates a few layouts and run it on newly installed servers.
(I'm using Liferay EE 6.1.10)
Thanks,
Lior
Paul ., modifié il y a 11 années.
RE: Hook that runs once
Liferay Master Publications: 522 Date d'inscription: 29/08/11 Publications récentes
I am not sure if there is a direct way to achieve this, may be check for certain values in db and then decide to continue execution in your hook. Something like the SevenCogs hook available from liferay itself. A cool idea would be to run the hook once, and then execute what is done via Control Panel -- Update plugins -- uninstall of a certain plugin.
David H Nebinger, modifié il y a 11 années.
RE: Hook that runs once (Réponse)
Liferay Legend Publications: 14915 Date d'inscription: 02/09/06 Publications récentesLior Hadaya:
the closest thing I know is to create a hook that implements a startup action and runs each time the server starts up, but I wonder if there's a way to create a hook that will run just once upon deployment and that's it. I want to write a hook that creates a few layouts and run it on newly installed servers.
That's going to be it. Your hook should check to see if the layouts are already installed; if they are, you do nothing. If they're not, then create them.
Hitoshi Ozawa, modifié il y a 11 années.
RE: Hook that runs once (Réponse)
Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
Use startup action event to check for layout as David said.
http://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins#section-Portal+Hook+Plugins-Event+Handlers
http://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins#section-Portal+Hook+Plugins-Event+Handlers
Lior Hadaya, modifié il y a 11 années.
RE: Hook that runs once
Regular Member Publications: 138 Date d'inscription: 24/01/12 Publications récentes
Alright, thanks guys.
Dominique Ebert, modifié il y a 10 années.
RE: Hook that runs once
Junior Member Publications: 29 Date d'inscription: 01/02/13 Publications récentes
Hi everyone!
As this thread is pretty close to what I'm currently trying to achieve I decided to revive this thread instead of creating a new one.
I'm trying to create a Hook that runs only once. I know how to create a Hook that runs when the Portal starts, and I know that I need to ensure somehow (e.g. database values) that the hook hasnt been run previously at this point.
My problem is, as im importing private-messages (dharma pm-portlet) into the privatemessaging portlet of the social office, that I dont have any reliable database value that I could check for. Such as "has Layout XY already been created". What would you guys recommend in this case, to ensure that the hook runs only once? What could I possibly check for, or do you know other approaches to ensure that the hook doesnt run twice?
thanks in advance and best regards
As this thread is pretty close to what I'm currently trying to achieve I decided to revive this thread instead of creating a new one.
I'm trying to create a Hook that runs only once. I know how to create a Hook that runs when the Portal starts, and I know that I need to ensure somehow (e.g. database values) that the hook hasnt been run previously at this point.
My problem is, as im importing private-messages (dharma pm-portlet) into the privatemessaging portlet of the social office, that I dont have any reliable database value that I could check for. Such as "has Layout XY already been created". What would you guys recommend in this case, to ensure that the hook runs only once? What could I possibly check for, or do you know other approaches to ensure that the hook doesnt run twice?
thanks in advance and best regards
Dominique Ebert, modifié il y a 10 années.