KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > playground > Secondary


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 org.apache.avalon.playground;
19
20 import org.apache.avalon.framework.logger.Logger;
21 import org.apache.avalon.framework.logger.AbstractLogEnabled;
22 import org.apache.avalon.framework.service.Serviceable;
23 import org.apache.avalon.framework.service.ServiceManager;
24 import org.apache.avalon.framework.service.ServiceException;
25
26 /**
27  * @avalon.component version="2.4" name="secondary-component"
28  * @avalon.service type="org.apache.avalon.playground.SecondaryService" version="0.1"
29  */

30 public class Secondary extends AbstractLogEnabled
31 implements Serviceable, SecondaryService
32 {
33     private Logger m_system = null;
34
35     private PrimaryService m_primary = null;
36
37    /**
38     * Supply of a logging channel to the component.
39     * @param logger the logging channel
40     * @avalon.logger name="system"
41     */

42     public void enableLogging( Logger logger )
43     {
44         super.enableLogging( logger );
45         m_system = logger.getChildLogger( "system" );
46         logger.info( "logging established" );
47     }
48
49    /**
50     * Supply of dependent services to this component by the container.
51     * @param manager the service manager
52     * @avalon.dependency type="org.apache.avalon.playground.PrimaryService" version="9.8" key="primary"
53     */

54     public void service( ServiceManager manager ) throws ServiceException
55     {
56         m_primary = (PrimaryService) manager.lookup( "primary" );
57         m_system.info( "primary service resolved" );
58     }
59 }
60
Popular Tags