Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Kiran Jai
Liferay : Why to use Hooks concept for Liferay Login Events ?
9 aprile 2012 3.38
Risposta

Kiran Jai

Punteggio: Junior Member

Messaggi: 38

Data di Iscrizione: 9 aprile 2012

Messaggi recenti

Hi ,

I have gone through Liferay Hooks tutorial it specifies that , the basic functionality of Liferay can be chnaged using Hooks
And i have come across a example where the author is using Liferay Hooks for overriding the default |Liferay Login pre and post events using hooks .

But i have a question here can't we do this way , that is by specfying it inside the portal-ext.properties file as shown

portal-ext.properties

login.events.post=com.MyLoginPostAction
logout.events.pre=com.MyLoginPreAction


And i seem that this way it is easier to do thinns where as if we sue the Hooks concept , we need to mention inside the liferay-hooks.xml file


<portal-properties>portal.properties</portal-properties>


Next, create the file portal.properties inside example-hook/docroot/WEB-INF/src with the following content:

login.events.pre=com.sample.hook.LoginAction




Please specify what approach is best
Ravi Kumar Gupta
RE: Liferay : Why to use Hooks concept for Liferay Login Events ?
9 aprile 2012 3.45
Risposta

Ravi Kumar Gupta

Punteggio: Liferay Legend

Messaggi: 1212

Data di Iscrizione: 23 giugno 2009

Messaggi recenti

Think about just one point.. if you need to remove that hook in production.. modifying portal-ext.properties will need server restart while hook will just need to be deleted from webapps.. emoticon

There can be more points.. but the line which says hooks can be hot-deployed teaches all..
Kiran Jai
RE: Liferay : Why to use Hooks concept for Liferay Login Events ?
9 aprile 2012 4.10
Risposta

Kiran Jai

Punteggio: Junior Member

Messaggi: 38

Data di Iscrizione: 9 aprile 2012

Messaggi recenti

Great point , i didn't thought of this , thank you very much for helping .
David H Nebinger
RE: Liferay : Why to use Hooks concept for Liferay Login Events ?
9 aprile 2012 5.29
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 7238

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

Kiran Jai:
Great point , i didn't thought of this , thank you very much for helping .


Yeah, you're new here. Stick around for awhile and you'll eventually understand why things were done how they were done, and most of the time there's a pretty good reason behind it...

I think everyone first coming to Liferay asks why certain pieces appear harder than they need to be, but eventually when the whole picture comes into focus it gets easier to understand why things are the way they are...
MICHAIL MOUDATSOS
RE: Liferay : Why to use Hooks concept for Liferay Login Events ?
26 aprile 2012 6.28
Risposta

MICHAIL MOUDATSOS

Punteggio: Regular Member

Messaggi: 110

Data di Iscrizione: 4 ottobre 2011

Messaggi recenti

I think you guys are right about removing a hook but how about adding a hook, which adds a definition of e.g. logout.events.post
I lost some time figuring out what was going wrong until I thought "Well the portal.properties are being overridden, so maybe a server restart is needed after all..." and yes(!) when I restarted the app server the property took effect. Most annoyingly, when I decided to change my class as to run as a logout.events.pre rather than as a logout.events.post (because I wanted the id of the session while it was valid, anyway) not even the restart of the server resulted in my changes taking effect! I stripped the property, I restarted, I added the new property, I restarted and then it worked.

For the benefit of your doubt I will also add that
- I already had another hook overriding some events (nevertheless, this must have no effect)
-(Most importantly) In my hook I also defined a service.xml (I needed some extra Entities for the goal of my hook) which I set to use the same namespace as the service.xml of a portlet I had already deployed. As a consequence I was getting some HotDeployException (*) every time I deployed the hook, however the code changes (Attention! The CODE changes not the property definition changes) would take effect at every deployment.

Unless the latter is the cause of the new, overridden in hook, properties not taking effect, then new properties in a hook need a restart...
And even if the latter is the case of my hot deployment not working properly, why the change from logout.events.post to logout.events.pre did not take effect after a single restart?

any ideas?

Thank you in advance

(*)Error stack trace included somewhere: "Build namespace xx has build number xxx which is newer than x"; deployment ended with: "Registering hook for xxx-hook" and "xxx-hook is available for use" as usual
Brian Scott Schupbach
RE: Liferay : Why to use Hooks concept for Liferay Login Events ?
10 maggio 2012 6.25
Risposta

Brian Scott Schupbach

Punteggio: Expert

Messaggi: 329

Data di Iscrizione: 23 ottobre 2008

Messaggi recenti

It's hard to tell without seeing the full stack trace but either your hook was built under a different liferay version or your java version doesn't match what you have in production.
MICHAIL MOUDATSOS
RE: Liferay : Why to use Hooks concept for Liferay Login Events ?
10 maggio 2012 23.00
Risposta

MICHAIL MOUDATSOS

Punteggio: Regular Member

Messaggi: 110

Data di Iscrizione: 4 ottobre 2011

Messaggi recenti

We do not need the stack trace. I also tried with another hook that produces no errors and still I needs a reboot when I override a portal.properties property, for the addition to take effect.