For the project I'm working on I was thinking to create a Java Module for each layer of my system:
servlet-presentation
defines the implementation of the presentation layer. It is composed by Java Servlets that call the layer below and by JSPs that represent the view (Also JS, CSS...)business
represents the service classes of the application, that contains the business logic.entity-api
represents the entity classes and the interfaces for their repositories, to isolate thebusiness
module from infrastructure code.entity-hibernate
represents an implementation ofentity-api
This is a simple approach that should do the trick for what I want to achieve: modularity for the presentation and persistence layer. (I may choose to add resteasy-presentation
one day, or entity-eclipselink
one day)
However, I'd also like a way to vertically partition the elements that compose my system for communication purposes. For this reason I wanted to use the plain old Java packages: classes in different layers that may adhere to the same use cases should be put in the same package. However, different Java Modules cannot have a package of the same name. What could be a way to achieve optimally split my codebase?