View Javadoc

1   /*
2    * Copyright (c) 2005 Brian Goetz and Tim Peierls
3    * Released under the Creative Commons Attribution License
4    *   (http://creativecommons.org/licenses/by/2.5)
5    * Official home: http://www.jcip.net
6    *
7    * Any republication or derived work distributed in source code form
8    * must include this copyright and license notice.
9    */
10  
11  package ch.elca.el4j.util.concurrency;
12  
13  import java.lang.annotation.Documented;
14  import java.lang.annotation.ElementType;
15  import java.lang.annotation.Retention;
16  import java.lang.annotation.RetentionPolicy;
17  import java.lang.annotation.Target;
18  
19  /**
20   * The field or method to which this annotation is applied can only be accessed
21   * when holding a particular lock, which may be a built-in (synchronization) lock,
22   * or may be an explicit java.util.concurrent.Lock.
23   *
24   * @svnLink $Revision: 3875 $;$Date: 2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/main/java/ch/elca/el4j/util/concurrency/GuardedBy.java $
25   *
26   * The argument determines which lock guards the annotated field or method:
27   * <ul>
28   * <li>
29   * <code>this</code> : The intrinsic lock of the object in whose class the field is defined.
30   * </li>
31   * <li>
32   * <code>class-name.this</code> : For inner classes, it may be necessary to disambiguate 'this';
33   * the <em>class-name.this</em> designation allows you to specify which 'this' reference is intended
34   * </li>
35   * <li>
36   * <code>itself</code> : For reference fields only; the object to which the field refers.
37   * </li>
38   * <li>
39   * <code>field-name</code> : The lock object is referenced by the (instance or static) field
40   * specified by <em>field-name</em>.
41   * </li>
42   * <li>
43   * <code>class-name.field-name</code> : The lock object is reference by the static field specified
44   * by <em>class-name.field-name</em>.
45   * </li>
46   * <li>
47   * <code>method-name()</code> : The lock object is returned by calling the named nil-ary method.
48   * </li>
49   * <li>
50   * <code>class-name.class</code> : The Class object for the specified class should be used as the lock object.
51   * </li>
52   * </ul>
53   *
54   */
55  @Documented
56  @Target({ElementType.FIELD, ElementType.METHOD})
57  @Retention(RetentionPolicy.RUNTIME)
58  public @interface GuardedBy {
59  	String value();
60  }