| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.uruma.desc; |
| 17 | |
|
| 18 | |
import java.util.concurrent.ConcurrentMap; |
| 19 | |
|
| 20 | |
import org.seasar.framework.util.Disposable; |
| 21 | |
import org.seasar.framework.util.DisposableUtil; |
| 22 | |
import org.seasar.framework.util.tiger.CollectionsUtil; |
| 23 | |
import org.seasar.uruma.desc.impl.FormDescImpl; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | 0 | public class FormDescFactory { |
| 31 | |
private static volatile boolean initialized; |
| 32 | |
|
| 33 | 4 | protected static final ConcurrentMap<Class<?>, FormDesc> formDescs = CollectionsUtil |
| 34 | |
.newConcurrentHashMap(); |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
public static void initialize() { |
| 40 | 112 | DisposableUtil.add(new Disposable() { |
| 41 | 112 | public void dispose() { |
| 42 | 112 | FormDescFactory.dispose(); |
| 43 | 112 | } |
| 44 | |
}); |
| 45 | 112 | initialized = true; |
| 46 | 112 | } |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public static synchronized void dispose() { |
| 52 | 112 | formDescs.clear(); |
| 53 | 112 | initialized = false; |
| 54 | 112 | } |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
public static FormDesc getFormDesc(final Class<?> formClass) { |
| 64 | 112 | if (!initialized) { |
| 65 | 112 | initialize(); |
| 66 | |
} |
| 67 | 112 | FormDesc formDesc = formDescs.get(formClass); |
| 68 | 112 | if (formDesc == null) { |
| 69 | 112 | formDesc = CollectionsUtil.putIfAbsent(formDescs, formClass, |
| 70 | |
new FormDescImpl(formClass)); |
| 71 | |
} |
| 72 | 112 | return formDesc; |
| 73 | |
} |
| 74 | |
} |