001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 *****************************************************************************/
008 package org.picocontainer.defaults;
009
010 import org.picocontainer.ComponentMonitor;
011
012 import java.io.Serializable;
013
014 /**
015 * Abstract base class for lifecycle strategy implementation supporting a {@link ComponentMonitor}.
016 *
017 * @author Jörg Schaible
018 * @since 1.2
019 */
020 public abstract class AbstractMonitoringLifecycleStrategy implements LifecycleStrategy, ComponentMonitorStrategy, Serializable {
021
022 private ComponentMonitor componentMonitor;
023
024 /**
025 * Construct a AbstractMonitoringLifecylceStrategy.
026 *
027 * @param monitor the componentMonitor to use
028 * @throws NullPointerException if the monitor is <code>null</code>
029 */
030 public AbstractMonitoringLifecycleStrategy(ComponentMonitor monitor) {
031 if (monitor == null) {
032 throw new NullPointerException("Monitor is null");
033 }
034 this.componentMonitor = monitor;
035 }
036
037 public void changeMonitor(ComponentMonitor monitor) {
038 if (monitor == null) {
039 throw new NullPointerException("Monitor is null");
040 }
041 this.componentMonitor = monitor;
042 }
043
044 public ComponentMonitor currentMonitor() {
045 return componentMonitor;
046 }
047
048 }