|
From: Tom T. <tom...@pr...> - 2004-12-07 07:48:33
|
Hello, Would it be possible to provide a way to destroy a specific instance of a prototype bean? I've implemented a RecreateableMixinAdvisor that introduces an interface with a single method, recreate(), on advised objects. Using a HotSwappableTargetSource, I create a singleton bean that targets an instance of a prototype bean. When you call recreate(), a new prototype instance is swapped in, and the old one is swapped out and destroyed after a specified wait time. This all works fine, except there's no decent way to destroy the old instance. I ended up copy-pasting AbstractBeanFactory's invokeCustomDestroyMethod(), which does what I want, but is not accessible. It would be nice if invokeCustomDestroyMethod()'s implementation could be reused (e.g. move to BeanUtils), but since I have the bean factory, bean name and bean instance available, maybe the bean factory could provide a destroyPrototypeBeanInstance(String beanName, Object bean) method instead? This method could then use the destroy-method specified on the prototype bean definition. Of course, the bean factory would have no way to verify the relation between the provided beanName and bean... In case you're wondering, we're using this with a Commons DBCP data source, but there may be other use cases. Thanks, Tom. |