forked from aofeng/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientMain.java
More file actions
33 lines (25 loc) · 955 Bytes
/
ClientMain.java
File metadata and controls
33 lines (25 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cn.aofeng.demo.eventdriver_normal;
/**
* 事件驱动调用示例
* @author aofeng <aofengblog@163.com>
*/
public class ClientMain {
public static void main(String[] args) {
EventSource eventSource = new EventSource();
eventSource.addListener(new HelloWorldListener());
eventSource.addListener(new SimpleListener());
eventSource.fire("hello, world!");
}
public static class HelloWorldListener implements EventListener {
@Override
public void execute(Event event) {
System.out.println("监听器:"+this + "接收到事件,事件附带的数据:" + event.getData());
}
}
public static class SimpleListener implements EventListener {
@Override
public void execute(Event event) {
System.out.println("监听器:"+this + "接收到事件,事件附带的数据:" + event.getData());
}
}
}