File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
spring-custom-event/src/main/java/com/hmkcode/beans Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .hmkcode .beans ;
2+
3+ import org .springframework .context .ApplicationEventPublisher ;
4+ import org .springframework .context .ApplicationEventPublisherAware ;
5+
6+ import com .hmkcode .event .LoginEvent ;
7+
8+ public class Login implements ApplicationEventPublisherAware {
9+
10+ private String username ;
11+ private ApplicationEventPublisher publisher ;
12+
13+ @ Override
14+ public void setApplicationEventPublisher (ApplicationEventPublisher publisher ) {
15+ this .publisher = publisher ;
16+ }
17+
18+ public void login (){
19+
20+ //do the login..
21+
22+ //fire the event
23+ LoginEvent event = new LoginEvent (this );
24+ publisher .publishEvent (event );
25+ }
26+
27+ public String getUsername () {
28+ return username ;
29+ }
30+
31+ public void setUsername (String username ) {
32+ this .username = username ;
33+ }
34+
35+ }
You can’t perform that action at this time.
0 commit comments