|
From: Colin S. <col...@ex...> - 2003-12-09 15:28:38
|
Tim McAuley wrote: > Colin Sampaleanu wrote: > >> I've modified the EJB support code to allow a user subclass of >> AbstractStatelessSessionBean to call a new method unloadBeanFactory() >> from ejbPassivate (which it should implement itself). The subclass >> should call the existing loadBeanFactory() from ejbCreate() and >> ejbActivate(). As well, the default implementation of ejbRemove >> which is in AbstractEnterpriseBean now calls the new >> unloadBeanFactory() method. There is one change that may affect >> some existing code, and that is that in the process of adding the >> above, I modified the existing BeanFactoryLoader interface to handle >> unloading as well as loading of a beanfactory. >> >> These changes should allow you to use a Stateful Session bean >> properly even wtih passivation and activation happening. >> >> Regards, >> Colin > > > Colin and others, > > We've come across another issue to do with the passivation of beans. > While our stateful session bean holds an instance of the bean factory > itself (and can control re-initialising it), it is very possible that > other standalone beans have a copy of the bean factory as well. If the > stateful session bean has references to these other beans then it > becomes very difficult to handle. > > Is there any reason that the BeanFactory (and Loader) is not > serializable. It would make it much easier to handle if they were. > > Example of problem: > > StatefulSessionBeanA HAS BusinessBeanB HAS BusinessBeanC HAD DAOBeanD > > + The Stateful Session bean will load the BeanFactory and lookup > BusinessBeanB. > + BusinessBeanB has the BeanFactory initialised through the > ApplicationContext.xml file. > + BusinessBeanB looks up BusinessBeanC using the BeanFactory. > + BusinessBeanC initialising DAOBeanD through the > ApplicationContext.xml file. > > In this case, the stateful session bean has problems serializing > BusinessBeanB due to the BeanFactory (XMLBeanFactory in this case). > > Any thoughts? > > Many thanks! > > Tim > > PS did you mean AbstractStatelessSessionBean or > AbstractStatefulSessionBean above? Stateless beans are not > passivated/activated. > Of course I meant AbstractStatefulSessionBean, not Stateless... W/regards to making BeanFactory serializable, Rod and Juergen would probably be able to best answer as to why it's not. I can't see much of a reason, to tell you the truth, so it's probably just historical. ApplicationContext (or most of its implementations rather) can not be serializable due to all the non-serializable classes used. So whether making BeanFactory serializable is useful to you depends on where you are actually using just a BeanFactory, with basic serializable beans in it, or are in fact using an ApplicationContext, with AOP, and things like interceptors and transaction managers inside it. Regards, Colin |