Source Code Cross Referenced for Slf4jLog.java in  » Sevlet-Container » jetty-modules » org » mortbay » log » 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 » Sevlet Container » jetty modules » org.mortbay.log 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //========================================================================
002:        //$Id: Slf4jLog.java,v 1.1 2005/11/14 16:55:09 gregwilkins Exp $
003:        //Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
004:        //------------------------------------------------------------------------
005:        //Licensed under the Apache License, Version 2.0 (the "License");
006:        //you may not use this file except in compliance with the License.
007:        //You may obtain a copy of the License at 
008:        //http://www.apache.org/licenses/LICENSE-2.0
009:        //Unless required by applicable law or agreed to in writing, software
010:        //distributed under the License is distributed on an "AS IS" BASIS,
011:        //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        //See the License for the specific language governing permissions and
013:        //limitations under the License.
014:        //========================================================================
015:
016:        package org.mortbay.log;
017:
018:        import java.lang.reflect.Method;
019:
020:        class Slf4jLog implements  Logger {
021:            private static final String LOGGER = "org.slf4j.Logger";
022:            private static final String LOGGERFACTORY = "org.slf4j.LoggerFactory";
023:            private static final Object[] NO_ARGS = new Object[] {};
024:            private Method infoSOO;
025:            private Method debugSOO;
026:            private Method debugST;
027:            private Method debugEnabled;
028:            private Method warnSOO;
029:            private Method warnST;
030:            private Method errorST;
031:            private Object logger;
032:
033:            Slf4jLog() throws Exception {
034:                this ("org.mortbay.log");
035:            }
036:
037:            Slf4jLog(String name) throws Exception {
038:                Class slf4j = null;
039:                Class slf4jf = null;
040:                try {
041:                    slf4j = this .getClass().getClassLoader().loadClass(LOGGER);
042:                    slf4jf = this .getClass().getClassLoader().loadClass(
043:                            LOGGERFACTORY);
044:                } catch (Exception e) {
045:                    slf4j = Thread.currentThread().getContextClassLoader() == null ? Class
046:                            .forName(LOGGER)
047:                            : Thread.currentThread().getContextClassLoader()
048:                                    .loadClass(LOGGER);
049:                    slf4jf = Thread.currentThread().getContextClassLoader() == null ? Class
050:                            .forName(LOGGERFACTORY)
051:                            : Thread.currentThread().getContextClassLoader()
052:                                    .loadClass(LOGGERFACTORY);
053:                }
054:
055:                infoSOO = slf4j.getMethod("info", new Class[] { String.class,
056:                        Object.class, Object.class });
057:                debugSOO = slf4j.getMethod("debug", new Class[] { String.class,
058:                        Object.class, Object.class });
059:                debugST = slf4j.getMethod("debug", new Class[] { String.class,
060:                        Throwable.class });
061:                debugEnabled = slf4j
062:                        .getMethod("isDebugEnabled", new Class[] {});
063:                warnSOO = slf4j.getMethod("warn", new Class[] { String.class,
064:                        Object.class, Object.class });
065:                warnST = slf4j.getMethod("warn", new Class[] { String.class,
066:                        Throwable.class });
067:                errorST = slf4j.getMethod("error", new Class[] { String.class,
068:                        Throwable.class });
069:
070:                Method getLogger = slf4jf.getMethod("getLogger",
071:                        new Class[] { String.class });
072:                logger = getLogger.invoke(null, new Object[] { name });
073:            }
074:
075:            /* ------------------------------------------------------------ */
076:            /* 
077:             * @see org.mortbay.log.Log#doDebug(java.lang.String, java.lang.Object, java.lang.Object)
078:             */
079:            public void debug(String msg, Object arg0, Object arg1) {
080:                try {
081:                    debugSOO.invoke(logger, new Object[] { msg, arg0, arg1 });
082:                } catch (Exception e) {
083:                    e.printStackTrace();
084:                }
085:            }
086:
087:            /* ------------------------------------------------------------ */
088:            /* 
089:             * @see org.mortbay.log.Log#doDebug(java.lang.String, java.lang.Throwable)
090:             */
091:            public void debug(String msg, Throwable th) {
092:                try {
093:                    debugST.invoke(logger, new Object[] { msg, th });
094:                } catch (Exception e) {
095:                    e.printStackTrace();
096:                }
097:            }
098:
099:            /* ------------------------------------------------------------ */
100:            /* 
101:             * @see org.mortbay.log.Log#doDebugEnabled()
102:             */
103:            public boolean isDebugEnabled() {
104:                try {
105:                    return ((Boolean) debugEnabled.invoke(logger, NO_ARGS))
106:                            .booleanValue();
107:                } catch (Exception e) {
108:                    e.printStackTrace();
109:                    return true;
110:                }
111:            }
112:
113:            /* ------------------------------------------------------------ */
114:            /* 
115:             * @see org.mortbay.log.Log#doInfo(java.lang.String, java.lang.Object, java.lang.Object)
116:             */
117:            public void info(String msg, Object arg0, Object arg1) {
118:                try {
119:                    infoSOO.invoke(logger, new Object[] { msg, arg0, arg1 });
120:                } catch (Exception e) {
121:                    e.printStackTrace();
122:                }
123:            }
124:
125:            /* ------------------------------------------------------------ */
126:            /* 
127:             * @see org.mortbay.log.Log#doWarn(java.lang.String, java.lang.Object, java.lang.Object)
128:             */
129:            public void warn(String msg, Object arg0, Object arg1) {
130:                try {
131:                    warnSOO.invoke(logger, new Object[] { msg, arg0, arg1 });
132:                } catch (Exception e) {
133:                    e.printStackTrace();
134:                }
135:            }
136:
137:            /* ------------------------------------------------------------ */
138:            /* 
139:             * @see org.mortbay.log.Log#doWarn(java.lang.String, java.lang.Throwable)
140:             */
141:            public void warn(String msg, Throwable th) {
142:                try {
143:                    if (th instanceof  RuntimeException || th instanceof  Error)
144:                        errorST.invoke(logger, new Object[] { msg, th });
145:                    else
146:                        warnST.invoke(logger, new Object[] { msg, th });
147:                } catch (Exception e) {
148:                    e.printStackTrace();
149:                }
150:            }
151:
152:            /* ------------------------------------------------------------ */
153:            public Logger getLogger(String name) {
154:                try {
155:                    return new Slf4jLog(name);
156:                } catch (Exception e) {
157:                    Log.warn(e);
158:                    return this ;
159:                }
160:            }
161:
162:            /* ------------------------------------------------------------ */
163:            public String toString() {
164:                return logger.toString();
165:            }
166:
167:            /* ------------------------------------------------------------ */
168:            public void setDebugEnabled(boolean enabled) {
169:                warn("setDebugEnabled not implemented", null, null);
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.