Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Simplify halo plugin manager #5251

Merged
merged 6 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package run.halo.app;

import org.springframework.context.ApplicationContext;

public interface PluginApplicationContextFactory {

/**
* Create and refresh application context.
*
* @param pluginId plugin id
* @return refresh application context for the plugin.
*/
ApplicationContext create(String pluginId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ private void resolveStaticResources(Plugin plugin) {
var p = pluginManager.getPlugin(pluginName);
var classLoader = p.getPluginClassLoader();
var resLoader = new DefaultResourceLoader(classLoader);
var entryRes = resLoader.getResource("classpath:/console/main.js");
var cssRes = resLoader.getResource("classpath:/console/style.css");
var entryRes = resLoader.getResource("classpath:console/main.js");
var cssRes = resLoader.getResource("classpath:console/style.css");
if (entryRes.exists()) {
var entry = UriComponentsBuilder.newInstance()
.pathSegment("plugins", pluginName, "assets", "console", "main.js")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public Controller setupWith(ControllerBuilder builder) {

private void registerReverseProxy(ReverseProxy reverseProxy) {
String pluginId = getPluginId(reverseProxy);
routerFunctionRegistry.register(pluginId, reverseProxy).block();
routerFunctionRegistry.register(pluginId, reverseProxy);
}

private void cleanUpResources(ReverseProxy reverseProxy) {
String pluginId = getPluginId(reverseProxy);
routerFunctionRegistry.remove(pluginId, reverseProxy.getMetadata().getName()).block();
routerFunctionRegistry.remove(pluginId, reverseProxy.getMetadata().getName());
}

private void addFinalizerIfNecessary(ReverseProxy oldReverseProxy) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package run.halo.app.infra;

import com.github.zafarkhaja.semver.Version;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Objects;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.info.BuildProperties;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

/**
Expand All @@ -17,21 +16,19 @@
public class DefaultSystemVersionSupplier implements SystemVersionSupplier {
private static final String DEFAULT_VERSION = "0.0.0";

@Nullable
private BuildProperties buildProperties;
private final ObjectProvider<BuildProperties> buildProperties;

@Autowired(required = false)
public void setBuildProperties(@Nullable BuildProperties buildProperties) {
public DefaultSystemVersionSupplier(ObjectProvider<BuildProperties> buildProperties) {
this.buildProperties = buildProperties;
}

@Override
public Version get() {
if (buildProperties == null) {
var properties = buildProperties.getIfUnique();
if (properties == null) {
return Version.valueOf(DEFAULT_VERSION);
}
String projectVersion =
StringUtils.defaultString(buildProperties.getVersion(), DEFAULT_VERSION);
var projectVersion = Objects.toString(properties.getVersion(), DEFAULT_VERSION);
return Version.valueOf(projectVersion);
}
}

This file was deleted.

Loading
Loading