[wildfly-dev] How to work with an optional module dependency

Martin Kouba mkouba at redhat.com
Wed Jul 27 03:26:13 EDT 2016


Hi all,

the Weld/CDI team is working on SWARM-568 [1] - to slim the module 
dependencies of the Weld subsystem. We will need to modify Weld 
subsystem so that some dependencies (EJB, JPA, etc.) are optional. And 
this brings additional complexity in the code.

I wonder whether there are any 
tips/recommendations/guidelines/examples/etc how to work with an 
optional module dependency?

More specifically, what is the best approach to detect a module 
availability? In Java SE one would usually take the ClassLoader and try 
to load some specific class...

Also what is the safe and reliable way of "handling" the code which 
depends on an optional module. It seems a JVM impl may choose to link 
everything up front. So I think the only way is to create a separate 
class containing all the logic and call this class via reflection.

Thanks a lot,

Martin

[1]
https://issues.jboss.org/browse/SWARM-568


-- 
Martin Kouba
Software Engineer
Red Hat, Czech Republic


More information about the wildfly-dev mailing list