Will you be distributing them separately? If not you don't need to dynamically load the jars or reflect them.
Your app can reference all jars. Here is the dependencies you could have:
|Application Jar |
↓ ↓ ↓
↓ |Region 1 Jar| |Region 2 Jar|
↓ ↓ ↓
|Core Jar |
Core Jar
is region agnostic but has one or more interfaces for what it requires from a region. Region jars
have classes that implement those core interfaces and the Application jar
is responsible for constructing the right region classes and plugging it all together.
If the Regions are outside of your control, and they can't depend on Core or implement it's interfaces you can use adapters:
|Application Jar |
↓ ↓ ↓
↓ |Region 1 Jar Adapter| |Region 2 Jar Adapter|
↓ ↓ ↓ ↓
|Core Jar | ↓ ↓
|Region 1 Jar| |Region 2 Jar|
Here Region 1
and Region 2
are anything you like, they have no dependencies. Only one package has a dependency on them, and that is it's adapter package. The Adapter supports a core interface and knows how to translate the calls to the underlying Region Jar. The application is identical to the previous situation.