Hi everybody, Is there a way to detect a user session is closing because of a timeout? There is the "unload" event that can be catched in an ULC Rich Dialog for performing some stuff when the user close a Dialog. Is there something similar for a session timeout? If not it would be very usefull to have such a possibility. Thanks in advance Emmanuel |
I did not test it: but I think that the ISessionExtension can do that job. See: ch.ivyteam.ivy.security.ISessionExtension.destroySession(ISession, IPersistentTransaction) And to register your extension: ch.ivyteam.ivy.security.ISecurityManager.addSessionExtension(ISessionExtension) Thanks a lot. Yes it should work. I would like to test it on the designer. How can I set the session timeout in the designer? I would like to set it to a very short time so I don't have to wait a to long time... Thanks in Advance. Setting the timeout in <Designer root>/webapps/ivy/WEB-INF/web.xml should do it. I was not able to find documentation for ch.ivyteam.ivy.security.ISessionExtension.destroySession(ISession, IPersistentTransaction) or ch.ivyteam.ivy.security.ISecurityManager.addSessionExtension(ISessionExtension). Please, could you share a link for the docs? Or a more detailed example of how to use ISessionExtension to detect session timeout would be very helpful. Thanks! 1
The registration of a ISessionExtension on every server start and stop has been described in another answer: see http://answers.axonivy.com/questions/2477/how-to-register-my-code-that-runs-on-every-engine-startup |
This is my implementation:
But we still got the error: Caused by: ch.ivyteam.ivy.environment.EnvironmentNotAvailableException: Access to ivy environment outside a process request thread is not possible. Current thread: Thread[ContainerBackgroundProcessor[StandardEngine[ivy]],6,main] at ch.ivyteam.ivy.environment.Ivy.getIvy(Ivy.java:577) at ch.ivyteam.ivy.environment.Ivy.getEnvironmentData(Ivy.java:556) at ch.ivyteam.ivy.environment.Ivy.getEnvironmentData(Ivy.java:551) at ch.ivyteam.ivy.environment.Ivy.log(Ivy.java:413) We can't get any ivy environment here :( 1
You can use internals to setup an environment. All you need is to store the IProcessModelVersion and ISession when the bean is created (and environment is available). Later you can execute and code by sending a callable to something like:
Hi Reguel Wermelinger, This is gold!!!! Finally, It's work Thank you so much! 1
hi @nhuuduong glad that it helped. Please keep in mind to automate tests against such functionality and keep and eye on when migrating to newer versions of Axon.ivy. As this API is internal it could change frequently on new releases... Hi Reguel Wermelinger, nhuuduong, I've also got the problem can not access ivy environment outside when building a plugin. Howerver, I don't understand clearly your solution. Could you explain more for this? How can we use "executeWithIvyContext". Many thanks in advance. Hi @Genzer Hawker This problem occurres whenever java code is being executed that was not started out of an HTTP request or another public interface that we provide to access the bpm engine. It's caused by the fact that our servlet-filters setup the valid context for a users HTTP request. And this context is used for DI later on. So whenever pure java code calls API of the BPM engine, users must setup the context manually. The other issue were this frequently happens is when java code runs asynch. But here we have a simple utility to face it: since the request context was once valid, but got lost during async usiage: https://developer.axonivy.com/doc/latest/PublicAPI/ch/ivyteam/util/threadcontext/IvyAsyncRunner.html
showing 5 of 6
show 1 more comments
|
it's not public API therefore there is no documentation for it. But the simple methods of theses interfaces should speak for themselves. Anyway here is a simple implementation:
The easiest way to register this Session extension is with a 'Program Start' event bean that runs when the server is up and running. Hi Reguel Wermelinger, I want to use the FacesContext.getCurrentInstance(); in the function destroySession(ISession session, IPersistentTransaction transaction), But It always return null Do you have any suggestion? I want to save the dossier before the session is timeout, but seem like this ways we can't do that ;( Thanks, Duong Nguyen. 1
@nhuuduong : access to FacesContext is not possible as you have no active JSF lifecycle when the session ends. I guess you are better of when you keep the actual BusinessData on a Thanks for your response quickly, Let me try to do your suggestion, I will post the result here to discuss, is this ok for you :) ? |
Following your recommendation, I am registering my Session extension with a 'Program Start', it's properly detecting when the session is destroyed, and then my StartEventBean calls fireProcessStartEventRequest(). The 'Program Start' is being triggered but it's failing on the way to a "Login Dialog". Any ideas of what I am missing? All I need is to redirect to my "Login Dialog" on a session timeout. The error message:
Thanks in advance! |
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 13.06.2015 at 10:22
Seen: 11,928 times
Last updated: 04.07.2019 at 04:23