Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

1. update 2.2.7-SNAPSHOT #823

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</modules>

<properties>
<sofa.ark.version>2.2.6</sofa.ark.version>
<sofa.ark.version>2.2.7-SNAPSHOT</sofa.ark.version>
<project.encoding>UTF-8</project.encoding>
<java.version>1.8</java.version>
<license.maven.plugin>3.0</license.maven.plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.boot.loader.LaunchedURLClassLoader;
import org.springframework.context.ApplicationListener;

/**
Expand All @@ -40,15 +39,32 @@ public class ArkApplicationStartListener implements ApplicationListener<SpringAp

private static final String LAUNCH_CLASSLOADER_NAME = "sun.misc.Launcher$AppClassLoader";
private static final String SPRING_BOOT_LOADER = "org.springframework.boot.loader.LaunchedURLClassLoader";
//SpringBoot 3.2.0 support
private static final String SPRING_BOOT_NEW_LOADER = "org.springframework.boot.loader.launch.LaunchedClassLoader";
private static final String APPLICATION_STARTED_EVENT = "org.springframework.boot.context.event.ApplicationStartedEvent";
private static final String APPLICATION_STARTING_EVENT = "org.springframework.boot.context.event.ApplicationStartingEvent";
private static Class<?> SPRING_BOOT_LOADER_CLASS;
private static Class<?> SPRING_BOOT_NEW_LOADER_CLASS;

static {
try {
SPRING_BOOT_LOADER_CLASS = ApplicationListener.class.getClassLoader().loadClass(
SPRING_BOOT_LOADER);
} catch (Throwable t) {
// ignore
}
try {
SPRING_BOOT_NEW_LOADER_CLASS = ApplicationListener.class.getClassLoader().loadClass(
SPRING_BOOT_NEW_LOADER);
} catch (Throwable t) {
// ignore
}
}

@Override
public void onApplicationEvent(SpringApplicationEvent event) {
try {
if (ArkConfigs.isEmbedEnable()
|| LaunchedURLClassLoader.class.isAssignableFrom(this.getClass().getClassLoader()
.getClass())) {
if (isEmbedEnable()) {
ArkConfigs.setEmbedEnable(true);
startUpArkEmbed(event);
return;
Expand All @@ -67,6 +83,23 @@ public void onApplicationEvent(SpringApplicationEvent event) {
}
}

private boolean isEmbedEnable() {
if (ArkConfigs.isEmbedEnable()) {
return true;
}
if (SPRING_BOOT_LOADER_CLASS != null
&& SPRING_BOOT_LOADER_CLASS.isAssignableFrom(this.getClass().getClassLoader()
.getClass())) {
return true;
}
if (SPRING_BOOT_NEW_LOADER_CLASS != null
&& SPRING_BOOT_NEW_LOADER_CLASS.isAssignableFrom(this.getClass().getClassLoader()
.getClass())) {
return true;
}
return false;
}

public void startUpArk(SpringApplicationEvent event) {
if (LAUNCH_CLASSLOADER_NAME.equals(this.getClass().getClassLoader().getClass().getName())) {
SofaArkBootstrap.launch(event.getArgs());
Expand Down
Loading