Source Code Cross Referenced for AttachSettings.java in  » IDE-Netbeans » cvsclient » org » netbeans » lib » profiler » common » 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 Netbeans » cvsclient » org.netbeans.lib.profiler.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         * The Original Software is NetBeans. The Initial Developer of the Original
026:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027:         * Microsystems, Inc. All Rights Reserved.
028:         *
029:         * If you wish your version of this file to be governed by only the CDDL
030:         * or only the GPL Version 2, indicate your decision by adding
031:         * "[Contributor] elects to include this software in this distribution
032:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
033:         * single choice of license, a recipient has the option to distribute
034:         * your version of this file under either the CDDL, the GPL Version 2 or
035:         * to extend the choice of license to its licensees as provided above.
036:         * However, if you add GPL Version 2 code and therefore, elected the GPL
037:         * Version 2 license, then the option applies only if the new code is
038:         * made subject to such option by the copyright holder.
039:         */
040:
041:        package org.netbeans.lib.profiler.common;
042:
043:        import org.netbeans.lib.profiler.ProfilerEngineSettings;
044:        import org.netbeans.lib.profiler.common.integration.IntegrationUtils;
045:        import java.util.Map;
046:
047:        /**
048:         * Storage of all settings that affect the method of attaching.
049:         *
050:         * @author Tomas Hurka
051:         * @author Ian Formanek
052:         * @author Misha Dmitriev
053:         */
054:        public final class AttachSettings {
055:            //~ Static fields/initializers -----------------------------------------------------------------------------------------------
056:
057:            public static final String PROP_ATTACH_DIRECT = "profiler.attach.direct"; //NOI18N
058:            public static final String PROP_ATTACH_REMOTE = "profiler.attach.remote"; //NOI18N
059:            public static final String PROP_ATTACH_DYNAMIC_JDK16 = "profiler.attach.dynamic.jdk16"; //NOI18N
060:            public static final String PROP_ATTACH_HOST = "profiler.attach.host"; //NOI18N
061:            public static final String PROP_ATTACH_PORT = "profiler.attach.port"; //NOI18N
062:
063:            // following items are for settings persistency only, they don't affect attaching at all
064:            public static final String PROP_ATTACH_TARGET_TYPE = "profiler.attach.target.type"; //NOI18N
065:            public static final String PROP_ATTACH_SERVER_TYPE = "profiler.attach.server.type"; //NOI18N
066:            public static final String PROP_ATTACH_HOST_OS = "profiler.attach.host.os"; //NOI18N
067:
068:            //~ Instance fields ----------------------------------------------------------------------------------------------------------
069:
070:            // for remote:
071:            private String host = ""; // NOI18N
072:            private String hostOS = ""; // NOI18N
073:            private String hostOS_dbl = new String(hostOS);
074:            private String host_dbl = new String(host);
075:            private String remoteHostOS = "";
076:            private String serverType = ""; // NOI18N
077:            private String serverType_dbl = new String(serverType);
078:
079:            // for persistence only:
080:            private String targetType = ""; // NOI18N
081:            private String targetType_dbl = new String(targetType);
082:
083:            // Direct is true means what we also call "attach on startup" - when the target VM is started with all necessary options
084:            // and waits for us to connect. It can be used both for local and remote profiling. In fact, currently remote profiling
085:            // can only be done in this way, but later we can implement an equivalent of "remote Ctrl+Break" or something. In that case,
086:            // the constructor of the AttachSettings for remote profiling will have to be modified.
087:            private boolean direct = true;
088:            private boolean direct_dbl = direct;
089:
090:            // for local:
091:            private boolean dynamic16 = false;
092:            private boolean dynamic16_dbl = dynamic16;
093:            private boolean remote = false;
094:            private boolean remote_dbl = remote;
095:            private int pid = -1;
096:            private int pid_dbl = pid;
097:            private int transientPort = -1;
098:            private int transientPort_dbl = transientPort;
099:
100:            //~ Constructors -------------------------------------------------------------------------------------------------------------
101:
102:            /** Create AttachSettings for direct local profiling */
103:            public AttachSettings() {
104:                remote = false;
105:                direct = true;
106:
107:                hostOS = IntegrationUtils.getLocalPlatform(-1);
108:            }
109:
110:            //~ Methods ------------------------------------------------------------------------------------------------------------------
111:
112:            public void setDirect(final boolean direct) {
113:                this .direct = direct;
114:            }
115:
116:            public boolean isDirect() {
117:                return direct;
118:            }
119:
120:            public void setDynamic16(final boolean dynamic) {
121:                this .dynamic16 = dynamic;
122:            }
123:
124:            public boolean isDynamic16() {
125:                return dynamic16;
126:            }
127:
128:            public void setHost(final String host) {
129:                if (host == null) {
130:                    throw new IllegalArgumentException();
131:                }
132:
133:                this .host = host;
134:            }
135:
136:            public String getHost() {
137:                return host;
138:            }
139:
140:            public void setHostOS(final String hostOS) {
141:                if (hostOS != null) {
142:                    this .hostOS = hostOS;
143:                } else {
144:                    if (remote) {
145:                        this .hostOS = remoteHostOS;
146:                    } else {
147:                        this .hostOS = IntegrationUtils.getLocalPlatform(-1);
148:                    }
149:                }
150:            }
151:
152:            public String getHostOS() {
153:                return hostOS;
154:            }
155:
156:            public void setPid(final int pid) {
157:                this .pid = pid;
158:            }
159:
160:            public int getPid() {
161:                return pid;
162:            }
163:
164:            /** This is only intended to be used to handle AttachSettings defined via ant.
165:             *
166:             * @param port A port to use insteead of globally defined port. The value is transient and will not be persisted.
167:             */
168:            public void setPort(final int port) {
169:                this .transientPort = port;
170:            }
171:
172:            public int getPort() {
173:                if (transientPort != -1) {
174:                    return transientPort;
175:                } else {
176:                    return Profiler.getDefault().getGlobalProfilingSettings()
177:                            .getPortNo();
178:                }
179:            }
180:
181:            public void setRemote(final boolean remote) {
182:                this .remote = remote;
183:            }
184:
185:            public boolean isRemote() {
186:                return remote;
187:            }
188:
189:            public void setServerType(final String serverType) {
190:                this .serverType = serverType;
191:            }
192:
193:            public String getServerType() {
194:                return serverType;
195:            }
196:
197:            public void setTargetType(final String targetType) {
198:                this .targetType = targetType;
199:            }
200:
201:            public String getTargetType() {
202:                return targetType;
203:            }
204:
205:            public void applySettings(
206:                    final ProfilerEngineSettings sharedSettings) {
207:                sharedSettings.setPortNo(getPort());
208:
209:                if (remote) {
210:                    sharedSettings.setRemoteHost(host);
211:                } else {
212:                    sharedSettings.setRemoteHost(""); // NOI18N
213:                }
214:            }
215:
216:            public boolean commit() {
217:                boolean dirty = false;
218:
219:                if (direct != direct_dbl) {
220:                    dirty = true;
221:                    direct_dbl = direct;
222:                }
223:
224:                if (remote != remote_dbl) {
225:                    dirty = true;
226:                    remote_dbl = remote;
227:                }
228:
229:                if (dynamic16 != dynamic16_dbl) {
230:                    dirty = true;
231:                    dynamic16_dbl = dynamic16;
232:                }
233:
234:                // changing dynamic attach method doesn't mean changing attach parameters
235:                //    if (pid != pid_dbl) {
236:                //      dirty = true;
237:                //      pid_dbl = pid;
238:                //    }
239:                if ((host_dbl == null) || !host.equalsIgnoreCase(host_dbl)) {
240:                    dirty = true;
241:                    host_dbl = new String(host);
242:                }
243:
244:                if (transientPort_dbl != transientPort) {
245:                    dirty = true;
246:                    transientPort_dbl = transientPort;
247:                }
248:
249:                if ((targetType_dbl == null)
250:                        || !targetType.equalsIgnoreCase(targetType_dbl)) {
251:                    dirty = true;
252:                    targetType_dbl = new String(targetType);
253:                }
254:
255:                if ((serverType_dbl == null)
256:                        || !serverType.equalsIgnoreCase(serverType_dbl)) {
257:                    dirty = true;
258:                    serverType_dbl = new String(serverType);
259:                }
260:
261:                if ((hostOS_dbl == null)
262:                        || !hostOS.equalsIgnoreCase(hostOS_dbl)) {
263:                    dirty = true;
264:                    hostOS_dbl = new String(hostOS);
265:                }
266:
267:                return dirty;
268:            }
269:
270:            public void copyInto(AttachSettings as) {
271:                as.direct = direct;
272:                as.direct_dbl = direct_dbl;
273:                as.remote = remote;
274:                as.remote_dbl = remote_dbl;
275:                as.dynamic16 = dynamic16;
276:                as.dynamic16_dbl = dynamic16_dbl;
277:                as.pid = pid;
278:                as.pid_dbl = pid_dbl;
279:                as.host = host;
280:                as.host_dbl = host_dbl;
281:                as.targetType = targetType;
282:                as.targetType_dbl = targetType_dbl;
283:                as.serverType = serverType;
284:                as.serverType_dbl = serverType_dbl;
285:                as.hostOS = hostOS;
286:                as.hostOS_dbl = hostOS_dbl;
287:                as.remoteHostOS = remoteHostOS;
288:            }
289:
290:            public String debug() {
291:                return toString();
292:            }
293:
294:            public void load(final Map props) {
295:                direct = Boolean.valueOf(
296:                        ProfilingSettings.getProperty(props,
297:                                PROP_ATTACH_DIRECT, "true")).booleanValue(); //NOI18N
298:                remote = Boolean.valueOf(
299:                        ProfilingSettings.getProperty(props,
300:                                PROP_ATTACH_REMOTE, "false")).booleanValue(); //NOI18N
301:                dynamic16 = Boolean.valueOf(
302:                        ProfilingSettings.getProperty(props,
303:                                PROP_ATTACH_DYNAMIC_JDK16, "false"))
304:                        .booleanValue(); //NOI18N
305:                host = ProfilingSettings.getProperty(props, PROP_ATTACH_HOST,
306:                        ""); //NOI18N
307:                targetType = ProfilingSettings.getProperty(props,
308:                        PROP_ATTACH_TARGET_TYPE, ""); //NOI18N
309:                serverType = ProfilingSettings.getProperty(props,
310:                        PROP_ATTACH_SERVER_TYPE, ""); //NOI18N
311:                remoteHostOS = ProfilingSettings.getProperty(props,
312:                        PROP_ATTACH_HOST_OS, IntegrationUtils
313:                                .getLocalPlatform(-1)); //NOI18N
314:            }
315:
316:            public void store(final Map props) {
317:                props.put(PROP_ATTACH_DIRECT, Boolean.toString(direct));
318:                props.put(PROP_ATTACH_REMOTE, Boolean.toString(remote));
319:                props.put(PROP_ATTACH_DYNAMIC_JDK16, Boolean
320:                        .toString(dynamic16));
321:                props.put(PROP_ATTACH_HOST, host);
322:                props.put(PROP_ATTACH_TARGET_TYPE, targetType);
323:                props.put(PROP_ATTACH_SERVER_TYPE, serverType);
324:                props.put(PROP_ATTACH_HOST_OS, hostOS);
325:            }
326:
327:            public String toString() {
328:                final StringBuffer sb = new StringBuffer();
329:                sb.append("target type =" + targetType); //NOI18N
330:                sb.append("\n"); //NOI18N
331:                sb.append("server type =" + serverType); //NOI18N
332:                sb.append("\n"); //NOI18N
333:                sb.append("remote =" + remote); //NOI18N
334:                sb.append("\n"); //NOI18N
335:                sb.append("direct =" + direct); //NOI18N
336:                sb.append("\n"); //NOI18N
337:                sb.append("dynamic JDK16 =" + dynamic16); //NOI18N
338:                sb.append("\n"); //NOI18N
339:                sb.append("pid =" + pid); //NOI18N
340:                sb.append("\n"); //NOI18N
341:                sb.append("host =" + host); //NOI18N
342:                sb.append("\n"); //NOI18N
343:                sb.append("host os =" + hostOS); //NOI18N
344:                sb.append("\n"); //NOI18N
345:                sb.append("transient port =" + transientPort); //NOI18N
346:                sb.append("\n"); //NOI18N
347:
348:                return sb.toString();
349:            }
350:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.