Source Code Cross Referenced for LogConfiguration.java in  » Development » jLo » org » jzonic » jlo » 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 » jLo » org.jzonic.jlo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jzonic.jlo;
002:
003:        import java.util.HashMap;
004:        import java.util.Vector;
005:        import org.jzonic.jlo.filter.LogFilter;
006:
007:        /**
008:         * The LogConfiguration keeps everything together. It contains
009:         * all logger, channels, filter, pipes and log-generator for one particular
010:         * configuration. The LogManager keeps a list of several
011:         * log configurations.
012:         *
013:         * @author Andreas Mecky
014:         * @author Terry Dye
015:         */
016:        public class LogConfiguration {
017:
018:            private String configurationName;
019:            private HashMap logger;
020:            private HashMap generator;
021:            private HashMap channels;
022:            private Vector pipes;
023:            private HashMap filters;
024:
025:            /**
026:             * @param configurationName
027:             */
028:            public LogConfiguration(String configurationName) {
029:                logger = new HashMap();
030:                generator = new HashMap();
031:                channels = new HashMap();
032:                pipes = new Vector();
033:                filters = new HashMap();
034:                this .configurationName = configurationName;
035:            }
036:
037:            /**
038:             * This method returns a channel with the given name from this configuration.
039:             *
040:             * @param name the name of the channel
041:             * @return the specific channel or NULL if the channel is not inside the configuration
042:             */
043:            public Channel getChannel(String name) {
044:                Channel channel = (Channel) channels.get(name);
045:                return channel;
046:            }
047:
048:            /**
049:             * This method is used internally to search for a channel.
050:             * It is exactly the same as findLoggerName except that
051:             * it searches through the channels.
052:             */
053:            private String findChannelName(String name) {
054:                boolean searching = true;
055:                String myName = name;
056:                while (searching) {
057:                    if (!channels.containsKey(myName)) {
058:                        int pos = myName.lastIndexOf(".");
059:                        if (pos != -1) {
060:                            myName = myName.substring(0, pos);
061:                        } else {
062:                            searching = false;
063:                            myName = null;
064:                        }
065:                    } else {
066:                        searching = false;
067:                    }
068:                }
069:                return myName;
070:            }
071:
072:            /**
073:             * This method returns a logger from this configuration
074:             * with the specific name. This method will try to search
075:             * for a matching logger using the findLoggerName method.
076:             *
077:             * @param name the name of the logger
078:             * @return the particular logger or a matching logger or NULL if not found
079:             */
080:            public Logger getLogger(String name) {
081:                String myName = findLoggerName(name);
082:                Logger myLogger = (Logger) logger.get(myName);
083:                return myLogger;
084:            }
085:
086:            /**
087:             * This method is used internally to find a logger by a given
088:             * name. If the given names is org.jzonic.jlo.test then
089:             * the method will look for this name first. If not found then
090:             * it will cut off the last part of the name from the last "."
091:             * and try it again.
092:             */
093:            private String findLoggerName(String name) {
094:                boolean searching = true;
095:                String myName = name;
096:                while (searching) {
097:                    if (!logger.containsKey(myName)) {
098:                        int pos = myName.lastIndexOf(".");
099:                        if (pos != -1) {
100:                            myName = myName.substring(0, pos);
101:                        } else {
102:                            searching = false;
103:                            myName = null;
104:                        }
105:                    } else {
106:                        searching = false;
107:                    }
108:                }
109:                return myName;
110:            }
111:
112:            /**
113:             * This method adds a logger to this configuration with
114:             * the name of the logger. The name of the logger is used
115:             * as key so it is not possible to add two loggers with the
116:             * same name. The second one will overwrite the first one.
117:             *
118:             * @param l the logger that will be added
119:             */
120:            public void addLogger(Logger l) {
121:                if (l != null) {
122:                    if (l.getLoggerName() != null) {
123:                        logger.put(l.getLoggerName(), l);
124:                    }
125:                }
126:            }
127:
128:            /**
129:             * This method returns the number of loggers in this
130:             * configuration.
131:             *
132:             * @return number of loggers
133:             */
134:            public int getLoggerCount() {
135:                return logger.size();
136:            }
137:
138:            /**
139:             * This method adds a LogGenerator to the configuration.
140:             * The name of the LogGenerator is the key. It is not
141:             * possible to add two LogGenerator with the same name.
142:             * The second one will overwrite the first one.
143:             *
144:             * @param lg the LogGenerator that will be added
145:             */
146:            public void addLogGenerator(LogGenerator lg) {
147:                if (lg != null) {
148:                    if (lg.getName() != null) {
149:                        generator.put(lg.getName(), lg);
150:                    }
151:                }
152:            }
153:
154:            /**
155:             * This method returns a LogGenerator with the given name
156:             * or NULL if the log generator is not in this configuration.
157:             *
158:             * @param name the name of the log generator
159:             * @return the log generator
160:             */
161:            public LogGenerator getLogGenerator(String name) {
162:                return (LogGenerator) generator.get(name);
163:            }
164:
165:            /**
166:             * This method returns the number of LogGenerators
167:             * in this configuration.
168:             *
169:             * @return number of log generators
170:             */
171:            public int getLogGeneratorCount() {
172:                return generator.size();
173:            }
174:
175:            /**
176:             * This method adds a channel to the configuration. This
177:             * channel is stored with the given name as key. It is
178:             * not possible to add two channels with the same name.
179:             * The second one will overwrite the first one.
180:             *
181:             * @param channel the channel to add
182:             */
183:            public void addChannel(Channel channel) {
184:                if (channel != null) {
185:                    if (channel.getChannelName() != null) {
186:                        channels.put(channel.getChannelName(), channel);
187:                    }
188:                }
189:            }
190:
191:            /**
192:             * This method returns the number of channel in this
193:             * configuration.
194:             *
195:             * @return number of channels
196:             */
197:            public int getChannelCount() {
198:                return channels.size();
199:            }
200:
201:            /**
202:             * This method returns the name of the configuration
203:             *
204:             * @return the name of the configuration
205:             *
206:             */
207:            public String getName() {
208:                return configurationName;
209:            }
210:
211:            /**
212:             * @param pipe
213:             */
214:            public void addLogPipe(LogPipe pipe) {
215:                if (pipe != null) {
216:                    pipes.add(pipe);
217:                }
218:            }
219:
220:            /**
221:             * This method returns all LogPipes
222:             *
223:             * @return a Vector containing all logpipes
224:             */
225:            public Vector getLogPipes() {
226:                return pipes;
227:            }
228:
229:            /**
230:             * This method returns the number of LogPipes
231:             * for this configuration.
232:             *
233:             * @return number of pipes
234:             */
235:            public int getLogPipesCount() {
236:                return pipes.size();
237:            }
238:
239:            /**
240:             * @param name
241:             * @param filter
242:             */
243:            public void addLogFilter(String name, LogFilter filter) {
244:                filters.put(name, filter);
245:            }
246:
247:            /**
248:             * @param name
249:             * @return
250:             */
251:            public LogFilter getLogFilter(String name) {
252:                return (LogFilter) filters.get(name);
253:            }
254:
255:            /**
256:             * @return
257:             */
258:            public int getFilterCount() {
259:                return filters.size();
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.