動的に記述およびロードされる拡張機能をサポートする JAR アプリケーション M.jar があります。アプリケーションでは、クラスがインターフェイス E を実装し、NE と呼ばれることが必要です。
今、私がやろうとしていることは次のとおりです。
- 拡張 API1 を作成し、M にロードします。
- 別の拡張 APIUser を作成し、それを M にロードして、API1 を使用します。
私がここでやろうとしていることについては、下の図を参照してください。
M.jar はカスタム ClassLoader を使用することを知っています。これは、拡張子を AE のみにする必要があるためです。
I tried the ServiceProvider, ServiceProviderInterface method as described here but that did not work. I believe this is because API's classes are not in M's classpath and hence APIUser cannot find it.
I want to know,
- If it is feasible to use APIUser's ClassLoader to load API's class and initialize it for use in APIUser.
- Is it possible for M to block/isolate API's ClassLoader from any other extensions? I think it can be based off of this answer.
- What other means are there to load API's class in APIUser1 or APIUSer2 ... and maintain only one instance of API's class? (i.e singleton)