concept cyclic dependency in category java

appears as: cyclic dependencies, cyclic dependency
The Java Module System

This is an excerpt from Manning's book The Java Module System.

Then you have monitor.rest, which also depends on the statistics module because it handles statistics. Beyond that, it uses the Spark micro framework to create the REST endpoint. When modularizing the application in section 2.2.1, I made a point that MonitorServer doesn’t depend on Monitor. That comes in handy now because it means monitor.rest doesn’t depend on monitor; this is great because monitor depends on monitor.rest, and the module system forbids declaring cyclic dependencies. Finally, monitor depends on all the other modules because it creates most instances and pipes the results from one into the other.

Figure 3.5 Getting dependency cycles past the compiler isn’t easy. Here it’s done by picking two unrelated modules, persistence and rest (both depend on statistics), and then adding dependencies from one to the other. It’s important to compile rest against the old persistence so the cycle doesn’t show and compilation passes. In a final step, both original modules can be replaced with the newly compiled ones that have the cyclic dependency between them.

c03_05.png

We’ll also look into using services to break cyclic dependencies between modules (section 10.3.5). Last but not least—and this is particularly interesting for those who plan to use services on different Java versions—we discuss how services work across plain and modular JARs (section 10.3.6).

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest