<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Maybe using the ServiceLoader?<div class=""><br class=""></div><div class=""><a href="https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html" class="">https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html</a></div><div class=""><br class=""></div><div class="">This should work fine with JBoss Modules as well.<br class=""><div class=""><br class=""></div><div class="">/Heiko</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 27 Jul 2016, at 09:26, Martin Kouba <<a href="mailto:mkouba@redhat.com" class="">mkouba@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi all,<br class=""><br class="">the Weld/CDI team is working on SWARM-568 [1] - to slim the module <br class="">dependencies of the Weld subsystem. We will need to modify Weld <br class="">subsystem so that some dependencies (EJB, JPA, etc.) are optional. And <br class="">this brings additional complexity in the code.<br class=""><br class="">I wonder whether there are any <br class="">tips/recommendations/guidelines/examples/etc how to work with an <br class="">optional module dependency?<br class=""><br class="">More specifically, what is the best approach to detect a module <br class="">availability? In Java SE one would usually take the ClassLoader and try <br class="">to load some specific class...<br class=""><br class="">Also what is the safe and reliable way of "handling" the code which <br class="">depends on an optional module. It seems a JVM impl may choose to link <br class="">everything up front. So I think the only way is to create a separate <br class="">class containing all the logic and call this class via reflection.<br class=""><br class="">Thanks a lot,<br class=""><br class="">Martin<br class=""><br class="">[1]<br class=""><a href="https://issues.jboss.org/browse/SWARM-568" class="">https://issues.jboss.org/browse/SWARM-568</a><br class=""><br class=""><br class="">-- <br class="">Martin Kouba<br class="">Software Engineer<br class="">Red Hat, Czech Republic<br class="">_______________________________________________<br class="">wildfly-dev mailing list<br class="">wildfly-dev@lists.jboss.org<br class="">https://lists.jboss.org/mailman/listinfo/wildfly-dev<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>