简体   繁体   中英

Dynamically load class in other WARs inside wildfly 11

Here I am again seeking enlightment. The situation is as follows:

We have a task engine running in Wildfly 11 that depends heavilly in dynamic loading through reflection. Don't need to say that we have an abstract "base" class for everything. It depends on database registration that uses simple Class.forName() to load the implementation. For usual work, it runs smoothly. Since our engine has different modules, we already work with jboss-deployment-structure.xml to tell Wildfly that the "Process" module depends on "Core" module and so on.

But now, we need to work with "plugins", so our customers could create their own implementations inside another package and simply register them in our database.

The question is: How do I tell Wildfly, or the classloader, or the divinity that manages it, to load the class inside the plugin without using .xml dependency files, since it would create a "regretable" circular dependency (the plugin already declares it's dependencies to the Core package)

Is it possible without hard changes in the implementation (like make the plugin init to declare itself to the core or something else)? we have a LOT of code and this kind of refactoring is not feasable at the moment.

Best Regards,

Fernando Augusto.

If you are deploying plugins together with core application in same EAR/WAR using reflection.org library should be enough to scan for plugins, either by implemented interface of some annotation. Using CDI Instance is even easier. If plugins are in separate deployment units then maybe require plugins to be JEE beans with @Remote interface and search JNDI(InitialContext) for such beans.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM