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; 009 010 /** 011 * An interface which specifies the lifecycle strategy on the component instance. 012 * Lifecycle strategies are used by component adapters to delegate the lifecycle 013 * operations on the component instances. 014 * 015 * @author Paul Hammant 016 * @author Peter Royal 017 * @author Jörg Schaible 018 * @author Mauro Talevi 019 * @see org.picocontainer.Startable 020 * @see org.picocontainer.Disposable 021 */ 022 public interface LifecycleStrategy { 023 024 /** 025 * Invoke the "start" method on the component instance if this is startable. 026 * It is up to the implementation of the strategy what "start" and "startable" means. 027 * 028 * @param component the instance of the component to start 029 */ 030 void start(Object component); 031 032 /** 033 * Invoke the "stop" method on the component instance if this is stoppable. 034 * It is up to the implementation of the strategy what "stop" and "stoppable" means. 035 * 036 * @param component the instance of the component to stop 037 */ 038 void stop(Object component); 039 040 /** 041 * Invoke the "dispose" method on the component instance if this is disposable. 042 * It is up to the implementation of the strategy what "dispose" and "disposable" means. 043 * 044 * @param component the instance of the component to dispose 045 */ 046 void dispose(Object component); 047 048 /** 049 * Test if a component instance has a lifecycle. 050 * @param type the component's type 051 * 052 * @return <code>true</code> if the component has a lifecycle 053 */ 054 boolean hasLifecycle(Class<?> type); 055 056 /** 057 * Is a component eager (not lazy) in that it should start when start() or equivalent is called, 058 * or lazy (it will only start on first getComponent() ). 059 * The default is the first of those two. 060 * 061 * @param adapter 062 * @return true if lazy, false if not lazy 063 */ 064 boolean isLazy(ComponentAdapter<?> adapter); 065 }