Source Code Cross Referenced for ApplLog4jFactory.java in  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » util » log4j » 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 » Workflow Engines » wfmopen 2.1.1 » de.danet.an.util.log4j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the WfMOpen project.
003:         * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004:         * All rights reserved.
005:         *
006:         * This program is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU General Public License as published by
008:         * the Free Software Foundation; either version 2 of the License, or
009:         * (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * $Id: ApplLog4jFactory.java,v 1.3 2007/03/27 21:59:43 mlipp Exp $
021:         *
022:         * $Log: ApplLog4jFactory.java,v $
023:         * Revision 1.3  2007/03/27 21:59:43  mlipp
024:         * Fixed lots of checkstyle warnings.
025:         *
026:         * Revision 1.2  2006/09/29 12:32:13  drmlipp
027:         * Consistently using WfMOpen as projct name now.
028:         *
029:         * Revision 1.1.1.2  2004/08/18 15:17:35  drmlipp
030:         * Update to 1.2
031:         *
032:         * Revision 1.3  2004/06/22 11:52:04  lipp
033:         * Some fixes to match new commons-logging.
034:         *
035:         * Revision 1.2  2003/06/27 08:51:46  lipp
036:         * Fixed copyright/license information.
037:         *
038:         * Revision 1.1  2003/03/28 10:09:20  lipp
039:         * Intriduced logging using commons-logging.
040:         *
041:         */
042:        package de.danet.an.util.log4j;
043:
044:        import java.util.Enumeration;
045:        import java.util.Hashtable;
046:        import java.util.Vector;
047:
048:        import org.apache.commons.logging.Log;
049:        import org.apache.commons.logging.LogConfigurationException;
050:        import org.apache.commons.logging.LogFactory;
051:        import org.apache.commons.logging.impl.Log4JLogger;
052:
053:        /**
054:         * This class provides an alternate access to the log4j logging
055:         * library for Apache commons logging.. The necessity arises from the
056:         * usage of log4j as logging package in the JBoss application
057:         * server. As log4j is already included in JBoss' classpath and
058:         * configured by JBoss, we cannot have really independent application
059:         * level logging.<P>
060:         *
061:         * The central problem is the static default hierarchy used by
062:         * <code>org.apache.log4j.Category</code>. For a distinct application
063:         * level logging we need an alternate hierarchy. This factory uses
064:         * such an alternate hierarchy.<P>
065:         *
066:         * This implementation is based on the <code>Log4JFactory</code> from
067:         * Apache.
068:         *
069:         * @author <a href="mailto:lipp@danet.de">Michael Lipp</a>
070:         * @version $Revision: 1.3 $
071:         */
072:
073:        public class ApplLog4jFactory extends LogFactory {
074:
075:            /**
076:             * The configuration attributes for this {@link LogFactory}.
077:             */
078:            private Hashtable attributes = new Hashtable();
079:
080:            // previously returned instances, to avoid creation of proxies
081:            private Hashtable instances = new Hashtable();
082:
083:            /**
084:             * Return the configuration attribute with the specified name (if any),
085:             * or <code>null</code> if there is no such attribute.
086:             *
087:             * @param name Name of the attribute to return
088:             */
089:            public Object getAttribute(String name) {
090:                return (attributes.get(name));
091:            }
092:
093:            /**
094:             * Return an array containing the names of all currently defined
095:             * configuration attributes.  If there are no such attributes, a zero
096:             * length array is returned.
097:             */
098:            public String[] getAttributeNames() {
099:                Vector names = new Vector();
100:                Enumeration keys = attributes.keys();
101:                while (keys.hasMoreElements()) {
102:                    names.addElement((String) keys.nextElement());
103:                }
104:                String[] results = new String[names.size()];
105:                for (int i = 0; i < results.length; i++) {
106:                    results[i] = (String) names.elementAt(i);
107:                }
108:                return (results);
109:            }
110:
111:            /**
112:             * Convenience method to derive a name from the specified class and
113:             * call <code>getInstance(String)</code> with it.
114:             *
115:             * @param clazz Class for which a suitable Log name will be derived
116:             *
117:             * @exception LogConfigurationException if a suitable <code>Log</code>
118:             *  instance cannot be returned
119:             */
120:            public Log getInstance(Class clazz)
121:                    throws LogConfigurationException {
122:                Log instance = (Log) instances.get(clazz);
123:                if (instance != null) {
124:                    return instance;
125:                }
126:
127:                instance = new Log4JLogger(ApplLogger.getLogger(clazz));
128:                instances.put(clazz, instance);
129:                return instance;
130:            }
131:
132:            public Log getInstance(String name)
133:                    throws LogConfigurationException {
134:                Log instance = (Log) instances.get(name);
135:                if (instance != null) {
136:                    return instance;
137:                }
138:
139:                instance = new Log4JLogger(ApplLogger.getLogger(name));
140:                instances.put(name, instance);
141:                return instance;
142:            }
143:
144:            /**
145:             * Release any internal references to previously created {@link Log}
146:             * instances returned by this factory.  This is useful environments
147:             * like servlet containers, which implement application reloading by
148:             * throwing away a ClassLoader.  Dangling references to objects in that
149:             * class loader would prevent garbage collection.
150:             */
151:            public void release() {
152:                instances.clear();
153:                // what's the log4j mechanism to cleanup ??? 
154:            }
155:
156:            /**
157:             * Remove any configuration attribute associated with the specified name.
158:             * If there is no such attribute, no action is taken.
159:             *
160:             * @param name Name of the attribute to remove
161:             */
162:            public void removeAttribute(String name) {
163:                attributes.remove(name);
164:            }
165:
166:            /**
167:             * Set the configuration attribute with the specified name.  Calling
168:             * this with a <code>null</code> value is equivalent to calling
169:             * <code>removeAttribute(name)</code>.
170:             *
171:             * @param name Name of the attribute to set
172:             * @param value Value of the attribute to set, or <code>null</code>
173:             *  to remove any setting for this attribute
174:             */
175:            public void setAttribute(String name, Object value) {
176:                if (value == null) {
177:                    attributes.remove(name);
178:                } else {
179:                    attributes.put(name, value);
180:                }
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.