- Export only what you want
- Hide the implementation detail
- Java module, public in the same module
- Compilation and runtime
- Reflection
- Better encapsulation
Using java convention src/{your module name }/{your module} Example :
src/com.greetings/com/greeting/Main.java
For the sake of simplicity we are going to use IntelliJ structure.
com.greetings/src/com/greeting/Main.java
// Greeting apps
GREETING APP -> Greeting Service -> Greeting Bean
-> Greeting Reflection
Define your module with module-info.java.
- Module name
- Module requirements
Create the greeting app module which only print Hello World. This is a monolith application which contains all the necessary code.
Define your module with module-info.java.
- Module exports
Define your module with module-info.java.
- Module requires transitive and non transitive
Export Greeting Repo only to the Greeting Service.
Define your module with module-info.java.
- Module export friends
Get internal value of Greeting Bean by using deep reflection.
Define your module with module-info.java.
- Open module or opens packages
// Greeting apps
GREETING APP -> Greeting Service Interface -> Greeting Service Impl 1
-> Greeting Service Impl 2 (optional)
Define your module with module-info.java.
- Declare interface with use
- Provide implementation
- Use implementation
TBD