Hi again,
I would like to seperate my buisness logic from the data layer. Say I
have an object Person, that has the fields id, firstName and lastName.
The only constructor I provide is one which takes two arguments (id,
firstName and lastName). The person objects will be stored in a certain
Database, but this may change in the future, this is why I use a
factory. The factory takes an id, connects to the DB, retrieves the
data, creates the Person object and returns it.
This pattern also comes in handy, when you have classes that inherit
from Person. If the DB access would happen in the constructor, one could
only create Person objects, with a factory, you can create an object of
the real type instead.
Anyway, what I want is to get a DataSource without knowing about a
servlet. Is this somehow possible? Is there some static access to the
DataSource Repository?
Tia,
Andreas