Skip to content

Commit f5b665d

Browse files
committed
fix getTriggerClass bug
1 parent fe036fc commit f5b665d

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>1.5.7</version>
15+
<version>1.5.8</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<name>springboot-parent</name>

springboot-starter-data-fast/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>1.5.7</version>
8+
<version>1.5.8</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-id-generator/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>1.5.7</version>
8+
<version>1.5.8</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-security-jwt/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>1.5.7</version>
9+
<version>1.5.8</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security-jwt</artifactId>

springboot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>1.5.7</version>
8+
<version>1.5.8</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

springboot-starter/src/main/java/com/codingapi/springboot/framework/trigger/TriggerContext.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private TriggerContext(){
3838
* @param handler 触发订阅
3939
*/
4040
public void addTrigger(TriggerHandler handler){
41-
Class<? extends Trigger> clazz = getTriggerClass(handler);
41+
Class<? extends Trigger> clazz = getTriggerClass(handler.getClass());
4242
List<TriggerHandler> triggerList = this.triggers.get(clazz);
4343
if(triggerList==null){
4444
triggerList = new CopyOnWriteArrayList<>();
@@ -53,9 +53,14 @@ public void addTrigger(TriggerHandler handler){
5353
* @param handler 触发订阅
5454
* @return Trigger类型
5555
*/
56-
private Class<? extends Trigger> getTriggerClass(TriggerHandler handler){
57-
ParameterizedType parameterizedType = (ParameterizedType) handler.getClass().getGenericInterfaces()[0];
58-
return (Class<? extends Trigger>) parameterizedType.getActualTypeArguments()[0];
56+
private Class<? extends Trigger> getTriggerClass(Class<?> handler){
57+
for(Class<?> superInterface : handler.getInterfaces()) {
58+
if (superInterface.equals(TriggerHandler.class)) {
59+
ParameterizedType parameterizedType = (ParameterizedType) handler.getGenericInterfaces()[0];
60+
return (Class<? extends Trigger>) parameterizedType.getActualTypeArguments()[0];
61+
}
62+
}
63+
return getTriggerClass(handler.getSuperclass());
5964
}
6065

6166

@@ -67,7 +72,7 @@ public void trigger(Trigger trigger){
6772
Class<? extends Trigger> clazz = trigger.getClass();
6873
List<TriggerHandler> triggerHandlerList = triggers.get(clazz);
6974
for(TriggerHandler handler:triggerHandlerList){
70-
Class<? extends Trigger> triggerClass = getTriggerClass(handler);
75+
Class<? extends Trigger> triggerClass = getTriggerClass(handler.getClass());
7176
if(triggerClass.equals(clazz)) {
7277
try {
7378
boolean canTrigger = handler.preTrigger(trigger);

0 commit comments

Comments
 (0)