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 2006-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  
 
 17  
 package org.kuali.rice.core.api.lifecycle;
 18  
 
 19  
 import java.util.LinkedList;
 20  
 import java.util.List;
 21  
 
 22  0
 public abstract class BaseCompositeLifecycle extends BaseLifecycle {
 23  
 
 24  0
         private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BaseCompositeLifecycle.class);
 25  
 
 26  
         private List<Lifecycle> lifecycles;
 27  
 
 28  
         protected abstract List<Lifecycle> loadLifecycles() throws Exception;
 29  
 
 30  
         @Override
 31  
         public void start() throws Exception {
 32  0
             this.lifecycles = loadLifecycles();
 33  0
                 for (Lifecycle lifecycle : this.lifecycles) {
 34  0
                         lifecycle.start();
 35  
                 }
 36  0
                 super.start();
 37  0
         }
 38  
 
 39  
         @Override
 40  
         public void stop() throws Exception {
 41  0
                 for (Lifecycle lifecycle : reverseLifecycles()) {
 42  
                         try {
 43  0
                                 lifecycle.stop();
 44  0
                         } catch (Throwable t) {
 45  0
                                 LOG.error("Failed to stop Lifecycle: " + lifecycle.getClass().getName(), t);
 46  0
                         }
 47  
                 }
 48  0
                 super.stop();
 49  0
         }
 50  
 
 51  
         private List<Lifecycle> reverseLifecycles() {
 52  0
                 LinkedList<Lifecycle> reversed = new LinkedList<Lifecycle>();
 53  0
                 for (Lifecycle lifecycle : this.lifecycles) {
 54  0
                         reversed.addFirst(lifecycle);
 55  
                 }
 56  0
                 return reversed;
 57  
         }
 58  
 
 59  
 }