I think the difficulty of transaction processing lies in the "recovery" part. To be able to recover, the scene must be saved, or effective reverse operations must be provided. Of course, reverse operations usually belong to the business category. Since dynamic proxy implementation is required here, state recovery should be relatively appropriate.
For a file operation, the simplest and crudest way to save the status is to save the file backup. So I think this dynamic proxy is like this
Save a backup of the file you want to operate
Call the proxied code to perform its own business operations (while monitoring exceptions)
If an exception occurs, restore the file backup, otherwise ignore this step
I think the difficulty of transaction processing lies in the "recovery" part. To be able to recover, the scene must be saved, or effective reverse operations must be provided. Of course, reverse operations usually belong to the business category. Since dynamic proxy implementation is required here, state recovery should be relatively appropriate.
For a file operation, the simplest and crudest way to save the status is to save the file backup. So I think this dynamic proxy is like this
Save a backup of the file you want to operate
Call the proxied code to perform its own business operations (while monitoring exceptions)
If an exception occurs, restore the file backup, otherwise ignore this step
Delete File Backup
Let’s see if my answer can give you an idea