Maybe using the ServiceLoader?

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@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/wildfly-dev