KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > testcase > FullLifecycleComponent


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

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 /**
40  * This test class is used to test the AbstractComponent facilities for you.
41  *
42  * @deprecated ECM is no longer supported
43  *
44  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
45  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:27 $
46  */

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 JavaDoc
104     {
105         m_validator.checkInitialized();
106     }
107
108     public void start()
109         throws Exception JavaDoc
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 JavaDoc
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