|
From: Matt S. <sga...@us...> - 2005-03-02 13:37:07
|
SPR-596 outlines a more robust algorithm for initializing and applying the BeanFactoryPostProcessors for Spring 1.2. The SPR does not address BeanPostProcessors, and I think we should spend some time discussing them as well. Basically, I'd like for the invocation order of the two types of PostProcessors to be configurable via the Ordered interface. The main problem as I see it is that it's not intuitive which of the PostProcessors are applied first: BeanFactoryPostProcessors or BeanPostProcessors? I think the "PostProcessor" suffix for these two different types of objects indicates that they are in some sense the same type of thing, even if they don't share a common super-interface. In Spring 1.1, BeanFactoryPostProcessors are applied before BeanPostProcessors, presumably so that BeanFactoryPostProcessors have a chance to programmatically register additional beans, which can then be operated on by BeanPostProcessors. Although that logic makes sense, I don't think anyone reading up on the two types of post processors would come to that deduction automatically. Further, I've run into scenarios where I wanted to apply a BeanPostProcessor first and then a BeanFactoryPostProcessor, but I was out of luck. I think the solution is straightforward: allow the invocation order of BeanPostProcessors and BeanFactoryPostProcessors to be configured using the Ordered interface. I thought I would open up this discussion here, since Spring 1.2 is now on the horizon. I want to make sure this discussion takes place before SPR-596 is worked on. For the full bug report, go here: http://opensource.atlassian.com/projects/spring/browse/SPR-596 The crux of the bug report is in the very last comment posted by me: If I understand correctly, the current implementation runs like this: 1) Instantiate all BeanFactoryPostProcessors 2) Wire all BeanFactoryPostProcessors 3) Apply the BeanFactoryPostProcessors in order I think this sequence is more robust: 1) Find all the BeanFactoryPostProcessors 2) Arrange the post processors with those that implement Ordered first (in ascending Order), followed by those that do not implement Ordered 3) For each BeanFactoryPostProcessor from #2, a) Instantiate the BeanFactoryPostProcessor b) Wire the processor c) apply the processor Matt |