Source Code Cross Referenced for MonologFactoryMBeanImpl.java in  » Development » Monolog » org » objectweb » util » monolog » wrapper » remote » lib » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » Monolog » org.objectweb.util.monolog.wrapper.remote.lib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (C) 2001-2005 France Telecom R&D
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */package org.objectweb.util.monolog.wrapper.remote.lib;
018:
019:        import org.objectweb.util.monolog.Monolog;
020:        import org.objectweb.util.monolog.api.Handler;
021:        import org.objectweb.util.monolog.api.Level;
022:        import org.objectweb.util.monolog.api.Logger;
023:        import org.objectweb.util.monolog.api.MonologFactory;
024:        import org.objectweb.util.monolog.api.TopicalLogger;
025:        import org.objectweb.util.monolog.file.monolog.PropertiesConfAccess;
026:        import org.objectweb.util.monolog.wrapper.remote.api.LoggerInfo;
027:        import org.objectweb.util.monolog.wrapper.remote.api.MonologFactoryMBean;
028:
029:        import java.util.Arrays;
030:        import java.util.Collections;
031:        import java.util.Comparator;
032:        import java.util.HashMap;
033:        import java.util.Map;
034:        import java.util.Properties;
035:
036:        /**
037:         * This class is a JMX MBean implementing the MonologFactoryMBean interface. It
038:         * permits to configure loggers, handlers and levels on a monolog factory
039:         * 
040:         * @author S.Chassande-Barrioz
041:         */
042:        public class MonologFactoryMBeanImpl implements  MonologFactoryMBean {
043:
044:            private MonologFactory mf;
045:
046:            /**
047:             * Build a JMX MBean managing the default MonologFactory registered
048:             * as current int the Monolog class.
049:             */
050:            public MonologFactoryMBeanImpl() {
051:                this (Monolog.getMonologFactory());
052:            }
053:
054:            /**
055:             * Build a JMX MBean for administrate the a MonologFactory.
056:             * @param mf is the monolog factory instance encapsulated into this MBean.
057:             */
058:            public MonologFactoryMBeanImpl(MonologFactory mf) {
059:                this .mf = mf;
060:            }
061:
062:            public boolean defineLevel(String name, int value) {
063:                return mf.defineLevel(name, value) != null;
064:            }
065:
066:            public boolean defineLevel(String name, String value) {
067:                return mf.defineLevel(name, value) != null;
068:            }
069:
070:            public void removeLevel(String name) {
071:                mf.removeLevel(name);
072:            }
073:
074:            public Level getLevel(String name) {
075:                return mf.getLevel(name);
076:            }
077:
078:            public Level getLevel(int value) {
079:                return mf.getLevel(value);
080:            }
081:
082:            public Level[] getLevels() {
083:                return mf.getLevels();
084:            }
085:
086:            public int compareTo(String levelname1, String levelname2) {
087:                Level l1 = mf.getLevel(levelname1);
088:                if (l1 == null) {
089:                    return Integer.MAX_VALUE;
090:                }
091:                Level l2 = mf.getLevel(levelname2);
092:                if (l2 == null) {
093:                    return Integer.MIN_VALUE;
094:                }
095:                return l1.compareTo(l2);
096:            }
097:
098:            public boolean createHandler(String hn, String handlertype) {
099:                return mf.createHandler(hn, handlertype) != null;
100:            }
101:
102:            public boolean removeHandler(String handlername) {
103:                return mf.removeHandler(handlername) == null;
104:            }
105:
106:            public String[] getHandlerNames() {
107:                Handler[] hs = mf.getHandlers();
108:                String[] hns = new String[hs.length];
109:                for (int i = 0; i < hs.length; i++) {
110:                    hns[i] = hs[i].getName();
111:                }
112:                return hns;
113:            }
114:
115:            public Map getHandlerAttributes(String handlername) {
116:                Handler h = mf.getHandler(handlername);
117:                String[] ans = h.getAttributeNames();
118:                Map m = new HashMap(ans.length);
119:                for (int i = 0; i < ans.length; i++) {
120:                    m.put(ans[i], h.getAttribute(ans[i]));
121:                }
122:                m.put("name", handlername);
123:                return m;
124:            }
125:
126:            public Map getAllHandlerAttributes() {
127:                Handler[] hs = mf.getHandlers();
128:                Map m = new HashMap(hs.length);
129:                for (int i = 0; i < hs.length; i++) {
130:                    m.put(hs[i], getHandlerAttributes(hs[i].getName()));
131:                }
132:                return m;
133:            }
134:
135:            public void setHandlerAttribute(String handlername,
136:                    String attributeName, String value) {
137:                Handler h = mf.getHandler(handlername);
138:                if (h == null) {
139:                    return;
140:                }
141:                h.setAttribute(attributeName, value);
142:            }
143:
144:            public LoggerInfo getLogger(String loggername) {
145:                return new LoggerInfo((TopicalLogger) mf.getLogger(loggername));
146:            }
147:
148:            public LoggerInfo getLogger(String loggername,
149:                    String resourceBundleName) {
150:                return new LoggerInfo((TopicalLogger) mf.getLogger(loggername,
151:                        resourceBundleName));
152:            }
153:
154:            public String getResourceBundleName() {
155:                return mf.getResourceBundleName();
156:            }
157:
158:            public void setResourceBundleName(String resourceBundleName) {
159:                mf.setResourceBundleName(resourceBundleName);
160:            }
161:
162:            public LoggerInfo[] getLoggers() {
163:                Logger[] ls = mf.getLoggers();
164:                LoggerInfo[] lis = new LoggerInfo[ls.length];
165:                for (int i = 0; i < ls.length; i++) {
166:                    lis[i] = new LoggerInfo((TopicalLogger) ls[i]);
167:                }
168:                Arrays.sort(lis, new Comparator() {
169:                    public int compare(Object o1, Object o2) {
170:                        return ((LoggerInfo) o1).topics[0]
171:                                .compareTo(((LoggerInfo) o2).topics[0]);
172:                    }
173:                });
174:                return lis;
175:            }
176:
177:            public void addHandlerToLogger(String handlername, String loggerName) {
178:                Handler h = mf.getHandler(handlername);
179:                if (h == null) {
180:                    return;
181:                }
182:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
183:                try {
184:                    l.addHandler(h);
185:                } catch (Exception e) {
186:                    return;
187:                }
188:            }
189:
190:            public void removeHandlerFromLogger(String handlerName,
191:                    String loggerName) {
192:                Handler h = mf.getHandler(handlerName);
193:                if (h == null) {
194:                    return;
195:                }
196:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
197:                try {
198:                    l.removeHandler(h);
199:                } catch (Exception e) {
200:                    return;
201:                }
202:            }
203:
204:            public void removeAllHandlersFromLogger(String loggerName) {
205:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
206:                try {
207:                    l.removeAllHandlers();
208:                } catch (Exception e) {
209:                    return;
210:                }
211:            }
212:
213:            public void setAdditivity(boolean a, String loggerName) {
214:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
215:                l.setAdditivity(a);
216:            }
217:
218:            /**
219:             * It assigns the level to a logger
220:             * @param level is the level to assign the logger
221:             * @param loggerName is the name of logger which the level must be set.
222:             */
223:            public void setLoggerLevel(int level, String loggerName) {
224:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
225:                l.setIntLevel(level);
226:            }
227:
228:            /**
229:             * It assigns the level to a logger
230:             * @param level is the level to assign the logger
231:             * @param loggerName is the name of logger which the level must be set.
232:             */
233:            public void setLoggerLevel(String levelName, String loggerName) {
234:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
235:                Level level = mf.getLevel(levelName);
236:                if (level != null) {
237:                    l.setLevel(level);
238:                }
239:            }
240:
241:            public void addTopicToLogger(String topic, String loggerName) {
242:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
243:                try {
244:                    l.addTopic(topic);
245:                } catch (Exception e) {
246:                    return;
247:                }
248:            }
249:
250:            public void removeTopicFromLogger(String topic, String loggerName) {
251:                TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
252:                try {
253:                    l.removeTopic(topic);
254:                } catch (Exception e) {
255:                    return;
256:                }
257:            }
258:
259:            public Properties getMonologProperties() {
260:                Properties p = new Properties();
261:                try {
262:                    PropertiesConfAccess.store(p, mf);
263:                } catch (Exception e) {
264:                    return null;
265:                }
266:                return p;
267:            }
268:
269:            public void setMonologProperties(Properties p) {
270:                try {
271:                    PropertiesConfAccess.load(p, mf);
272:                } catch (Exception e) {
273:                }
274:            }
275:
276:        }
ww_w___._j__a___v___a2___s_._c_om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.