T
T
tFirst2017-03-22 23:36:19
Java
tFirst, 2017-03-22 23:36:19

Connecting libraries in java?

I am writing a system that collects data from different sources. Each source has its own database.
Sources can be added to and removed from the system, so it is not known in advance which database a particular source has. And therefore for each database I want to write a library that would work with it. I assume that when the system is launched, the libraries for working with the database will have to be written new anyway.
The question, in fact, is this: how is it possible to connect / disconnect a library to a system without recompiling the systems themselves? For it is not known in advance which source the admin wants to add? Providing work with any library is not a problem, but how to connect it is a serious task.
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-03-23
@red-barbarian

Each library must have the same interface. Inherit from a single interface.
Load library by name
getClass().forName(name)
The name can be taken from the settings.
Look towards
reflection and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question