Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Kiran Jai
Liferay : Why to use Hooks concept for Liferay Login Events ?
9 de Abril de 2012 03:38
Resposta

Kiran Jai

Ranking: Junior Member

Mensagens: 38

Data de entrada: 9 de Abril de 2012

Mensagens recentes

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 de Abril de 2012 03:45
Resposta

Ravi Kumar Gupta

Ranking: Liferay Legend

Mensagens: 1303

Data de entrada: 23 de Junho de 2009

Mensagens recentes

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 de Abril de 2012 04:10
Resposta

Kiran Jai

Ranking: Junior Member

Mensagens: 38

Data de entrada: 9 de Abril de 2012

Mensagens recentes

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 de Abril de 2012 05:29
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11295

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

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 de Abril de 2012 06:28
Resposta

MICHAIL MOUDATSOS

Ranking: Regular Member

Mensagens: 110

Data de entrada: 4 de Outubro de 2011

Mensagens recentes

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 de Maio de 2012 06:25
Resposta

Brian Scott Schupbach

Ranking: Expert

Mensagens: 329

Data de entrada: 23 de Outubro de 2008

Mensagens recentes

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 de Maio de 2012 23:00
Resposta

MICHAIL MOUDATSOS

Ranking: Regular Member

Mensagens: 110

Data de entrada: 4 de Outubro de 2011

Mensagens recentes

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.