1

Definition --

  • There is working web-app with managed-bean state at some point.
  • this web-app posts request to external-application
  • External-application calls-back(http 'get' method) to web-app

    -- At this time application should restore managed-bean state as it was before request to external application.

    -- Note: External-app may respond later, than web-app session duration last.

Question -- If there are patterns or techniques around this kind of problem in JSF?

What is your way dealing with problem like this?

Mr.Bonz
  • 13
  • 2

1 Answers1

0

Store the state in the session scope along with an unique key and include that key as request parameter or pathinfo in the callback URL. When the callback request is received, extract the key from the request parameter or pathinfo and then obtain the state from the session based on that key.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Allright, one shortcoming I see with this approach is that external-app may send call-back after web-app session is expired (user delays to perform action on external-app). What's then ? – Mr.Bonz Aug 09 '11 at 18:26
  • Store it in application scope instead. Ensure that the key is **strong**. `java.util.UUID` is then very helpful in this. – BalusC Aug 09 '11 at 18:26
  • This would help!, but callback from external-app may never come back to web-app... and I think application-scope would then poison memory of web-app as it is kept in memory until web-app restart. Web-app is massively used application and this kind of memory poisoning may have quite big impact on performance I think. Would you consider self-destroying applicaiton-scope objects(after some period of time, when response is not received from external-app). – Mr.Bonz Aug 09 '11 at 18:48
  • Store a timestamp along the state and run a hourly background job which reaps states older than X hours. For detail, start with this answer: http://stackoverflow.com/questions/5357033/background-timer-task-in-jsp-web-application/5357856#5357856 – BalusC Aug 09 '11 at 18:50