KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > jcip > annotations > GuardedBy


1 package net.jcip.annotations;
2
3 import java.lang.annotation.ElementType JavaDoc;
4 import java.lang.annotation.Retention JavaDoc;
5 import java.lang.annotation.RetentionPolicy JavaDoc;
6 import java.lang.annotation.Target JavaDoc;
7
8 /*
9  * Copyright (c) 2005 Brian Goetz
10  * Released under the Creative Commons Attribution License
11  * (http://creativecommons.org/licenses/by/2.5)
12  * Official home: http://www.jcip.net
13  */

14
15 /**
16  * GuardedBy
17  *
18  * The field or method to which this annotation is applied can only be accessed
19  * when holding a particular lock, which may be a built-in (synchronization) lock,
20  * or may be an explicit java.util.concurrent.Lock.
21  *
22  * The argument determines which lock guards the annotated field or method:
23  * this : The string literal "this" means that this field is guarded by the
24  * class in which it is defined.
25  * class-name.this : For inner classes, it may be necessary to disambiguate 'this';
26  * the class-name.this designation allows you to specify which 'this' reference is intended
27  * itself : For reference fields only; the object to which the field refers.
28  * field-name : The lock object is referenced by the (instance or static) field specified by field-name.
29  * class-name.field-name : The lock object is reference by the static field specified by class-name.field-name.
30  * method-name() : The lock object is returned by calling the named nil-ary method.
31  * class-name.class : The Class object for the specified class should be used as the lock object.
32  */

33 @Target JavaDoc({ElementType.FIELD, ElementType.METHOD})
34 @Retention JavaDoc(RetentionPolicy.CLASS)
35 public @interface GuardedBy {
36     String JavaDoc value();
37 }
Popular Tags