KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > logging > logkit > DefaultLogTargetManager


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.logging.logkit;
19
20 import java.util.Map JavaDoc;
21
22 import org.apache.avalon.util.i18n.ResourceManager;
23 import org.apache.avalon.util.i18n.Resources;
24
25 import org.apache.log.LogTarget;
26
27 /**
28  * A <code>LoggerManager</code> interface declares operation supporting
29  * the management of a logging hierarchy.
30  *
31  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
32  */

33 class DefaultLogTargetManager implements LogTargetManager
34 {
35     //---------------------------------------------------------------
36
// static
37
//---------------------------------------------------------------
38

39     private static final Resources REZ =
40       ResourceManager.getPackageResources(
41         DefaultLogTargetManager.class );
42
43     //---------------------------------------------------------------
44
// state
45
//---------------------------------------------------------------
46

47    /**
48     * Map for id to target mapping.
49     */

50     private final Map JavaDoc m_targets;
51
52     //---------------------------------------------------------------
53
// constructor
54
//---------------------------------------------------------------
55

56     /**
57      * Creation of a new log target manager.
58      * @param targets a map of log targets
59      */

60     public DefaultLogTargetManager( Map JavaDoc targets ) throws Exception JavaDoc
61     {
62         if( null == targets )
63         {
64             throw new NullPointerException JavaDoc( "targets" );
65         }
66         m_targets = targets;
67     }
68
69     //---------------------------------------------------------------
70
// LogTargetManager
71
//---------------------------------------------------------------
72

73    /**
74     * Return a log target using a supplied target id. If the
75     * supplied id is unknown a null value is returned.
76     * @param id the logging target id
77     * @return the logging target
78     */

79     public LogTarget getLogTarget( final String JavaDoc id )
80     {
81         return (LogTarget) m_targets.get( id );
82     }
83 }
84
Popular Tags