1 17 18 package org.apache.avalon.fortress.util.test; 19 20 import org.apache.avalon.framework.activity.Disposable; 21 import org.apache.avalon.framework.activity.Initializable; 22 import org.apache.avalon.framework.activity.Startable; 23 import org.apache.avalon.framework.activity.Suspendable; 24 import org.apache.avalon.framework.configuration.Configurable; 25 import org.apache.avalon.framework.configuration.Configuration; 26 import org.apache.avalon.framework.configuration.ConfigurationException; 27 import org.apache.avalon.framework.context.Context; 28 import org.apache.avalon.framework.context.ContextException; 29 import org.apache.avalon.framework.context.Contextualizable; 30 import org.apache.avalon.framework.logger.LogEnabled; 31 import org.apache.avalon.framework.logger.Logger; 32 import org.apache.avalon.framework.parameters.ParameterException; 33 import org.apache.avalon.framework.parameters.Parameterizable; 34 import org.apache.avalon.framework.parameters.Parameters; 35 import org.apache.avalon.framework.service.ServiceException; 36 import org.apache.avalon.framework.service.ServiceManager; 37 import org.apache.avalon.framework.service.Serviceable; 38 import org.apache.avalon.framework.thread.ThreadSafe; 39 40 41 47 public final class FullLifecycleComponent 48 implements LogEnabled, Contextualizable, Parameterizable, Configurable, 49 Serviceable, Initializable, Startable, Suspendable, Disposable, 50 ThreadSafe 51 { 52 private org.apache.avalon.fortress.util.test.ComponentStateValidator m_validator = new org.apache.avalon.fortress.util.test.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_componentManager; 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( final ServiceManager manager ) 95 throws ServiceException 96 { 97 m_validator.checkNotAssigned( m_componentManager ); 98 m_validator.checkServiced(); 99 } 100 101 public void initialize() 102 throws Exception 103 { 104 m_validator.checkInitialized(); 105 } 106 107 public void start() 108 throws Exception 109 { 110 m_validator.checkStarted(); 111 } 112 113 public void suspend() 114 { 115 m_validator.checkSuspended(); 116 } 117 118 public void resume() 119 { 120 m_validator.checkResumed(); 121 } 122 123 public void stop() 124 throws Exception 125 { 126 m_validator.checkStopped(); 127 } 128 129 public void dispose() 130 { 131 m_validator.checkDisposed(); 132 133 m_logger = null; 134 m_context = null; 135 m_parameters = null; 136 m_configuration = null; 137 m_componentManager = null; 138 } 139 } 140 | Popular Tags |