Source Code Cross Referenced for VirtualMachineManagerImpl.java in  » IDE-Eclipse » jdt » org » eclipse » jdi » internal » 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.jdi.internal 
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.jdi.internal;
011:
012:        import java.io.FileOutputStream;
013:        import java.io.IOException;
014:        import java.io.InputStream;
015:        import java.io.OutputStream;
016:        import java.io.PrintWriter;
017:        import java.net.URL;
018:        import java.util.ArrayList;
019:        import java.util.List;
020:        import java.util.MissingResourceException;
021:        import java.util.PropertyResourceBundle;
022:
023:        import org.eclipse.jdi.internal.connect.SocketAttachingConnectorImpl;
024:        import org.eclipse.jdi.internal.connect.SocketLaunchingConnectorImpl;
025:        import org.eclipse.jdi.internal.connect.SocketListeningConnectorImpl;
026:        import org.eclipse.jdi.internal.connect.SocketRawLaunchingConnectorImpl;
027:        import org.eclipse.jdt.debug.core.JDIDebugModel;
028:
029:        import com.sun.jdi.VirtualMachine;
030:        import com.sun.jdi.VirtualMachineManager;
031:        import com.sun.jdi.connect.LaunchingConnector;
032:        import com.sun.jdi.connect.spi.Connection;
033:
034:        /**
035:         * this class implements the corresponding interfaces
036:         * declared by the JDI specification. See the com.sun.jdi package
037:         * for more information.
038:         *
039:         */
040:        public class VirtualMachineManagerImpl implements  VirtualMachineManager {
041:            /** Major interface version. */
042:            public static int MAJOR_INTERFACE_VERSION = 1;
043:            /** Minor interface version. */
044:            public static int MINOR_INTERFACE_VERSION = 5;
045:            /** PrintWriter where verbose info is written to, null if no verbose must be given. */
046:            private PrintWriter fVerbosePrintWriter = null;
047:            /** List of all VMs that are currently connected. */
048:            List fConnectedVMs = new ArrayList();
049:            /** True if in verbose mode. */
050:            private boolean fVerbose = false;
051:            /** Name of verbose file. */
052:            private String fVerboseFile = null;
053:
054:            /**
055:             * Creates new VirtualMachineManagerImpl.
056:             */
057:            public VirtualMachineManagerImpl() {
058:
059:                getPreferences();
060:
061:                // See if verbose info must be given.
062:                if (fVerbose) {
063:                    OutputStream out;
064:                    if (fVerboseFile != null && fVerboseFile.length() > 0) {
065:                        try {
066:                            out = new FileOutputStream(fVerboseFile);
067:                        } catch (IOException e) {
068:                            out = System.out;
069:                            System.out
070:                                    .println(JDIMessages.VirtualMachineManagerImpl_Could_not_open_verbose_file___1
071:                                            + fVerboseFile
072:                                            + JDIMessages.VirtualMachineManagerImpl_____2
073:                                            + e); // 
074:                        }
075:                    } else {
076:                        out = System.out;
077:                    }
078:                    fVerbosePrintWriter = new PrintWriter(out);
079:                }
080:            }
081:
082:            /**
083:             * Returns the major version number of the JDI interface.
084:             */
085:            public int majorInterfaceVersion() {
086:                return MAJOR_INTERFACE_VERSION;
087:            }
088:
089:            /**
090:             * Returns the minor version number of the JDI interface.
091:             */
092:            public int minorInterfaceVersion() {
093:                return MINOR_INTERFACE_VERSION;
094:            }
095:
096:            /**
097:             * Loads the user preferences from the jdi.ini file.
098:             */
099:            private void getPreferences() {
100:                // Get jdi.ini info.
101:                URL url = getClass().getResource("/jdi.ini"); //$NON-NLS-1$
102:                if (url == null) {
103:                    return;
104:                }
105:
106:                try {
107:                    InputStream stream = url.openStream();
108:                    PropertyResourceBundle prefs = new PropertyResourceBundle(
109:                            stream);
110:
111:                    try {
112:                        fVerbose = Boolean.valueOf(
113:                                prefs.getString("User.verbose")).booleanValue(); //$NON-NLS-1$
114:                    } catch (MissingResourceException e) {
115:                    }
116:
117:                    try {
118:                        fVerboseFile = prefs.getString("Verbose.out"); //$NON-NLS-1$
119:                    } catch (MissingResourceException e) {
120:                    }
121:
122:                } catch (IOException e) {
123:                }
124:
125:            }
126:
127:            /**
128:             * @return Returns Timeout value for requests to VM, if not overridden for the VM.
129:             * This value is used to throw the exception TimeoutException in JDI calls.
130:             * NOTE: This is not in compliance with the Sun's JDI.
131:             */
132:            public int getGlobalRequestTimeout() {
133:                try {
134:                    if (JDIDebugModel.getPreferences() != null) {
135:                        return JDIDebugModel.getPreferences().getInt(
136:                                JDIDebugModel.PREF_REQUEST_TIMEOUT);
137:                    }
138:                    // JDI plug-in is not loaded
139:                    return JDIDebugModel.DEF_REQUEST_TIMEOUT;
140:                } catch (NoClassDefFoundError e) {
141:                }
142:                // return the hard coded preference if the jdi debug plug-in does not exist
143:                return 3000;
144:            }
145:
146:            /**
147:             * Adds a VM to the connected VM list. 
148:             */
149:            public void addConnectedVM(VirtualMachineImpl vm) {
150:                fConnectedVMs.add(vm);
151:            }
152:
153:            /**
154:             * Removes a VM from the connected VM list. 
155:             */
156:            public void removeConnectedVM(VirtualMachineImpl vm) {
157:                fConnectedVMs.remove(vm);
158:            }
159:
160:            /**
161:             * @return Returns all target VMs which are connected to the debugger. 
162:             */
163:            public List connectedVirtualMachines() {
164:                return fConnectedVMs;
165:            }
166:
167:            /**
168:             * @return Returns all connectors.
169:             */
170:            public List allConnectors() {
171:                List result = new ArrayList(attachingConnectors());
172:                result.addAll(launchingConnectors());
173:                result.addAll(listeningConnectors());
174:                return result;
175:            }
176:
177:            /**
178:             * @return Returns attaching connectors.
179:             */
180:            public List attachingConnectors() {
181:                ArrayList list = new ArrayList(1);
182:                list.add(new SocketAttachingConnectorImpl(this ));
183:                return list;
184:            }
185:
186:            /**
187:             * @return Returns launching connectors.
188:             */
189:            public List launchingConnectors() {
190:                ArrayList list = new ArrayList(2);
191:                list.add(new SocketLaunchingConnectorImpl(this ));
192:                list.add(new SocketRawLaunchingConnectorImpl(this ));
193:                return list;
194:            }
195:
196:            /**
197:             * @return Returns listening connectors.
198:             */
199:            public List listeningConnectors() {
200:                ArrayList list = new ArrayList(1);
201:                list.add(new SocketListeningConnectorImpl(this ));
202:                return list;
203:            }
204:
205:            /**
206:             * @return Returns default connector.
207:             */
208:            public LaunchingConnector defaultConnector() {
209:                return new SocketLaunchingConnectorImpl(this );
210:            }
211:
212:            /**
213:             * @return Returns PrintWriter to which verbose info must be written, or null if no verbose must be given.
214:             */
215:            public PrintWriter verbosePrintWriter() {
216:                return fVerbosePrintWriter;
217:            }
218:
219:            public VirtualMachine createVirtualMachine(Connection connection)
220:                    throws IOException {
221:                VirtualMachineImpl vmImpl = new VirtualMachineImpl(connection);
222:                return vmImpl;
223:            }
224:
225:            public VirtualMachine createVirtualMachine(Connection connection,
226:                    Process process) throws IOException {
227:                VirtualMachineImpl vmImpl = new VirtualMachineImpl(connection);
228:                vmImpl.setLaunchedProcess(process);
229:                return vmImpl;
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.