KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tutorial > location > LocationComponent


1 /*
2  * Copyright 2004 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 tutorial.location;
19
20 import java.io.File JavaDoc;
21
22 import org.apache.avalon.framework.logger.AbstractLogEnabled;
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.activity.Disposable;
27
28 /**
29  * HelloComponent from Merlin's Tutorial
30  *
31  * @avalon.component version="1.0" name="location-provider"
32  * @avalon.service type="tutorial.location.LocationService"
33  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
34  */

35 public class LocationComponent extends AbstractLogEnabled implements
36 Configurable, Disposable, LocationService
37 {
38     private String JavaDoc m_location = "unknown";
39
40    /**
41     * Configuration of the component by the container. The
42     * implementation gets a child element named 'source' and
43     * assigns log the value.
44     *
45     * @param config the component configuration
46     * @exception ConfigurationException if a configuration error occurs
47     */

48     public void configure( Configuration config ) throws
49     ConfigurationException
50     {
51         m_location = config.getChild( "source" ).getValue( "unknown" );
52         getLogger().info( "location: " + m_location );
53     }
54
55    /**
56     * Return a location.
57     * @return a location
58     */

59     public String JavaDoc getLocation()
60     {
61         return m_location;
62     }
63
64     public void dispose()
65     {
66         getLogger().info( "disposal" );
67     }
68 }
69
70
Popular Tags