Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Component
- public class SpringContext implements ApplicationContextAware {
- private static ApplicationContext context;
- @Autowired
- public void setApplicationContext(ApplicationContext context) throws BeansException {
- this.context = context;
- }
- public static void autowireBean(Object bean){
- AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
- bpp.setBeanFactory(context.getAutowireCapableBeanFactory());
- bpp.processInjection(bean);
- }
- }
- public abstract class AggregateRoot {
- {
- SpringContext.autowireBean(this);
- }
- }
- class MyAggregate extends AggregateRoot {
- @Autowired
- private MyComp myComp;
- public MyAggregate(String test, String testToo) {
- this.test = test;
- this.testToo = testToo;
- }
- private String test;
- private String testToo;
- public String getTest() {
- return test;
- }
- public String getTestToo() {
- return testToo;
- }
- public String getOk(){
- return myComp.ok;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement