Our Java application has a number of modules which implement a common interface. By design, each module is well-encapsulated and interchangeable. All calls to/from go via a small set of interfaces.
We need to instrument this mechanism to add,
Are there recommended options for this?
A few options I glanced at:
Assuming you are very strict about adhering to your small set of interfaces, then you could make use of wrapper objects that do the following:
You could also modify factory methods to return wrapped objects rather than the underlying objects so that the usage of these wrappers is fairly transparent.
Note that you will need to be very careful about mutability of parameters: ideally all parameters would be immutable but if not you would need to take deep copies (perhaps via serialization).
Theoretically you can then also use the logged inputs to enable playback and/or testing.... but I'd be cautious about expecting too much from this since playback would require you to capture all relevant state (including external state like DB transaction, filesystem access etc.) In general this is hard to achieve, though you might be able to make it work in your specific case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With