KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > monolog > provider > lib > TopicProviderImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.util.monolog.provider.lib;
28
29 import java.util.HashMap JavaDoc;
30
31 import org.objectweb.util.monolog.provider.api.TopicProvider;
32 import org.objectweb.util.monolog.provider.lib.topics.BundleTopics;
33 import org.objectweb.util.monolog.provider.lib.topics.TopicsMapSingleton;
34 import org.objectweb.util.monolog.provider.lib.topics.TopicsPool;
35
36 /**
37  * @author Jerome Offroy
38  *
39  * used to create Topics and to maintain a pool of currently used Topics
40  */

41 public class TopicProviderImpl implements TopicProvider {
42     protected static TopicsPool tm_ = TopicsMapSingleton.getTopicsMap();
43
44     /**
45      * @see org.objectweb.util.monolog.provider.api.TopicProvider#createTopic(String, Class, String[])
46      */

47     public String JavaDoc createTopic(String JavaDoc name, Class JavaDoc ref, String JavaDoc[] description) {
48         String JavaDoc realTopic = buildTopicNameBundle(ref) + BundleTopics.getPreTopic("TOPIC_SEPARATOR") + name;
49
50         if (ref != null) {
51             // add the new Topic and description to the structure
52
// which maintain topics declaration and description
53
tm_.put(ref,realTopic,description);
54         }
55         return realTopic;
56     }
57
58     /**
59      * @see org.objectweb.util.monolog.provider.api.TopicProvider#getTopic(Object)
60      */

61     public String JavaDoc getTopic(Class JavaDoc ref) {
62         String JavaDoc res = tm_.getName(ref);
63         if (res == null) {
64             res = "";
65         }
66         return res;
67     }
68
69     /**
70      * @see org.objectweb.util.monolog.provider.api.TopicProvider#getTopics()
71      */

72     public String JavaDoc[] getTopics() {
73         return tm_.getAllName();
74     }
75
76     /**
77      * @see org.objectweb.util.monolog.provider.api.TopicProvider#getTopicDescription(String)
78      */

79     public String JavaDoc[] getTopicDescription(String JavaDoc name) {
80         return tm_.getDescription(name);
81     }
82
83     /**
84      * Method getTopicsByRef.
85      * @return HashMap
86      */

87     public HashMap JavaDoc getTopicsByRef() {
88         return tm_.getTopicsByRef();
89     }
90
91     /*************************************************
92      * Private methods
93      *************************************************/

94     private String JavaDoc buildTopicNameBundle(Class JavaDoc ref) {
95         String JavaDoc res = "default";
96         res = BundleTopics.getPreTopic(ref.getPackage());
97         return res;
98     }
99 }
100
Popular Tags