Coverage Report - org.seasar.cubby.controller.impl.ClassDetectorImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ClassDetectorImpl
93%
13/14
75%
3/4
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.cubby.controller.impl;
 17  
 
 18  
 import org.seasar.cubby.controller.ClassDetector;
 19  
 import org.seasar.cubby.controller.DetectClassProcessor;
 20  
 import org.seasar.framework.container.ComponentDef;
 21  
 import org.seasar.framework.container.cooldeploy.CoolComponentAutoRegister;
 22  
 import org.seasar.framework.util.Disposable;
 23  
 import org.seasar.framework.util.DisposableUtil;
 24  
 
 25  
 /**
 26  
  * クラスパスを走査してクラスを検出するクラスの実装です。
 27  
  * <p>
 28  
  * Cool Deploy の挙動と合わせるため、{@link CoolComponentAutoRegister} を継承しています。
 29  
  * </p>
 30  
  * 
 31  
  * @author baba
 32  
  * @since 1.1.0
 33  
  */
 34  97
 public class ClassDetectorImpl extends CoolComponentAutoRegister implements
 35  
                 ClassDetector, Disposable {
 36  
 
 37  
         /** スーパークラスの初期化メソッドをクリアします。 */
 38  1
         public static final String INIT_METHOD = null;
 39  
 
 40  
         /** 初期化フラグ。 */
 41  
         private boolean initialized;
 42  
 
 43  
         /** 検出されたクラスを処理するクラスの配列です。 */
 44  
         private DetectClassProcessor[] processors;
 45  
 
 46  
         /**
 47  
          * {@inheritDoc}
 48  
          */
 49  
         @Override
 50  
         public void processClass(final String packageName,
 51  
                         final String shortClassName) {
 52  22230
                 for (final DetectClassProcessor processor : processors) {
 53  11628
                         processor.processClass(packageName, shortClassName);
 54  
                 }
 55  10602
         }
 56  
 
 57  
         /**
 58  
          * {@inheritDoc}
 59  
          */
 60  
         public void detect() {
 61  31
                 if (!initialized) {
 62  31
                         processors = DetectClassProcessor[].class.cast(getContainer()
 63  
                                         .getRoot().findAllComponents(DetectClassProcessor.class));
 64  31
                         registerAll();
 65  31
                         DisposableUtil.add(this);
 66  31
                         initialized = true;
 67  
                 }
 68  31
         }
 69  
 
 70  
         /**
 71  
          * {@inheritDoc}
 72  
          */
 73  
         public void dispose() {
 74  31
                 initialized = false;
 75  31
         }
 76  
 
 77  
         /**
 78  
          * {@inheritDoc}
 79  
          */
 80  
         @SuppressWarnings("unchecked")
 81  
         @Override
 82  
         protected ComponentDef createComponentDef(final Class componentClass) {
 83  0
                 throw new UnsupportedOperationException();
 84  
         }
 85  
 
 86  
 }