Fix the problem of starting reconcilers in plugin before registering scheme (#5271)

#### What type of PR is this?

/kind bug
/area core
/area plugin
/milestone 2.12.0

#### What this PR does / why we need it:

This PR adjusts the order of starting reconcilers in plugin, or it will be stuck in starting synchronizer and no reconcilers will be executed.

The problem may be introduced by <https://github.com/halo-dev/halo/pull/5251>.

#### Does this PR introduce a user-facing change?

```release-note
None
```
pull/5134/head^2
John Niang 2024-01-29 15:18:20 +08:00 committed by GitHub
parent e2b8d6e1f9
commit 82d2afc6ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 5 deletions

View File

@ -3,14 +3,14 @@ package run.halo.app.plugin;
import static org.springframework.core.ResolvableType.forClassWithGenerics;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import reactor.core.Disposable;
import run.halo.app.extension.ExtensionClient;
import run.halo.app.extension.controller.Controller;
import run.halo.app.extension.controller.ControllerBuilder;
import run.halo.app.extension.controller.Reconciler;
import run.halo.app.plugin.event.SpringPluginStartedEvent;
import run.halo.app.plugin.event.SpringPluginStoppingEvent;
public class PluginControllerManager {
@ -24,8 +24,8 @@ public class PluginControllerManager {
}
@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) {
event.getApplicationContext()
public void onApplicationEvent(SpringPluginStartedEvent event) {
event.getSpringPlugin().getApplicationContext()
.<Reconciler<Reconciler.Request>>getBeanProvider(
forClassWithGenerics(Reconciler.class, Reconciler.Request.class))
.orderedStream()
@ -33,7 +33,7 @@ public class PluginControllerManager {
}
@EventListener
public void onApplicationEvent(ContextClosedEvent event) throws Exception {
public void onApplicationEvent(SpringPluginStoppingEvent event) throws Exception {
controllers.values()
.forEach(Disposable::dispose);
controllers.clear();