Giter Club home page Giter Club logo

Comments (12)

hank-cp avatar hank-cp commented on August 16, 2024

I have commit demonstration code of building plugin jar. Please checkout 9107e87 for more details. Also, you could read the doc describe further more.

Regarding to

Managing plugins with the shape of spring boot application, is SBP library aware to search classes under BOOT-INF folder?

the quick answer is no. I recommand search plugins jar via file system, rather than searching classpath. It's design to load/unload plugins dynamically at runtime time. If you use classpath, sbp has not difference as other ordinary monolithic Spring Boot application.

from sbp.

fabioformosa avatar fabioformosa commented on August 16, 2024

I recommand search plugins jar via file system, rather than searching classpath

I'm added the plugin jar via file system, but my jar is a spring boot executable jar, not a standard jar. Look at this link to browser the structure of a spring boot executable jar: https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-executable-jar-format.html#executable-jar-jar-file-structure

You've done a wonderful work with this library, but since it addresses pluggability of spring boot apps, I'm expecting that it's possible to provide via filesystem a spring boot executable jar because it's a standard way to build for spring.

So, according your opinion, loading a plugin jar with that structure, is it possibile to specify to sbp plugin loader the path (inside jar): /BOOT-INF/classes and /BOOT-INF/libs?
I've tried with classes-directories properties but it doesn't work in deployment mode.

EDIT: I've just tried to load a standard jar (not spring boot executable jar ) assembling manually it with "libs" and it run OK. I think it could be more convenient to load a spring boot executable jar, because it contains all libs by default.

from sbp.

hank-cp avatar hank-cp commented on August 16, 2024

got your point.

I think this could be done by add a custom PluginLoader. Right now SbpAutoConfiguration.pluginManager use two PluginLoader as here and here. You could implement an ExecutableJarPluginLoader to locate the dependent jars in BOOT-INFO/libs, and then add it to SbpAutoConfiguration.pluginManager by overridding it.

from sbp.

fabioformosa avatar fabioformosa commented on August 16, 2024

Thank you for the answer. Now, it's clear to me how to define a new PluginLoader in the PluginManager bean.
I think that the ExecutableJarPluginLoader should use an extended version of your SpringBootPluginClassLoader. Could you help me to understand which method to override in SpringBootPluginClassLoader to locate (inside the jar) classes and libs into the folders BOOT-INFO/classes and BOOT-INFO/libs ?

from sbp.

hank-cp avatar hank-cp commented on August 16, 2024

I have just added a configuration spring.sbp.custom-plugin-loaders to allow you customize your own PluginLoader (example)

You could use the SNAPSHOT version to experience it.

from sbp.

fabioformosa avatar fabioformosa commented on August 16, 2024

Good, so it's easier to add a custom plugin loader. Very nice!
But I don't understand yet how to develop this custom plugin loader to load classes from a jar with the structure of a spring-executable-jar.
It should be like the native JarPluginLoader but with an extendend SpringBootPluginClassLoader , I suppose.
Which method should I override in SpringBootPluginClassLoader to locate (inside the jar) classes and libs into the folders BOOT-INFO/classes and BOOT-INFO/libs ?

from sbp.

hank-cp avatar hank-cp commented on August 16, 2024

I don't suggest you to extend SpringBootPluginClassLoader. There are complex class loading strategies behind it.

What you have to do now is to load jars inside a jar. Looks like there are no out-of-box solution till today(can't believe that >_<!). Here is antoher example.

Then you could implement a custom FatJarPluginLoader, who holds the PluginClassLoader, and tell this PluginClassLoader to load the jars by pluginClassLoader.addFile(myJarFile); just as other PluginLoader did.

from sbp.

fabioformosa avatar fabioformosa commented on August 16, 2024

What you have to do now is to load jars inside a jar

Not only jars, also the classes are in another folder (BOOT-INF/classes) inside the plugin.jar

from sbp.

fabioformosa avatar fabioformosa commented on August 16, 2024

With spring.sbp.custom-plugin-loaders does the CustomPluginLoader replace the default ones or add itself to the list of default loaders?

from sbp.

hank-cp avatar hank-cp commented on August 16, 2024

adding, after the builtin pluginLoader DefaultPluginLoader/JarPluginLoader

from sbp.

fabioformosa avatar fabioformosa commented on August 16, 2024

Ok, I would need to remove/replace JarPluginLoader because it's apply to all jars. I would like to have an extended JarPluginLoader that supports standard jar and spring boot jar.

from sbp.

hank-cp avatar hank-cp commented on August 16, 2024

Have make custom-plugin-loader exclusive as #13 mentioned.

from sbp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.