I have a java application in which each process has been divided in java classes (Spring beans). Eg:
ProcessFileBean , runs if request's state=1
EmailSenderBean , runs if request's state=2
DB returns requests which have to be processed with their state value, Eg:
Request ID 1000, current State=1
Request ID 1001, current State=2
ProcessFileBean gets records with state=1, runs its functionality and updates state in DB to 2. EmailSenderBean gets records with state=2, run its functionality and sends email.
Challenges:
- ProcessFileBean and EmailSenderBean have to be processed in this sequence only
- Beans can be disabled. If ProcessFileBean is disabled, EmailSenderBean will be executed directly. Currently to achieve this, the mapping of respective state associated with bean has to be commented. -> Eg: If Bean3 runs on state 3, EmailSenderBean has to be disabled, then ProcessFileBean has to be modified to update closing state to 3 instead of 2.
What I want to achieve:
- In the entire code there are such 10 beans and states. I want to remove hardcoding of states to respective beans. If Bean2 is disabled, Bean1 should know from DB or some other way that what state has to be updated. Bean3 should be automatically invoked using configuration, without codelevel change.
- I have thought of getting the states configuration from XML or DB, Bean1 will get to know using configuration on which state it has to poll on, and what is the closing state for that bean.
- But I am putting this on stackoverflow to see if there are some better design workflows?
Thanks Ridhi
Aucun commentaire:
Enregistrer un commentaire