Clover coverage report - PicoContainer - 1.0-alpha-2
Coverage timestamp: Thu Jul 10 2003 10:40:43 BST
file stats: LOC: 98   Methods: 7
NCLOC: 72   Classes: 2
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
LifecyclePicoContainer.java 100% 100% 100% 100%
coverage
 1   
 /*****************************************************************************
 2   
  * Copyright (Cc) PicoContainer Organization. All rights reserved.            *
 3   
  * ------------------------------------------------------------------------- *
 4   
  * The software in this package is published under the terms of the BSD      *
 5   
  * style license a copy of which has been included with this distribution in *
 6   
  * the license.html file.                                                    *
 7   
  *                                                                           *
 8   
  * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant   *
 9   
  *****************************************************************************/
 10   
 
 11   
 package picocontainer.lifecycle;
 12   
 
 13   
 import picocontainer.ComponentFactory;
 14   
 import picocontainer.PicoContainer;
 15   
 import picocontainer.PicoInstantiationException;
 16   
 import picocontainer.PicoIntrospectionException;
 17   
 import picocontainer.defaults.NullContainer;
 18   
 import picocontainer.defaults.DefaultComponentFactory;
 19   
 import picocontainer.hierarchical.HierarchicalPicoContainer;
 20   
 
 21   
 public class LifecyclePicoContainer extends HierarchicalPicoContainer implements Startable, Stoppable, Disposable {
 22   
 
 23   
     private Startable startableAggregatedComponent;
 24   
     private Stoppable stoppableAggregatedComponent;
 25   
     private Disposable disposableAggregatedComponent;
 26   
     private boolean started;
 27   
     private boolean disposed;
 28   
 
 29  7
     public LifecyclePicoContainer(ComponentFactory componentFactory, PicoContainer parentContainer) {
 30  7
         super(componentFactory, parentContainer);
 31   
     }
 32   
 
 33   
     public static class Default extends LifecyclePicoContainer {
 34  7
         public Default() {
 35  7
             super(new DefaultComponentFactory(), new NullContainer());
 36   
         }
 37   
     }
 38   
 
 39  7
     public void instantiateComponents() throws PicoInstantiationException, PicoIntrospectionException {
 40  7
         super.instantiateComponents();
 41  7
         try {
 42  7
             startableAggregatedComponent = (Startable) getAggregateComponentProxy(true, false);
 43   
         } catch (ClassCastException e) {
 44   
         }
 45  7
         try {
 46   
 
 47  7
             stoppableAggregatedComponent = (Stoppable) getAggregateComponentProxy(false, false);
 48   
         } catch (ClassCastException e) {
 49   
         }
 50  7
         try {
 51   
             //TODO-Aslak broken
 52  7
             Object o =  getAggregateComponentProxy(false, false);
 53  7
             disposableAggregatedComponent = (Disposable) o;
 54   
         } catch (ClassCastException e) {
 55  6
             System.out.println("");
 56   
         }
 57   
 
 58   
     }
 59   
 
 60  9
     public void start() throws Exception {
 61  9
         checkDisposed();
 62  9
         if (started) {
 63  1
             throw new IllegalStateException("Already started.");
 64   
         }
 65  8
         started = true;
 66  8
         if (startableAggregatedComponent != null) {
 67  3
             startableAggregatedComponent.start();
 68   
         }
 69   
     }
 70   
 
 71  7
     public void stop() throws Exception {
 72  7
         checkDisposed();
 73  7
         if (started == false) {
 74  1
             throw new IllegalStateException("Already stopped.");
 75   
         }
 76  6
         started = false;
 77  6
         if (stoppableAggregatedComponent != null) {
 78  3
             stoppableAggregatedComponent.stop();
 79   
         }
 80   
     }
 81   
 
 82  5
     public void dispose() throws Exception {
 83  5
         checkDisposed();
 84  3
         disposed = true;
 85  3
         if (disposableAggregatedComponent != null) {
 86  1
             disposableAggregatedComponent.dispose();
 87   
         }
 88   
     }
 89   
 
 90  21
     private void checkDisposed() {
 91  21
         if (disposed) {
 92  2
             throw new IllegalStateException("Components Disposed Of");
 93   
         }
 94   
     }
 95   
 
 96   
 }
 97   
 
 98