package cn.webfuse.demos.springevents.userdemo.publisher;

import cn.webfuse.demos.springevents.userdemo.event.UserRegisterEvent;
import cn.webfuse.demos.springevents.userdemo.model.UserBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class UserPublisher {

    @Autowired
    ApplicationContext applicationContext;

    public void register(UserBean user) {
        applicationContext.publishEvent(new UserRegisterEvent(this, user));
    }


}

@@ -294,23 +294,30 @@
 lication
-Context
+EventPublisher
 ;%0Aimport
@@ -401,16 +401,22 @@
 sher %7B%0A%0A
+    //
     @Aut
@@ -422,16 +422,18 @@
 towired%0A
+//
     Appl
@@ -468,16 +468,97 @@
 ntext;%0A%0A
+    @Autowired%0A    private ApplicationEventPublisher applicationEventPublisher;%0A%0A
     publ
@@ -610,23 +610,30 @@
 lication
-Context
+EventPublisher
 .publish

use ApplicationEventPublisher