How to work with an optional module dependency

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to work with an optional module dependency

Martin Kouba
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
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to work with an optional module dependency

Heiko Braun
Maybe using the ServiceLoader?


This should work fine with JBoss Modules as well.

/Heiko

On 27 Jul 2016, at 09:26, Martin Kouba <[hidden email]> 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
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev


_______________________________________________
wildfly-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/wildfly-dev