Source Code Cross Referenced for EventReader.java in  » IDE-Eclipse » jdt » org » eclipse » debug » jdi » tests » 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 » IDE Eclipse » jdt » org.eclipse.debug.jdi.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         * 
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.debug.jdi.tests;
011:
012:        import java.util.Vector;
013:
014:        import com.sun.jdi.VMDisconnectedException;
015:        import com.sun.jdi.event.AccessWatchpointEvent;
016:        import com.sun.jdi.event.BreakpointEvent;
017:        import com.sun.jdi.event.ClassPrepareEvent;
018:        import com.sun.jdi.event.ClassUnloadEvent;
019:        import com.sun.jdi.event.Event;
020:        import com.sun.jdi.event.EventIterator;
021:        import com.sun.jdi.event.EventQueue;
022:        import com.sun.jdi.event.EventSet;
023:        import com.sun.jdi.event.ExceptionEvent;
024:        import com.sun.jdi.event.MethodEntryEvent;
025:        import com.sun.jdi.event.MethodExitEvent;
026:        import com.sun.jdi.event.ModificationWatchpointEvent;
027:        import com.sun.jdi.event.StepEvent;
028:        import com.sun.jdi.event.ThreadDeathEvent;
029:        import com.sun.jdi.event.ThreadStartEvent;
030:        import com.sun.jdi.event.VMDeathEvent;
031:        import com.sun.jdi.event.VMDisconnectEvent;
032:        import com.sun.jdi.request.EventRequest;
033:
034:        /**
035:         * An event reader that continuously reads events coming from the VM
036:         * and dispatch them to the registered listeners.
037:         */
038:
039:        public class EventReader extends AbstractReader {
040:            private EventQueue fEventQueue;
041:            private Vector fEventListeners = new Vector(); // A Vector of EventListener
042:
043:            /**
044:             * Constructor
045:             * @param name
046:             * @param queue
047:             */
048:            public EventReader(String name, EventQueue queue) {
049:                super (name);
050:                fEventQueue = queue;
051:            }
052:
053:            /**
054:             * Registers the given event listener.
055:             * @param listener
056:             */
057:            public synchronized void addEventListener(EventListener listener) {
058:                fEventListeners.addElement(listener);
059:            }
060:
061:            /**
062:             * Dispatches the given event to the given listener.
063:             * Returns whether the VM should be resumed.
064:             */
065:            private boolean dispath(Event event, EventListener listener) {
066:                if (event instanceof  AccessWatchpointEvent)
067:                    return listener
068:                            .accessWatchpoint((AccessWatchpointEvent) event);
069:                if (event instanceof  BreakpointEvent)
070:                    return listener.breakpoint((BreakpointEvent) event);
071:                if (event instanceof  ClassPrepareEvent)
072:                    return listener.classPrepare((ClassPrepareEvent) event);
073:                if (event instanceof  ClassUnloadEvent)
074:                    return listener.classUnload((ClassUnloadEvent) event);
075:                if (event instanceof  ExceptionEvent)
076:                    return listener.exception((ExceptionEvent) event);
077:                if (event instanceof  MethodEntryEvent)
078:                    return listener.methodEntry((MethodEntryEvent) event);
079:                if (event instanceof  MethodExitEvent)
080:                    return listener.methodExit((MethodExitEvent) event);
081:                if (event instanceof  ModificationWatchpointEvent)
082:                    return listener
083:                            .modificationWatchpoint((ModificationWatchpointEvent) event);
084:                if (event instanceof  StepEvent)
085:                    return listener.step((StepEvent) event);
086:                if (event instanceof  ThreadDeathEvent)
087:                    return listener.threadDeath((ThreadDeathEvent) event);
088:                if (event instanceof  ThreadStartEvent)
089:                    return listener.threadStart((ThreadStartEvent) event);
090:                if (event instanceof  VMDisconnectEvent)
091:                    return listener.vmDisconnect((VMDisconnectEvent) event);
092:                if (event instanceof  VMDeathEvent)
093:                    return listener.vmDeath((VMDeathEvent) event);
094:                return true;
095:            }
096:
097:            /**
098:             * Continuously reads events that are coming from the event queue.
099:             */
100:            protected void readerLoop() {
101:                while (!fIsStopping) {
102:                    try {
103:                        if (!fIsStopping) {
104:                            // Get the next event
105:                            EventSet eventSet = fEventQueue.remove();
106:
107:                            // Dispatch the events
108:                            boolean shouldGo = true;
109:                            EventIterator iterator = eventSet.eventIterator();
110:                            while (iterator.hasNext()) {
111:                                Event event = iterator.nextEvent();
112:                                for (int i = 0; i < fEventListeners.size(); i++) {
113:                                    EventListener listener = (EventListener) fEventListeners
114:                                            .elementAt(i);
115:                                    shouldGo = shouldGo
116:                                            & dispath(event, listener);
117:                                }
118:                                if (event instanceof  VMDeathEvent)
119:                                    stop();
120:                            }
121:
122:                            // Let the VM go if it was interrupted
123:                            if ((!fIsStopping)
124:                                    && (eventSet != null)
125:                                    && (eventSet.suspendPolicy() == EventRequest.SUSPEND_ALL)
126:                                    && shouldGo)
127:                                synchronized (this ) {
128:                                    fEventQueue.virtualMachine().resume();
129:                                }
130:                        }
131:                    } catch (InterruptedException e) {
132:                        if (!fIsStopping) {
133:                            System.out
134:                                    .println("Event reader loop was interrupted");
135:                            return;
136:                        }
137:                    } catch (VMDisconnectedException e) {
138:                        return;
139:                    }
140:                }
141:            }
142:
143:            /**
144:             * De-registers the given event listener.
145:             * @param listener
146:             */
147:            public synchronized void removeEventListener(EventListener listener) {
148:                fEventListeners.removeElement(listener);
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.