I love Autowired and Component. My apps tend to be on the smaller so these suffice for 99% of my use cases and I directly instantiate and operate on spring managed beans.
I need for my latest requirement to be able to programmatically access the context this bean is part of, and operate on other beans in the context. I see you can implement BeanFactoryAware and then use that, but I was wondering if there annotations for context-level items. Also does the same thing exist for init and destroy so I don't have to drop down to xml for that?
That seems like it would be a little more friendly in spring terms - you still are "tying yourself" to spring, but I don't care about that. I used to be very xml-oriented, but the annotations are really are so useful I've completely forgotten about any hesitation to include them in the code.Code:public class ContextOperator { // either of these would be awesome @BeanFactory private BeanFactory factory; @ApplicationContext private ApplicationContext context; @Init public void load() { } @Destroy public void close() { } public void doStuff() { context.getBean("adsf") etc... } }


Reply With Quote
