This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
A webservice operation have the following tasks :
1-calls dao operation1 and operation2 to create a row in table 1 and 2 with RowID1 and RowID2
2-do something else ( like calling another webservice2 )
3-if the webservice2 response satisfy a condition then call dao operation3 to create a row in table 3 with fk = RowID1) and second fk = RowID2
so somehow RowID1 and RowID2 has to be provided to DAO operation3.
I'm trying to find a way not to pass around RowID1 and RowID2 between higher level classes as these IDs really should not be known by the webservice operation 1 as they are not part of business logic.
make DAO stateful inwhich RowID1 and RowID2 are class members and can be used by dao operation 3.
for thread safety concern use spring scope (request) so that all the class members only belong to one request/thread in order to avoid the following threading issue:
call to dao method to create RowID1 and RowID2 a car, and store them in class members
then webservice operation does other tasks which as calling webservice2 which takes a long time to complete
meanwhile request2 comes in ->
call to dao method to create RowID1 and RowID2 a car, and store it in class members. ( without thread-safety the request2 will override the request1 RowID1 and RowID2 )
WS op does other tasks
request1 continues ->
based on a condition call dao operation 3 to create a row in table 3 with fk = table1 RowID1) and second fk = RowID2
dao to pass the RowID1 and RowID2 and pass it as input to dao operation 3
really appreciate your comment and other suggestions