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