Skip to content

Commit 351de8e

Browse files
committed
Login.java
Login.java
1 parent 211d3f7 commit 351de8e

File tree

1 file changed

+35
-0
lines changed
  • spring-custom-event/src/main/java/com/hmkcode/beans

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

0 commit comments

Comments
 (0)