Coverage Report - org.seasar.uruma.desc.PartActionDescFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
PartActionDescFactory
93%
13/14
100%
4/4
0
PartActionDescFactory$1
100%
3/3
N/A
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 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.PartActionDescImpl;
 24  
 
 25  
 /**
 26  
  * {@link PartActionDesc} オブジェクトを取得するためのファクトリクラスです。<br />
 27  
  * 
 28  
  * @author y-komori
 29  
  */
 30  0
 public class PartActionDescFactory {
 31  
     private static volatile boolean initialized;
 32  
 
 33  4
     protected static final ConcurrentMap<Class<?>, PartActionDesc> partActionDescs = CollectionsUtil
 34  
             .newConcurrentHashMap();
 35  
 
 36  
     /**
 37  
      * 本ファクトリの初期化を行います。<br />
 38  
      */
 39  
     public static void initialize() {
 40  112
         DisposableUtil.add(new Disposable() {
 41  112
             public void dispose() {
 42  112
                 PartActionDescFactory.dispose();
 43  112
             }
 44  
         });
 45  112
         initialized = true;
 46  112
     }
 47  
 
 48  
     /**
 49  
      * 本ファクトリが保持するキャッシュをクリアします。<br />
 50  
      */
 51  
     public static synchronized void dispose() {
 52  112
         partActionDescs.clear();
 53  112
         initialized = false;
 54  112
     }
 55  
 
 56  
     /**
 57  
      * 指定したクラスに対応する {@link PartActionDesc} オブジェクトを取得します。<br />
 58  
      * 
 59  
      * @param partActionClass
 60  
      *            {@link PartActionDesc} を取得するクラス
 61  
      * @return {@link PartActionDesc} オブジェクト
 62  
      */
 63  
     public static PartActionDesc getPartActionDesc(
 64  
             final Class<?> partActionClass) {
 65  224
         if (!initialized) {
 66  112
             initialize();
 67  
         }
 68  224
         PartActionDesc partActionDesc = partActionDescs.get(partActionClass);
 69  224
         if (partActionDesc == null) {
 70  112
             partActionDesc = CollectionsUtil.putIfAbsent(partActionDescs,
 71  
                     partActionClass, new PartActionDescImpl(partActionClass));
 72  
         }
 73  224
         return partActionDesc;
 74  
     }
 75  
 }