Coverage Report - org.kuali.rice.core.api.lifecycle.BaseCompositeLifecycle
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseCompositeLifecycle
0%
0/18
0%
0/6
2
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 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, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.core.api.lifecycle;
 17  
 
 18  
 import java.util.LinkedList;
 19  
 import java.util.List;
 20  
 
 21  0
 public abstract class BaseCompositeLifecycle extends BaseLifecycle {
 22  
 
 23  0
         private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BaseCompositeLifecycle.class);
 24  
 
 25  
         private List<Lifecycle> lifecycles;
 26  
 
 27  
         protected abstract List<Lifecycle> loadLifecycles() throws Exception;
 28  
 
 29  
         @Override
 30  
         public void start() throws Exception {
 31  0
             this.lifecycles = loadLifecycles();
 32  0
                 for (Lifecycle lifecycle : this.lifecycles) {
 33  0
                         lifecycle.start();
 34  
                 }
 35  0
                 super.start();
 36  0
         }
 37  
 
 38  
         @Override
 39  
         public void stop() throws Exception {
 40  0
                 for (Lifecycle lifecycle : reverseLifecycles()) {
 41  
                         try {
 42  0
                                 lifecycle.stop();
 43  0
                         } catch (Throwable t) {
 44  0
                                 LOG.error("Failed to stop Lifecycle: " + lifecycle.getClass().getName(), t);
 45  0
                         }
 46  
                 }
 47  0
                 super.stop();
 48  0
         }
 49  
 
 50  
         private List<Lifecycle> reverseLifecycles() {
 51  0
                 LinkedList<Lifecycle> reversed = new LinkedList<Lifecycle>();
 52  0
                 for (Lifecycle lifecycle : this.lifecycles) {
 53  0
                         reversed.addFirst(lifecycle);
 54  
                 }
 55  0
                 return reversed;
 56  
         }
 57  
 
 58  
 }