View Javadoc

1   /*
2    * Copyright (c) 2002-2004
3    * All rights reserved.
4    */
5   package com.atlassian.plugin.servlet.util;
6   
7   import com.atlassian.util.concurrent.LazyReference;
8   
9   /**
10   * Thread-safe lock-less (see note) reference that is not constructed until
11   * required. This class is used to maintain a reference to an object that is
12   * expensive to create and must be constructed once and once only. Therefore
13   * this reference behaves as though the <code>final</code> keyword has been used
14   * (you cannot reset it once it has been constructed).
15   * <p/>
16   * When using this class you need to implement the {@link #create()} method to
17   * return the object this reference will hold.
18   * <p/>
19   * For instance:
20   * 
21   * <pre>
22   * final LazyLoadedReference ref = new LazyLoadedReference()
23   * {
24   *     protected Object create() throws Exception
25   *     {
26   *         // Do some useful object construction here
27   *         return new MyObject();
28   *     }
29   * };
30   * </pre>
31   * 
32   * Then call to get a reference to the object:
33   * 
34   * <pre>
35   *   MyObject myLazyLoadedObject = (MyObject) ref.get()
36   * </pre>
37   * <p/>
38   * <strong>Note:</strong> Copied from JIRA
39   * com.atlassian.jira.util.concurrent.ThreadsafeLazyLoadedReference and modified
40   * to use generics and java.util.concurrent.
41   * 
42   * @since 2.1.0
43   * @deprecated since 2.5.0 use {@link LazyReference} directly instead.
44   */
45  @Deprecated
46  public abstract class LazyLoadedReference<V> extends LazyReference<V>
47  {}