|
From: Jan H. <jh...@sc...> - 2008-03-14 16:37:41
|
Hi all, I'm currently looking at the problems concerning the extra application context for the commands and the associated ApplicationWindowAware interface (relates to issue RCP-376). This is what I've done on my local machine to fix this: 1) Implemented an ApplicationWindowScope. It contains a small registry in map form to store the objects that are scoped 'window' for each ApplicationWindow. It tracks the window by listening to application events so that at the moment the that a bean is requested, it searches its 'registry' for that bean, creates if necessary and stores it. When the ApplicationWindow closes, another event will cause a removal of all stored objects for that window. 2) Refactored the ApplicationWindowSetter to listen to the same events as the scope, thus tracking the window that is active or being created at the moment. This allows the AWS to be used as a normal beanPostProcessor and by declaring it in the context your beans will get the window injected. Mind though that if you use this interface, the bean needs to be in the 'window' scope as well to manage it's lifecycle correctly. 3) Adapted the launcher to register the scope and its listener. 4) Adapted the lifecycleAdvisor to be able to not use the commands-context set as windowCommandBarDefinitions and handled in a separate context. So just use <import/> instead. 5) WindowManager and AbstractApplicationWindow are sending some extra application events to make this work. Some things to know: I've successfully adapted a small app to use the scope. I did this by using the context import, setting the menu beans in 'window scope' as well as all other beans that implement the ApplicationWindowAware interface. Mind that the whole chain should be in the correct scope: menuBean->subMenuBean->myAppWindowCommand all three need the 'window scope'. I can commit this as an additional way of configuring or I can remove the old way of having a separate application context. Not sure yet what to choose as these changes are quite new and not yet fully tested. I'm going to check the other richclient samples and see if they expose any problem with this approach. If anyone has some remarks or another view on how to implement this, please share your thoughts. Kind Regards, Jan **** DISCLAIMER **** http://www.schaubroeck.be/maildisclaimer.htm |