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.lifecycle; 009 010 import java.io.Serializable; 011 012 import org.picocontainer.ComponentAdapter; 013 import org.picocontainer.ComponentMonitor; 014 import org.picocontainer.ComponentMonitorStrategy; 015 import org.picocontainer.LifecycleStrategy; 016 017 /** 018 * Abstract base class for lifecycle strategy implementation supporting a {@link ComponentMonitor}. 019 * 020 * @author Jörg Schaible 021 */ 022 public abstract class AbstractMonitoringLifecycleStrategy implements LifecycleStrategy, ComponentMonitorStrategy, Serializable { 023 024 /** 025 * Component monitor that receives lifecycle state. 026 */ 027 private ComponentMonitor componentMonitor; 028 029 /** 030 * Construct a AbstractMonitoringLifecycleStrategy. 031 * 032 * @param monitor the componentMonitor to use 033 * @throws NullPointerException if the monitor is <code>null</code> 034 */ 035 public AbstractMonitoringLifecycleStrategy(final ComponentMonitor monitor) { 036 changeMonitor(monitor); 037 } 038 039 /** 040 * Swaps the current monitor with a replacement. 041 * @param monitor The new monitor. 042 * @throws NullPointerException if the passed in monitor is null. 043 */ 044 public void changeMonitor(final ComponentMonitor monitor) { 045 if (monitor == null) { 046 throw new NullPointerException("Monitor is null"); 047 } 048 this.componentMonitor = monitor; 049 } 050 051 public ComponentMonitor currentMonitor() { 052 return componentMonitor; 053 } 054 055 public boolean isLazy(ComponentAdapter<?> adapter) { 056 return false; 057 } 058 059 }