-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into refactor/4610
# Conflicts: # application/src/main/java/run/halo/app/plugin/PluginAutoConfiguration.java
- Loading branch information
Showing
17 changed files
with
763 additions
and
626 deletions.
There are no files selected for viewing
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
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,27 @@ | ||
package run.halo.app.plugin; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.pf4j.RuntimeMode; | ||
|
||
/** | ||
* <p>This class will provide a context for the plugin, which will be used to store some | ||
* information about the plugin.</p> | ||
* <p>An instance of this class is provided to plugins in their constructor.</p> | ||
* <p>It's safe for plugins to keep a reference to the instance for later use.</p> | ||
* <p>This class facilitates communication with application and plugin manager.</p> | ||
* <p>Pf4j recommends that you use a custom PluginContext instead of PluginWrapper.</p> | ||
* <a href="https://github.com/pf4j/pf4j/blob/e4d7c7b9ea0c9a32179c3e33da1403228838944f/pf4j/src/main/java/org/pf4j/Plugin.java#L46">Use application custom PluginContext instead of PluginWrapper</a> | ||
* | ||
* @author guqing | ||
* @since 2.10.0 | ||
*/ | ||
@Getter | ||
@RequiredArgsConstructor | ||
public class PluginContext { | ||
private final String name; | ||
|
||
private final String version; | ||
|
||
private final RuntimeMode runtimeMode; | ||
} |
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
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
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
34 changes: 34 additions & 0 deletions
34
application/src/main/java/run/halo/app/plugin/HaloPluginWrapper.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,34 @@ | ||
package run.halo.app.plugin; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import org.pf4j.PluginDescriptor; | ||
import org.pf4j.PluginManager; | ||
import org.pf4j.PluginWrapper; | ||
import org.pf4j.RuntimeMode; | ||
|
||
/** | ||
* A wrapper over plugin instance for Halo. | ||
* | ||
* @author guqing | ||
* @since 2.10.0 | ||
*/ | ||
public class HaloPluginWrapper extends PluginWrapper { | ||
|
||
private final RuntimeMode runtimeMode; | ||
|
||
/** | ||
* Creates a new plugin wrapper to manage the specified plugin. | ||
*/ | ||
public HaloPluginWrapper(PluginManager pluginManager, PluginDescriptor descriptor, | ||
Path pluginPath, ClassLoader pluginClassLoader) { | ||
super(pluginManager, descriptor, pluginPath, pluginClassLoader); | ||
this.runtimeMode = Files.isDirectory(pluginPath) | ||
? RuntimeMode.DEVELOPMENT : RuntimeMode.DEPLOYMENT; | ||
} | ||
|
||
@Override | ||
public RuntimeMode getRuntimeMode() { | ||
return runtimeMode; | ||
} | ||
} |
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
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
Oops, something went wrong.