1 17 package org.apache.avalon.excalibur.testcase; 18 19 import org.apache.avalon.framework.activity.Disposable; 20 import org.apache.avalon.framework.activity.Initializable; 21 import org.apache.avalon.framework.activity.Startable; 22 import org.apache.avalon.framework.activity.Suspendable; 23 import org.apache.avalon.framework.configuration.Configurable; 24 import org.apache.avalon.framework.configuration.Configuration; 25 import org.apache.avalon.framework.configuration.ConfigurationException; 26 import org.apache.avalon.framework.context.Context; 27 import org.apache.avalon.framework.context.ContextException; 28 import org.apache.avalon.framework.context.Contextualizable; 29 import org.apache.avalon.framework.logger.LogEnabled; 30 import org.apache.avalon.framework.logger.Logger; 31 import org.apache.avalon.framework.parameters.ParameterException; 32 import org.apache.avalon.framework.parameters.Parameterizable; 33 import org.apache.avalon.framework.parameters.Parameters; 34 import org.apache.avalon.framework.service.ServiceException; 35 import org.apache.avalon.framework.service.ServiceManager; 36 import org.apache.avalon.framework.service.Serviceable; 37 import org.apache.avalon.framework.thread.ThreadSafe; 38 39 47 public final class FullLifecycleComponent 48 implements LogEnabled, Contextualizable, Parameterizable, Configurable, 49 Serviceable, Initializable, Startable, Suspendable, Disposable, 50 ThreadSafe 51 { 52 private ComponentStateValidator m_validator = new ComponentStateValidator( this ); 53 private Logger m_logger; 54 private Context m_context; 55 private Parameters m_parameters; 56 private Configuration m_configuration; 57 private ServiceManager m_manager; 58 59 public void enableLogging( Logger logger ) 60 { 61 m_validator.checkNotAssigned( m_logger ); 62 m_validator.checkLogEnabled(); 63 64 m_logger = logger; 65 } 66 67 public void contextualize( Context context ) 68 throws ContextException 69 { 70 m_validator.checkNotAssigned( m_context ); 71 m_validator.checkContextualized(); 72 73 m_context = context; 74 } 75 76 public void parameterize( Parameters params ) 77 throws ParameterException 78 { 79 m_validator.checkNotAssigned( m_parameters ); 80 m_validator.checkParameterized(); 81 82 m_parameters = params; 83 } 84 85 public void configure( Configuration config ) 86 throws ConfigurationException 87 { 88 m_validator.checkNotAssigned( m_configuration ); 89 m_validator.checkConfigured(); 90 91 m_configuration = config; 92 } 93 94 public void service( ServiceManager manager ) 95 throws ServiceException 96 { 97 m_validator.checkNotAssigned( m_manager ); 98 m_validator.checkServiced(); 99 m_manager = manager; 100 } 101 102 public void initialize() 103 throws Exception 104 { 105 m_validator.checkInitialized(); 106 } 107 108 public void start() 109 throws Exception 110 { 111 m_validator.checkStarted(); 112 } 113 114 public void suspend() 115 { 116 m_validator.checkSuspended(); 117 } 118 119 public void resume() 120 { 121 m_validator.checkResumed(); 122 } 123 124 public void stop() 125 throws Exception 126 { 127 m_validator.checkStopped(); 128 } 129 130 public void dispose() 131 { 132 m_validator.checkDisposed(); 133 134 m_logger = null; 135 m_context = null; 136 m_parameters = null; 137 m_configuration = null; 138 m_manager = null; 139 } 140 } 141 | Popular Tags |