Hi Guys, a bit of help.
I have an application which executes multiple queries (query1, query2, query3) against a DB, retrieves data and then publishes that data.
The way I went about designing it was:
a. Have a DB class which encapsulated the connection, query execution, transforming resultset to POJOs.
b. A publisher class which knows how to publish the pojo.
c. A controller which, at start, executes a and then feeds the output to b.
public void start(){
List<DataPojo> pojoList = db.executeAndRetrieveResult();
for (DataPojo p : pojoList){
publisher.publish(p);
}
}
d. A manager which contains a list of controller. When invoked, iterates and asks the controller to start.
public void start(){
for (Controller c : controllerList){
c.start();
}
}
The life of the app was simple and thus good.
But now I need to make a change which entails, taking data from query1, combining with the data from query2 and then publishing it.
Previously, the Controllers were homogeneous. The difference between them was encapsulated in the query that they executed (using the Db class).
However, now I need to know which controller is executing which query so I know where to get the output of query1 and query2.
Is a design pattern that I can use to make Controller1 and Controller2 interact while still keeping them relatively loosely coupled?
Cheers