Are there any recommendations, guidelines, or good articles on providing integration hooks?
Let's say I'm developing a network-based ordering system. In the end, I would like my client to be able to write some code, pack it in a jar, upload it to the classpath, and change the behavior of the software.
For example, if an order arrives, the code
1. can send email or sms
2. can write some additional data to the database
3. can change the data in the database or decide that the order should not be stored in the database (cancel saving data)
Point 3 is pretty dangerous because it interferes with data integrity too much, but if we want the integration to be so flexible, is this possible?
Options so far
1. provide hooks for specific actions, for example. if this happens already, call this method, the client will write an implementation for this method, this is too tough, although
2. A mechanism similar to servlet filters, there is code before the actual action is performed and after it the code is not quite sure how this could be developed, although
We use Struts2 if that matters.
This integration should be able to detect a โstate changeโ, and not just a โfinal stateโ after the main action.
For example, if an order changes state from In Progress to Paid, then it will do something, but if it changes from Draft to Paid, it should not do anything.
The main action in this case will be loading the order object from the database, changing the state to Paid and saving it again (or performing an sql update).
source share