Halo plug-in capacity experimental exploration.

Overview

Halo plugin experimental

Halo 博客插件化的功能性探索。

简介

插件管理能力位于 extensions 目录下

plugins 目录下为插件示例

在插件和 Halo 主应用共用 ApplicationContext 还是 插件使用独立的 ApplicationContext的问题上:

经过实验最终还是选择插件和 Halo 使用同一个 ApplicationContext,原因如下:

  1. 插件作为独立应用使用时(即有自己独立的ApplicationContext)加载一个空插件在我的机器上需要 10s以上, 而这段时间基本都是花费在插件加载时创建插件的ApplicationContext上,如果插件功能类文件过多则会导致时间更久, 在配置低的服务器上则无法想像。
  2. 如果以插件使用独立ApplicationContext为依据开发插件功能那么当一个Halo应用存 在 10 个插件时,加载插件所耗费的时间以及插件的ApplicationContext造成的无用资源浪费也是不可容忍的。

实现

  • 自定义ScanningExtensionFinder插件类扫描器以提供对spring注解的支持
  • 插件的所有类由自定义的插件类加载器SpringPluginClassLoader加载防止名称空间伪造
  • 启用插件后将带有spring注解的插件类加载到 HaloSpring 容器中。该功能由SingletonSpringExtensionFactory完成
  • 加载时带有ExtControllerExtRestController注解的类由PluginRequestMappingManager注册到MVC

目标

  • 插件可以注入使用Halo提供的Bean

  • 插件可以像写普通的spring boot应用一样

  • 插件在开发时可以引入Halo中不存在的外部依赖

  • 插件的静态资源可以被主应用加载

  • 插件发生异常不会影响主应用及其他插件的使用(随主应用加载时,动态加载时)

  • 插件类使用独立的类加载器

  • 插件和主应用共用ApplicationContext却又能做到Bean之间的隔离

  • 主应用可以定义扩展点由插件选择性实现

  • 插件可以使用主应用定义的事件(Event)

You might also like...

TwelveMonkeys ImageIO: Additional plug-ins and extensions for Java's ImageIO

About TwelveMonkeys ImageIO is a collection of plugins and extensions for Java's ImageIO. These plugins extend the number of image file formats suppor

Jan 5, 2023

Additional plug-ins and extensions for Java's ImageIO using native libraries

NightMonkeys A collection of ImageIO plugins, adding support for newer image formats. NightMonkeys uses the newer Foreign Linker API available in JDK

Dec 3, 2022

An experimental toolset for Unity asset and asset bundle files.

DisUnity An experimental command-line toolset for Unity asset and asset bundle files written in Java, mostly designed for extraction. Download The lat

Jan 6, 2023

Experimental Netty-based Java 16 application/web framework

Experimental Netty-based Java 16 application/web framework

Experimental Netty-based application/web framework. An example application can be seen here. Should I use this? Probably not! It's still incredibly ea

Feb 17, 2022

Highly experimental and unstable alternative world format for Minecraft

Radon for Fabric An alternative world storage format that tries to be more performant and durable than vanilla's own. This is hardly more than a day's

Dec 9, 2022

Experimental validation mini-framework

ClinQ Simple yet interesting validation mini-framework Features Declarative checks ClinQ.checker(Integer.class) .with(i - i % 2 == 0) .with(i

Sep 27, 2022

Experimental Discord Mobile Rich Presence (Android)

MRPC Experimental Discord Mobile Rich Presence (Android) How does it work? It's pretty simple. Connect to the Discord Gateway as a normal Discord Clie

Dec 25, 2022

Catogram - Experimental telegram client based on official Android sources

Catogram Experimental telegram client based on official Android sources Features: Message translator TGX Style of context menu VKUI Icons and inbuilt

Dec 17, 2022

An experimental mod that converts some block entities to blockstates. This is done for performance & functionality reasons.

An experimental mod that converts some block entities to blockstates. This is done for performance & functionality reasons.

BetterBlockStates An experimental mod that converts some block entities to blockstates. This is done for performance & functionality reasons. Current

Sep 17, 2022

Intra is an experimental tool that allows you to test new DNS-over-HTTPS services that encrypt domain name lookups and prevent manipulation by your network

Intra Intra is an experimental tool that allows you to test new DNS-over-HTTPS services that encrypt domain name lookups and prevent manipulation by y

Jan 1, 2023

Mindustry v7 experimental mod.

Confictura A Mindustry v7 experimental mod. Features "Shockwave" effect, distorting the screen pixels. Slash trail effect. Building for Desktop Testin

Sep 3, 2022
Comments
  • 静态文件支持

    静态文件支持

    测试流程 以potatoes 项目为例,在resources/static 新增需要的js、css、flt等静态资源。并build(打包)

    1. 将 potatoes-1.0-SNAPSHOT-plain.jar 放入plugins插件加载目录
    2. halo 主程序启动后,当PluginManagerController#start 接口被调用,会将jar里面的resources/static 所有资源复制到 ${user.home}/halo-dev/static/{pluginId} 目录下
    3. 访问 ${halo.plugin.controller.base-path:/plugins}/web/{pluginId}/ ,就能正常访问静态资源

    本地调试

    1. core 主程序会加载工程目录 plugins/potatoes 下{pluginId}-*.jar ,将resources/static资源进行复制
    opened by cooker 4
Owner
guqing
毕生所求无它,爱与自由而已
guqing
Additional plug-ins and extensions for Java's ImageIO using native libraries

NightMonkeys A collection of ImageIO plugins, adding support for newer image formats. NightMonkeys uses the newer Foreign Linker API available in JDK

Gauthier 20 Dec 3, 2022
Experimental validation mini-framework

ClinQ Simple yet interesting validation mini-framework Features Declarative checks ClinQ.checker(Integer.class) .with(i -> i % 2 == 0) .with(i

Alexey Akhundov 13 Sep 27, 2022
Experimental Discord Mobile Rich Presence (Android)

MRPC Experimental Discord Mobile Rich Presence (Android) How does it work? It's pretty simple. Connect to the Discord Gateway as a normal Discord Clie

Duy Tran Khanh 41 Dec 25, 2022
Catogram - Experimental telegram client based on official Android sources

Catogram Experimental telegram client based on official Android sources Features: Message translator TGX Style of context menu VKUI Icons and inbuilt

null 188 Dec 17, 2022
An experimental mod that converts some block entities to blockstates. This is done for performance & functionality reasons.

BetterBlockStates An experimental mod that converts some block entities to blockstates. This is done for performance & functionality reasons. Current

Fx Morin 10 Sep 17, 2022
The most powerfull forge server software (not yet) which aims for high capacity and performance on 1.16.5 modded server.

GoldenForge The most powerfull forge server software (not yet) which aims for high capacity and performance on 1.16.5 modded server. Current work Asyn

null 20 Sep 3, 2022
Automatic Dynamodb Capacity Change Lambda

DynamoDB Provisioned Capacity Adjuster This lambda function will adjust your AWS dynamodb write capacity on the fly. If you need to adjust the provisi

null 3 May 7, 2021
Docker-compose-integration-tstst - An exploration of how to run integration tests against an application that has inconvenient external dependencies (e.g. a SQL database).

Tstst? it was supposed to be docker-compose-integration-tests but i was too lazy to fix it at the outset, and now im trying to convince myself its fun

null 1 Jan 4, 2022
An exploration for running analytics on JDK Flight Recorder recordings

JFR Analytics An exploration for running analytics on JDK Flight Recorder recordings. There's two areas of interest: Pull-based SQL queries on JFR rec

ModiTect 53 Jan 3, 2023