I have a web application, which will be installed in multiple companies. Each of companies have API, which I try to unify and put in separate modules. (It's a security reason, as I don't want CompanyA
to have CompanyB
's API).
So, I think it should be something like this (btw I use Maven),
external-api
module, which has only interfaces for API, something like:
interface ExternalApi {
....
}
main-application
module, which depends on external-api
and Inject's it's implementation:
@RestController
class ApiController {
@Inject
ExternalApi api;
...
}
and lots of modules, like
companyA-external-api
(also depends on external-api
) with ExternalApi
interface implementation:
@Service
class CompanyAExternalApi implements ExternalApi {
....
}
Now, as I understand, I can put external api module's output jars under application's classpath and have it classes loaded and processed by Spring.
Is this a legitimate way? Or should it be done in more automatic way (maybe there are some Maven plugins or Gradle scripts), because I'm feeling like reinventing the wheel?