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

Heiko Braun hbraun at redhat.com
Wed Jul 27 03:42:08 EDT 2016


Maybe using the ServiceLoader?

https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html <https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html>

This should work fine with JBoss Modules as well.

/Heiko

> On 27 Jul 2016, at 09:26, Martin Kouba <mkouba at redhat.com> wrote:
> 
> 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
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/wildfly-dev/attachments/20160727/a0597fc5/attachment.html 


More information about the wildfly-dev mailing list