Locking resources
The great thing about locking in the annotations framework is ... you don't do anything!! Thats right, you dont need to implement or annotate anything.
But there's a couple of things you need to be aware of...
Must provide a UniqueId
Milton's transparent locking mechanism relies on each resource having a persistent and reliable uniqueID to key locks on. You can do this by having an ID bean property on your domain object:
public Long getId() { return id; }
Or you can annotate a method on the controller:
@UniqueId public String getProductCode(Product product) { return product.getProductCode(); }
Be Aware of Clustering
Milton's locking implementation uses an in-memory cache of lock tokens. If you deploy to a cluster you need to ensure this is replicated among your servers. At the time of writing milton doesnt have a built-in clustering solution, but one will be ready shortly. Please get in touch if you need help.