Dynamically loading plugin jars using ServiceLoader

后端 未结 3 707
南笙
南笙 2020-12-02 07:12

I\'m trying to create a plugin system for my application, and I want to start with something simple. Every plugin should be packed in a .jar file and implement the Sim

3条回答
  •  抹茶落季
    2020-12-02 07:49

    Starting from Java 9 the service providing scanning will be much easier and efficient. No more need for META-INF/services.

    In the interface module declaration declare:

    uses com.foo.spi.Service;
    

    And in the provider's module:

    provides com.foo.spi.Service with com.bar.ServiceImplementation
    

提交回复
热议问题