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
sarika kotha
liferay method to get all session ids
19 de Janeiro de 2012 04:01
Resposta

sarika kotha

Ranking: New Member

Mensagens: 8

Data de entrada: 19 de Janeiro de 2012

Mensagens recentes

hi friends,
please help me in finding this,i am developing a portlet which needs all the users session ids who are logged in into liferay.is there any method in liferay api please send me the syntax,i will be very thankful.


thanks in advance
David H Nebinger
RE: liferay method to get all session ids
19 de Janeiro de 2012 06:10
Resposta

David H Nebinger

Ranking: Liferay Legend

Mensagens: 6274

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

That info is not persisted, it is in memory of Liferay.

I don't think the list is exposed by default.

Fortunately the Liferay source is available so you can pull up the code for the Monitoring control panel and see how they do it. You may have to override some Liferay code to make it available outside of the core Liferay system, but it should certainly be doable.
sarika kotha
RE: liferay method to get all session ids
20 de Janeiro de 2012 00:27
Resposta

sarika kotha

Ranking: New Member

Mensagens: 8

Data de entrada: 19 de Janeiro de 2012

Mensagens recentes

David H Nebinger:
That info is not persisted, it is in memory of Liferay.

I don't think the list is exposed by default.

Fortunately the Liferay source is available so you can pull up the code for the Monitoring control panel and see how they do it. You may have to override some Liferay code to make it available outside of the core Liferay system, but it should certainly be doable.



hi david,

thank you very much for u r reply,but i have gone through some of the source of liferay from liferay api's,but i am very new to it so i need some help which classes to look ,so i cAN FIND THE SOLUTION.

thanks in advance
Amos Fong
RE: liferay method to get all session ids
20 de Janeiro de 2012 00:39
Resposta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 1843

Data de entrada: 7 de Outubro de 2008

Mensagens recentes

Hi,

I believe session info is not stored unless you turn on monitoring via live users.

1##
2## Live Users
3##
4
5    #
6    # Set this to true to enable tracking via Live Users.
7    #
8    live.users.enabled=false


You can look at the LiveUsers class to see how to retrieve the info.
David H Nebinger
RE: liferay method to get all session ids
20 de Janeiro de 2012 05:25
Resposta

David H Nebinger

Ranking: Liferay Legend

Mensagens: 6274

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Well, stored in memory, yes that property needs to be set, but it's never stored in the database.
sarika kotha
RE: liferay method to get all session ids
22 de Janeiro de 2012 22:40
Resposta

sarika kotha

Ranking: New Member

Mensagens: 8

Data de entrada: 19 de Janeiro de 2012

Mensagens recentes

hi thank you for the information, but where should i change that property.please inform me.


thanks in advance

sarika
Sandeep Nair
RE: liferay method to get all session ids
22 de Janeiro de 2012 22:46
Resposta

Sandeep Nair

Ranking: Liferay Legend

Mensagens: 1691

Data de entrada: 5 de Novembro de 2008

Mensagens recentes

It should be in portal-ext.properties where you specify you db related properties.

Regards,
Sandeep
sarika kotha
RE: liferay method to get all session ids
23 de Janeiro de 2012 02:58
Resposta

sarika kotha

Ranking: New Member

Mensagens: 8

Data de entrada: 19 de Janeiro de 2012

Mensagens recentes

Sandeep Nair:
It should be in portal-ext.properties where you specify you db related properties.

Regards,
Sandeep



thank you,sandeep but actually my plan is to retrieve all the session ids of liferay users.my requirement is to get all the session ids of liferay users and display those session ids of users who will be using my own portlets,deployed in liferay.

thanks in advance
David H Nebinger
RE: liferay method to get all session ids
23 de Janeiro de 2012 05:27
Resposta

David H Nebinger

Ranking: Liferay Legend

Mensagens: 6274

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Well turning on the property enables Liferay monitoring.

Cloning from the monitoring page will show you how to access session ids.

From there, however, you're done. You can see the session ids, but not know what the users are doing.

If you want to see who's using your portlets, you probably want more of an audit trail type of function.
sarika kotha
RE: liferay method to get all session ids
24 de Janeiro de 2012 03:52
Resposta

sarika kotha

Ranking: New Member

Mensagens: 8

Data de entrada: 19 de Janeiro de 2012

Mensagens recentes

David H Nebinger:
Well turning on the property enables Liferay monitoring.

Cloning from the monitoring page will show you how to access session ids.

From there, however, you're done. You can see the session ids, but not know what the users are doing.

If you want to see who's using your portlets, you probably want more of an audit trail type of function.



Thank you david,
i have changed the properties file i.e..portal-ext properties but how should i track them can u explain me in detail.as i am very new to all these coding,but i am trying hard to do all these.i also need a clarification that whether is this possible.getting all the session ids of users in liferay and sending them to my portlets jsp page,and display only those ids of users who are using my portlets context.

thanks in advance
MICHAIL MOUDATSOS
RE: liferay method to get all session ids
4 de Maio de 2012 04:34
Resposta

MICHAIL MOUDATSOS

Ranking: Regular Member

Mensagens: 110

Data de entrada: 4 de Outubro de 2011

Mensagens recentes

David H Nebinger:
Well, stored in memory, yes that property needs to be set, but it's never stored in the database.

However, this information (i.e. userId-sessionId, and the session itself) is not lost even after a server restart, which means that this information is somehow persisted between app server restarts, probably by serialization. Could one have access to this serialized information? It would be nice if one wanted to implement his/her own SessionListener.

To take this one step further, there probably already exists an implemented SessionListener in Liferay code. It should probably be located in portal-impl.jar, whose API can not be directly accessed by a portlet's code. However, as it is mentioned in this conversation, an (awsome, in my opoinion) idea, which is simple yet I haven't read anywhere else, is to expose the desired functionality throuth the implementation of an ext-plugin (with all the consequent implications).

So, does anyone know where to look for Liferay SessionListener? Is it a good idea to use it, by exposing it through an ext-plugin?

Thank you for your time

PS For those wondering, I want a session listener in order to implement the old auth.simultaneous.logins functionality. I want to invalidate the session, let say A, of the logged in user when the same user re-loggins, so I need that session A! If application server restarts, I could use an application.startup.events, where I would brutally kill all sessions just in case ( emoticon ) but I wanted a more elegant approach and since liferay seems to handle sessions properly when application server restarts, why wouldn't I use its functionality, rather than trying to re-invent the wheel???
MICHAIL MOUDATSOS
RE: liferay method to get all session ids
4 de Maio de 2012 04:34
Resposta

MICHAIL MOUDATSOS

Ranking: Regular Member

Mensagens: 110

Data de entrada: 4 de Outubro de 2011

Mensagens recentes

Well, it seems that session persistence is a container's job, so Liferay has nothing to do with it. I suppose there's no way, or no easy way, to access this info. On the other hand, one can disable persistent sessions across app server restarts in tomcat by uncommenting
1<Manager pathname="" />
in $CATALINA_HOME/conf/Context.xml

As for the session listener - part of the question, the only thing I could find was com.liferay.portal.kernel.servlet.PortletSessionTracker in portal-service.jar, nevertheless there's no public method to use to get any session. It contains a private Map<String, Set<HttpSession>> of all sessions. So using an ext-plugin maybe one could give access to this map and start messing up with it... I just used the ServletContext to store userId-HttpSession pairs in a map, which means I will be forced to disable persistent sessions across app server restarts, otherwise my implementation will brake since ServletContext is destroyed (and since I've yet to think of a good way to persist the HttpSession object and retrieve it at ServletContext creation - does anyone have? emoticon )

Can anyone confirm the above statements?