-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from linyimin0812/feat/20230803_health_check_u…
…pgrade_1 feat: health check upgrade
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...ore/src/main/java/io/github/linyimin0812/profiler/core/monitor/ApplicationRunMonitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package io.github.linyimin0812.profiler.core.monitor; | ||
|
||
import io.github.linyimin0812.profiler.api.EventListener; | ||
import io.github.linyimin0812.profiler.api.event.AtExitEvent; | ||
import io.github.linyimin0812.profiler.api.event.Event; | ||
import io.github.linyimin0812.profiler.common.logger.LogFactory; | ||
import io.github.linyimin0812.profiler.core.container.IocContainer; | ||
import org.kohsuke.MetaInfServices; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* @author yiminlin | ||
**/ | ||
@MetaInfServices | ||
public class ApplicationRunMonitor implements EventListener { | ||
|
||
private final Logger logger = LogFactory.getStartupLogger(); | ||
|
||
@Override | ||
public boolean filter(String className) { | ||
return "org.springframework.boot.SpringApplication".equals(className); | ||
} | ||
|
||
@Override | ||
public boolean filter(String methodName, String[] methodTypes) { | ||
|
||
if (!"run".equals(methodName) || methodTypes == null || methodTypes.length != 2) { | ||
return false; | ||
} | ||
|
||
return "java.lang.Class[]".equals(methodTypes[0]) && "java.lang.String[]".equals(methodTypes[1]); | ||
} | ||
|
||
@Override | ||
public void onEvent(Event event) { | ||
if (! (event instanceof AtExitEvent)) { | ||
return; | ||
} | ||
|
||
IocContainer.stop(); | ||
} | ||
|
||
@Override | ||
public List<Event.Type> listen() { | ||
return Collections.singletonList(Event.Type.AT_EXIT); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
logger.info("=============ApplicationRunMonitor start============="); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
logger.info("=============ApplicationRunMonitor stop============="); | ||
} | ||
} |