View Javadoc
1   package com.atlassian.plugin.servlet;
2   
3   import java.util.concurrent.atomic.AtomicReference;
4   
5   public class ObjectFactories {
6       private ObjectFactories() {
7       }
8   
9       public static <T> ObjectFactory<T> createSingleton(final T object) {
10          return new ObjectFactory<T>() {
11              public T create() {
12                  return object;
13              }
14          };
15      }
16  
17      public static <T> ObjectFactory<T> createMutable(final AtomicReference<T> ref) {
18          return new ObjectFactory<T>() {
19              public T create() {
20                  return ref.get();
21              }
22          };
23      }
24  }