KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > util > test > FullLifecycleComponent


1 /*
2  * Copyright 2003-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
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 /**
42  * This test class is used to test the AbstractComponent facilities for you.
43  *
44  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
45  * @version CVS $Revision: 1.6 $ $Date: 2004/02/28 15:16:27 $
46  */

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