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


001:        package org.jzonic.jlo.processor;
002:
003:        import org.jzonic.jlo.LogEvent;
004:        import org.jzonic.jlo.LogGenerator;
005:        import org.jzonic.jlo.LogRecord;
006:
007:        import java.util.List;
008:        import java.util.Vector;
009:
010:        /**
011:         * The AsynchronousLogProcessor will process all incoming
012:         * log request inside a separate thread.
013:         *
014:         *@author     mecky
015:         *@created    29. Januar 2002
016:         */
017:        public class AsynchronousLogProcessor extends AbstractLogProcessor
018:                implements  Runnable {
019:
020:            private static List events = new Vector();
021:            private static long counter = 0;
022:            private static Thread threadCleanerUpper = null;
023:            private boolean running = false;
024:            int milliSecondSleepTime = 500;
025:
026:            /**
027:             *  Constructor for the LogHandler object
028:             */
029:            public AsynchronousLogProcessor() {
030:                running = true;
031:                Thread thread = new Thread(this );
032:                thread.setDaemon(true);
033:                thread.start();
034:            }
035:
036:            public void run() {
037:                LogEvent le;
038:                while (running) {
039:                    while (getEvents().iterator().hasNext()) {
040:                        le = getNextRecord();
041:                        handlePipes(le);
042:                        handle(le);
043:                        handleSpecialChannels(le.getLogRecord());
044:                    }
045:                    // time to sleep.
046:                    try {
047:                        Thread.sleep(this .milliSecondSleepTime);
048:                    } catch (Exception e) {
049:                        // we do nothing here
050:                    }
051:                }
052:            }
053:
054:            private synchronized List getEvents() {
055:                return events;
056:            }
057:
058:            /**
059:             *  This method adds a logevent to the qeue of the LogHandler.
060:             *
061:             *@param  handler    the handler for this logevent
062:             *@param  formatter  the formatter for this logevent (can be null)
063:             *@param  lr         the LogRecord
064:             */
065:            public void processEvent(LogGenerator lg, LogRecord lr) {
066:                LogEvent le = new LogEvent(lg.getHandler(), lg.getFormatter(),
067:                        lr);
068:                if (lg.getFilter() != null) {
069:                    if (lg.getFilter().match(lr.getMessage())) {
070:                        getEvents().add(le);
071:                    }
072:                } else {
073:                    getEvents().add(le);
074:                }
075:            }
076:
077:            public void flush() {
078:                while (getEvents().iterator().hasNext()) {
079:                    LogEvent le = getNextRecord();
080:                    if (le.getFormatter() != null) {
081:                        String msg = le.getFormatter().formatMessage(
082:                                le.getLogRecord());
083:                        le.getHandler().publish(msg);
084:                    } else {
085:                        le.getHandler().publish(le.getLogRecord());
086:                    }
087:
088:                }
089:            }
090:
091:            private synchronized LogEvent getNextRecord() {
092:                LogEvent le = (LogEvent) getEvents().iterator().next();
093:                getEvents().remove(le);
094:                return le;
095:            }
096:
097:            public String getProcessorName() {
098:                return "AsynchronousLogProcessor";
099:            }
100:
101:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.