I have a
Dao interface which doesn't have any methods defined.
Then I have multiple classes which implement this interface, like
For some of the implementation classes, and some of their methods, I need to do an operation.
Let's say this operation is defined in the
Operation class, and the method is
PetDao has several methods:
Pet selectPet(int petId),
void insertPet(PetDto pet), and I only want to call
HouseDao has several methods:
House selectHouse(int houseId),
void deleteHouse(int houseId), and I only want to call
I cannot modify the Dao interface. Neither of these classes are instantiated manually, they are all injected.
I could change
HouseDao code to statically call
doOperation(). But this would mean that the Dao classes would have another responsibility than the originally intended, and that I would have a big impact on the source code (there are multiple Daos with multiple methods that I need to track).
I cannot use the Decorator Pattern because
Dao interface does not have any methods.
Are there other options, besides AOP, to achieve this?
doOperationmethod in it, and have each DTO implement that interface?
But this would mean that the Dao classes would have another responsibility than the originally intended-- I'm not particularly concerned about this arbitrary distinction, if your proposed solution actually solves the problem you are having in a reasonably good way.