Coverage Report - org.seasar.teeda.core.lifecycle.LifecycleFactoryImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
LifecycleFactoryImpl
100%
14/14
100%
6/6
2
 
 1  
 /*
 2  
  * Copyright 2004-2011 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.teeda.core.lifecycle;
 17  
 
 18  
 import java.util.Collections;
 19  
 import java.util.HashMap;
 20  
 import java.util.Iterator;
 21  
 import java.util.Map;
 22  
 
 23  
 import javax.faces.FacesException;
 24  
 import javax.faces.lifecycle.Lifecycle;
 25  
 import javax.faces.lifecycle.LifecycleFactory;
 26  
 
 27  
 import org.seasar.teeda.core.exception.LifecycleIdAlreadyExistRuntimeException;
 28  
 import org.seasar.teeda.core.exception.LifecycleIdNotFoundRuntimeException;
 29  
 import org.seasar.teeda.core.util.DIContainerUtil;
 30  
 
 31  
 /**
 32  
  * @author higa
 33  
  * @author shot
 34  
  */
 35  
 public class LifecycleFactoryImpl extends LifecycleFactory {
 36  
 
 37  4
     private Map lifecycles_ = Collections.synchronizedMap(new HashMap());
 38  
 
 39  4
     public LifecycleFactoryImpl() {
 40  4
         Lifecycle lifecycle = (Lifecycle) DIContainerUtil
 41  1
                 .getComponentNoException(Lifecycle.class);
 42  4
         addLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE, lifecycle);
 43  4
     }
 44  
 
 45  
     public void addLifecycle(String id, Lifecycle lifecycle) {
 46  8
         if (lifecycles_.put(id, lifecycle) != null) {
 47  1
             throw new LifecycleIdAlreadyExistRuntimeException(id);
 48  
         }
 49  7
     }
 50  
 
 51  
     public Lifecycle getLifecycle(String id) throws FacesException {
 52  2
         Lifecycle lifecycle = (Lifecycle) lifecycles_.get(id);
 53  2
         if (lifecycle == null) {
 54  1
             throw new LifecycleIdNotFoundRuntimeException(id);
 55  
         }
 56  1
         return lifecycle;
 57  
     }
 58  
 
 59  
     public Iterator getLifecycleIds() {
 60  1
         return lifecycles_.keySet().iterator();
 61  
     }
 62  
 }