Java: Dynamically Load Multiple Versions of Same Class

前端 未结 7 947
一整个雨季
一整个雨季 2021-01-01 01:14

What I\'d like to be able to do is to load set of classes, probably all in the same folder. All of which implement the same interface and are the same class, then in my code

7条回答
  •  醉话见心
    2021-01-01 01:39

    The only framework I know which does support what you are after is OSGI:

    Its network model, described in this article "Exposing the boot classpath in OSGi", does allow that

    One of the side effects (or aims) of the networking model is type isolation or class versioning: multiple version of the same class can coexist nicely inside the same VM since each one is loaded into its own network, its own space.

    See this tutorial for beginning and choose on eof the OSGI Framework (like Equinox, Knoplerfish or Apache Felix)

提交回复
热议问题