com.calitha.concurrent
Annotation Type RWLock
@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface RWLock
This annotation can be used to declare that a method needs
a read or write lock. This annotation can be used together with
the proxy design pattern and the RWLockInvocationHandler to automatically
create and use the locks declared in the annotations.
Example:
@RWLock(RWLock.Type.WRITE)
public void setValue(long value)
{
this.value = value;
}
When a proxy is set-up it will read the annotation and create and lock the writelock before
the call, and releases it after that call.
It will not create any new locks for internal calls. Therefore you should declare
the needed lock at the method and take into account the internally called methods too.
Don't call a method that needs a write lock from a method that has declared it needs only a
read lock.
- Author:
- Robert van Loenhout
value
public abstract RWLock.Type value
- Returns:
- the declared lock type.
Possible values are NONE, READ and WRITE.
- Default:
- com.calitha.concurrent.RWLock.Type.READ