KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tutorial > IdentifiableComponent


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 package tutorial;
18
19 import org.apache.avalon.framework.logger.AbstractLogEnabled;
20 import org.apache.avalon.framework.context.Contextualizable;
21 import org.apache.avalon.framework.context.Context;
22 import org.apache.avalon.framework.context.ContextException;
23
24 /**
25  * The IdentifiableComponent implements Identifiable.
26  *
27  * @avalon.component version="1.0" name="simple" lifestyle="singleton"
28  * @avalon.service type="tutorial.Identifiable"
29  */

30 public class IdentifiableComponent extends AbstractLogEnabled
31   implements Identifiable, Contextualizable
32 {
33
34     private String JavaDoc m_identity = null;
35
36    /**
37     * Contextualization of the component during which we
38     * establish the component identity.
39     *
40     * @param context the component context
41     * @avalon.entry key="urn:avalon:name"
42     * @avalon.entry key="urn:avalon:partition"
43     */

44     public void contextualize( Context context )
45       throws ContextException
46     {
47         getLogger().info( "contextualize" );
48         String JavaDoc name = (String JavaDoc) context.get( "urn:avalon:name" );
49         String JavaDoc partition = (String JavaDoc) context.get( "urn:avalon:partition" );
50         m_identity = partition + name;
51     }
52
53     public String JavaDoc getIdentity()
54     {
55         return m_identity;
56     }
57
58 }
59
Popular Tags