2

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?

Semyon Danilov
  • 1,753
  • 1
  • 17
  • 37
  • So you publish a module of interfaces called **external-api**, having each company implement the interfaces. Also, you supply web access module called **main-application** that only knows **external-api**, right? That sounds simple and nicely de-coupled. The only issue I can suggest is that the web access module should better be called something like **web-api**. The main application is actually what your customers are implementing. – Ossin Java guy Apr 04 '18 at 10:34

0 Answers0