Source Code Cross Referenced for PortalLogger.java in  » Portal » Open-Portal » com » sun » portal » log » common » 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 » Portal » Open Portal » com.sun.portal.log.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2004 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.log.common;
013:
014:        import java.util.Collections;
015:        import java.util.HashSet;
016:        import java.util.Set;
017:        import java.util.logging.Handler;
018:        import java.util.logging.Logger;
019:
020:        /**
021:         * Use this API to get the portal specific logger. It does additional house-keeping
022:         * jobs on loggers so as to overcome container-specific settings.
023:         * This is just a proxy to the Logger class.
024:         */
025:
026:        // Any changes to this class. Also check ABLogger, SSOAdapterLogger
027:        public class PortalLogger {
028:
029:            static String DEBUG_NAME = "debug";
030:
031:            // Maintains a list of loggers
032:            static Set loggerSet = Collections.synchronizedSet(new HashSet());
033:
034:            static PortalLogManager manager = new PortalLogManager(); //forced classloading
035:
036:            /**
037:             * Add the root logger to the list of loggers and also to the LoggersList
038:             *
039:             * @param rootLoggerName
040:             */
041:            protected static void addRootLogger(String rootLoggerName) {
042:                loggerSet.add(rootLoggerName);
043:                LoggersList.add(rootLoggerName);
044:            }
045:
046:            /**
047:             * Configure the logger.
048:             * Set the logger to use the parent handlers.
049:             * Remove any handlers added by the system.
050:             * When a level is set on a particular logger. All the child loggers of that
051:             * logger do not inherit the level of the parent logger. Bug in Webserver ???
052:             * Hence its explicitly set to that of the default. i.e All the loggers are
053:             * set to a default level. This is done only once as any change in the level
054:             * has to be retained.
055:             */
056:            private static Logger config(Logger logger) {
057:                String loggerName = logger.getName();
058:
059:                if (!loggerSet.contains(loggerName)) {
060:                    if (!manager.useServerLogs(loggerName)) {
061:                        logger.setUseParentHandlers(true);
062:                        // Set the level to the default level
063:                        logger.setLevel(manager.getLevel(loggerName));
064:                        // Remove the handlers added by the system
065:                        Handler[] handlers = logger.getHandlers();
066:                        for (int i = 0; i < handlers.length; i++) {
067:                            logger.removeHandler(handlers[i]);
068:                        }
069:                    }
070:                    loggerSet.add(loggerName);
071:                }
072:                LoggersList.add(loggerName);
073:                return logger;
074:            }
075:
076:            /**
077:             * Returns the Logger for the class object.
078:             * Derives the package name from the class object and uses it
079:             * to create the Logger.
080:             *
081:             * @param cls a class object
082:             * @return the Logger
083:             */
084:            public static Logger getLogger(Class cls) {
085:                return config(Logger.getLogger(getName(cls)));
086:            }
087:
088:            /**
089:             * Returns the Logger for the specified name.
090:             * This method is used by those classes that do not follow
091:             * com.sun.portal namespace. This is used in place if the
092:             * above method <code>getLogger(Class cls)</code>.
093:             *
094:             * @param name the package name
095:             * @return the Logger
096:             */
097:            public static Logger getLogger(String name) {
098:                return config(Logger.getLogger(getName(name)));
099:            }
100:
101:            /**
102:             * Derives the package name from the class object and prepends it
103:             * with "debug".
104:             *
105:             * @param cls a class object
106:             * @return the package name prepended with 'debug'.
107:             */
108:            private static String getName(Class cls) {
109:                Package pkg = cls.getPackage();
110:                String packageName = (pkg == null) ? getDefaultPkgName(cls)
111:                        : pkg.getName();
112:                String correctName = correct(packageName);
113:                return correctName;
114:            }
115:
116:            private static String getDefaultPkgName(Class cls) {
117:                String className = cls.getName();
118:                String pkgName = DEBUG_NAME;
119:                int index = -1;
120:                if (className != null) {
121:                    index = className.lastIndexOf(".");
122:                }
123:                if (index != -1) {
124:                    pkgName = className.substring(0, index);
125:                }
126:                return pkgName;
127:            }
128:
129:            /**
130:             * Prepends the package name with "debug".
131:             *
132:             * @param name the package name
133:             * @return the package name prepended with 'debug'.
134:             */
135:            private static String getName(String name) {
136:                String correctName = correct(name);
137:                return correctName;
138:            }
139:
140:            /**
141:             * Prepends the name with "debug" if its not present.
142:             *
143:             * @param name the package name
144:             * @return the package name prepended with 'debug'.
145:             */
146:            private static String correct(String name) {
147:                if (name.indexOf(DEBUG_NAME) != 0) {
148:                    StringBuffer csuffix = new StringBuffer();
149:                    csuffix.append(DEBUG_NAME);
150:                    csuffix.append(".");
151:                    csuffix.append(name);
152:                    return csuffix.toString();
153:                } else {
154:                    return name;
155:                }
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.