Skip to content

Commit 891ebb0

Browse files
author
王亮
committed
event 优化
1 parent f9983fa commit 891ebb0

File tree

11 files changed

+46
-37
lines changed

11 files changed

+46
-37
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>com.codingapi.springboot</groupId>
1212
<artifactId>springboot-framework-parent</artifactId>
13-
<version>0.0.12</version>
13+
<version>0.0.13</version>
1414

1515
<url>https://github.com/codingapi/springboot-framewrok</url>
1616
<name>springboot-framework-parent</name>

springboot-data-permission/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-framework-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>0.0.12</version>
8+
<version>0.0.13</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -32,7 +32,7 @@
3232
<dependency>
3333
<groupId>com.codingapi.springboot</groupId>
3434
<artifactId>springboot-framework</artifactId>
35-
<version>0.0.12</version>
35+
<version>0.0.13</version>
3636
</dependency>
3737

3838
<dependency>

springboot-example/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<parent>
55
<groupId>com.codingapi.springboot</groupId>
66
<artifactId>springboot-framework-parent</artifactId>
7-
<version>0.0.12</version>
7+
<version>0.0.13</version>
88
</parent>
99
<artifactId>springboot-example</artifactId>
10-
<version>0.0.12</version>
10+
<version>0.0.13</version>
1111

1212
<name>springboot-example</name>
1313
<description>springboot-example project for Spring Boot</description>
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.codingapi.springboot</groupId>
3232
<artifactId>springboot-framework</artifactId>
33-
<version>0.0.12</version>
33+
<version>0.0.13</version>
3434
</dependency>
3535

3636
<dependency>

springboot-example/src/main/java/com/codingapi/springboot/example/domain/Demo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void changeName(String name){
3737
String oldName = this.name;
3838
this.name = name;
3939

40-
EventPusher.asyncPush(new DemoNameChangeEvent(oldName,name));
40+
EventPusher.push(new DemoNameChangeEvent(oldName,name));
4141
}
4242

4343
}

springboot-framework/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
<parent>
1111
<groupId>com.codingapi.springboot</groupId>
1212
<artifactId>springboot-framework-parent</artifactId>
13-
<version>0.0.12</version>
13+
<version>0.0.13</version>
1414
</parent>
1515
<artifactId>springboot-framework</artifactId>
16-
<version>0.0.12</version>
16+
<version>0.0.13</version>
1717

1818
<name>springboot-framework</name>
1919
<description>springboot-framework project for Spring Boot</description>

springboot-framework/src/main/java/com/codingapi/springboot/framework/event/DomainEventContext.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,15 @@ private void push(IEvent event,boolean sync){
3939
*/
4040
@Deprecated
4141
public void push(IEvent event){
42-
this.syncPush(event);
43-
}
44-
45-
/**
46-
* @see EventPusher
47-
* 同步事件
48-
* @param event
49-
*/
50-
@Deprecated
51-
public void syncPush(IEvent event){
52-
this.push(event,true);
42+
if(event instanceof IAsyncEvent) {
43+
this.push(event, false);
44+
}else if(event instanceof ISyncEvent) {
45+
this.push(event, true);
46+
}else{
47+
this.push(event, true);
48+
}
5349
}
5450

55-
/**
56-
* @see EventPusher
57-
* 异步事件
58-
* @param event
59-
*/
60-
@Deprecated
61-
public void asyncPush(IEvent event){
62-
this.push(event,false);
63-
}
6451

6552
protected void initContext(ApplicationContext context){
6653
this.context = context;

springboot-framework/src/main/java/com/codingapi/springboot/framework/event/EventPusher.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,4 @@ public class EventPusher {
55
public static void push(IEvent event){
66
DomainEventContext.getInstance().push(event);
77
}
8-
9-
public static void asyncPush(IEvent event){
10-
DomainEventContext.getInstance().asyncPush(event);
11-
}
12-
13-
public static void syncPush(IEvent event){
14-
DomainEventContext.getInstance().syncPush(event);
15-
}
168
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.codingapi.springboot.framework.event;
2+
3+
/**
4+
* 异步事件
5+
*/
6+
public interface IAsyncEvent extends IEvent{
7+
8+
9+
}

springboot-framework/src/main/java/com/codingapi/springboot/framework/event/IEvent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.codingapi.springboot.framework.event;
22

33

4+
/**
5+
*
6+
* 默认同步事件
7+
*/
48
public interface IEvent {
59

610

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.codingapi.springboot.framework.event;
2+
3+
/**
4+
* 持久化同步事件
5+
*/
6+
public interface IPersistenceEvent extends ISyncEvent{
7+
8+
}

0 commit comments

Comments
 (0)