Source Code Cross Referenced for JCLLogger.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » runtime » component » http » server » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.runtime.component.http.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package com.bostechcorp.cbesb.runtime.component.http.server;
018:
019:        import org.apache.commons.logging.Log;
020:        import org.apache.commons.logging.LogFactory;
021:        import org.mortbay.log.Logger;
022:
023:        /**
024:         * A jetty6 logger implementation on top of commons-logging
025:         * 
026:         * @author gnodet
027:         */
028:        public class JCLLogger implements  Logger {
029:
030:            private final String name;
031:            private final Log log;
032:
033:            public static void init() {
034:                // TODO: use org.mortbay.log.Log#setLog when available (beta18)
035:                String old = System.getProperty("org.mortbay.log.class");
036:                try {
037:                    System.setProperty("org.mortbay.log.class", JCLLogger.class
038:                            .getName());
039:                    // For the class to be loaded by invoking a public static method
040:                    Class cl = Thread.currentThread().getContextClassLoader()
041:                            .loadClass("org.mortbay.log.Log");
042:                    cl.getMethod("isDebugEnabled", new Class[0]).invoke(null,
043:                            null);
044:                } catch (Exception e) {
045:                    e.printStackTrace();
046:                } finally {
047:                    if (old != null) {
048:                        System.setProperty("org.mortbay.log.class", old);
049:                    } else {
050:                        System.getProperties().remove("org.mortbay.log.class");
051:                    }
052:                }
053:            }
054:
055:            public JCLLogger() {
056:                this ("org.mortbay.jetty");
057:            }
058:
059:            public JCLLogger(String name) {
060:                this .name = name;
061:                this .log = LogFactory.getLog(name);
062:            }
063:
064:            public void debug(String msg, Throwable th) {
065:                log.debug(msg, th);
066:            }
067:
068:            public void debug(String msg, Object arg0, Object arg1) {
069:                if (log.isDebugEnabled()) {
070:                    log.debug(arrayFormat(msg, new Object[] { arg0, arg1 }));
071:                }
072:            }
073:
074:            public Logger getLogger(String name) {
075:                if (name == null) {
076:                    return null;
077:                }
078:                return new JCLLogger(this .name + "." + name);
079:            }
080:
081:            public void info(String msg, Object arg0, Object arg1) {
082:                if (log.isInfoEnabled()) {
083:                    log.info(arrayFormat(msg, new Object[] { arg0, arg1 }));
084:                }
085:            }
086:
087:            public boolean isDebugEnabled() {
088:                return log.isDebugEnabled();
089:            }
090:
091:            public void setDebugEnabled(boolean enabled) {
092:                log.warn("setDebugEnabled not supported");
093:            }
094:
095:            public void warn(String msg, Throwable th) {
096:                log.warn(msg, th);
097:            }
098:
099:            public void warn(String msg, Object arg0, Object arg1) {
100:                if (log.isWarnEnabled()) {
101:                    log.warn(arrayFormat(msg, new Object[] { arg0, arg1 }));
102:                }
103:            }
104:
105:            static final char DELIM_START = '{';
106:            static final char DELIM_STOP = '}';
107:
108:            public static String arrayFormat(String messagePattern,
109:                    Object[] argArray) {
110:                if (messagePattern == null) {
111:                    return null;
112:                }
113:                int i = 0;
114:                int len = messagePattern.length();
115:                int j = messagePattern.indexOf(DELIM_START);
116:
117:                StringBuffer sbuf = new StringBuffer(
118:                        messagePattern.length() + 50);
119:
120:                for (int L = 0; L < argArray.length; L++) {
121:
122:                    char escape = 'x';
123:
124:                    j = messagePattern.indexOf(DELIM_START, i);
125:
126:                    if (j == -1 || (j + 1 == len)) {
127:                        // no more variables
128:                        if (i == 0) { // this is a simple string
129:                            return messagePattern;
130:                        } else { // add the tail string which contains no variables
131:                            // and return the result.
132:                            sbuf.append(messagePattern.substring(i,
133:                                    messagePattern.length()));
134:                            return sbuf.toString();
135:                        }
136:                    } else {
137:                        char delimStop = messagePattern.charAt(j + 1);
138:                        if (j > 0) {
139:                            escape = messagePattern.charAt(j - 1);
140:                        }
141:
142:                        if (escape == '\\') {
143:                            L--; // DELIM_START was escaped, thus should not be
144:                            // incremented
145:                            sbuf.append(messagePattern.substring(i, j - 1));
146:                            sbuf.append(DELIM_START);
147:                            i = j + 1;
148:                        } else if ((delimStop != DELIM_STOP)) {
149:                            // invalid DELIM_START/DELIM_STOP pair
150:                            sbuf.append(messagePattern.substring(i,
151:                                    messagePattern.length()));
152:                            return sbuf.toString();
153:                        } else {
154:                            // normal case
155:                            sbuf.append(messagePattern.substring(i, j));
156:                            sbuf.append(argArray[L]);
157:                            i = j + 2;
158:                        }
159:                    }
160:                }
161:                // append the characters following the second {} pair.
162:                sbuf.append(messagePattern
163:                        .substring(i, messagePattern.length()));
164:                return sbuf.toString();
165:            }
166:        }
w_w_w_.__j___a_va__2__s.___com___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.