Source Code Cross Referenced for VMOption.java in  » 6.0-JDK-Modules-com.sun » management » com » sun » management » 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 » 6.0 JDK Modules com.sun » management » com.sun.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package com.sun.management;
027:
028:        import sun.management.VMOptionCompositeData;
029:        import javax.management.openmbean.CompositeData;
030:
031:        /**
032:         * Information about a VM option including its value and
033:         * where the value came from which is referred as its
034:         * {@link VMOption.Origin <i>origin</i>}.
035:         * <p>
036:         * Each VM option has a default value.  A VM option can
037:         * be set at VM creation time typically as a command line
038:         * argument to the launcher or an argument passed to the
039:         * VM created using the JNI invocation interface.
040:         * In addition, a VM option may be set via an environment
041:         * variable or a configuration file. A VM option can also
042:         * be set dynamically via a management interface after
043:         * the VM was started.
044:         *
045:         * A <tt>VMOption</tt> contains the value of a VM option
046:         * and the origin of that value at the time this <tt>VMOption</tt>
047:         * object was constructed.  The value of the VM option
048:         * may be changed after the <tt>VMOption</tt> object was constructed,
049:         *
050:         * @see <a href="{@docRoot}/../../../../technotes/guides/vm/index.html">
051:         *         Java Virtual Machine</a>
052:         * @author Mandy Chung
053:         * @since 1.6
054:         */
055:        public class VMOption {
056:            private String name;
057:            private String value;
058:            private boolean writeable;
059:            private Origin origin;
060:
061:            /**
062:             * Origin of the value of a VM option.  It tells where the
063:             * value of a VM option came from.
064:             *
065:             * @since 1.6
066:             */
067:            public enum Origin {
068:                /**
069:                 * The VM option has not been set and its value
070:                 * is the default value.
071:                 */
072:                DEFAULT,
073:                /**
074:                 * The VM option was set at VM creation time typically
075:                 * as a command line argument to the launcher or
076:                 * an argument passed to the VM created using the
077:                 * JNI invocation interface.
078:                 */
079:                VM_CREATION,
080:                /**
081:                 * The VM option was set via an environment variable.
082:                 */
083:                ENVIRON_VAR,
084:                /**
085:                 * The VM option was set via a configuration file.
086:                 */
087:                CONFIG_FILE,
088:                /**
089:                 * The VM option was set via the management interface after the VM
090:                 * was started.
091:                 */
092:                MANAGEMENT,
093:                /**
094:                 * The VM option was set via the VM ergonomic support.
095:                 */
096:                ERGONOMIC,
097:                /**
098:                 * The VM option was set via some other mechanism.
099:                 */
100:                OTHER
101:            }
102:
103:            /**
104:             * Constructs a <tt>VMOption</tt>.
105:             *
106:             * @param name Name of a VM option.
107:             * @param value Value of a VM option.
108:             * @param writeable <tt>true</tt> if a VM option can be set dynamically,
109:             *                  or <tt>false</tt> otherwise.
110:             * @param origin where the value of a VM option came from.
111:             *
112:             * @throws NullPointerException if the name or value is <tt>null</tt>
113:             */
114:            public VMOption(String name, String value, boolean writeable,
115:                    Origin origin) {
116:                this .name = name;
117:                this .value = value;
118:                this .writeable = writeable;
119:                this .origin = origin;
120:            }
121:
122:            /**
123:             * Constructs a <tt>VMOption</tt> object from a
124:             * {@link CompositeData CompositeData}.
125:             */
126:            private VMOption(CompositeData cd) {
127:                // validate the input composite data
128:                VMOptionCompositeData.validateCompositeData(cd);
129:
130:                this .name = VMOptionCompositeData.getName(cd);
131:                this .value = VMOptionCompositeData.getValue(cd);
132:                this .writeable = VMOptionCompositeData.isWriteable(cd);
133:                this .origin = VMOptionCompositeData.getOrigin(cd);
134:            }
135:
136:            /**
137:             * Returns the name of this VM option.
138:             *
139:             * @return the name of this VM option.
140:             */
141:            public String getName() {
142:                return name;
143:            }
144:
145:            /**
146:             * Returns the value of this VM option at the time when
147:             * this <tt>VMOption</tt> was created. The value could have been changed.
148:             *
149:             * @return the value of the VM option at the time when
150:             *         this <tt>VMOption</tt> was created.
151:             */
152:            public String getValue() {
153:                return value;
154:            }
155:
156:            /**
157:             * Returns the origin of the value of this VM option. That is,
158:             * where the value of this VM option came from.
159:             *
160:             * @return where the value of this VM option came from.
161:             */
162:            public Origin getOrigin() {
163:                return origin;
164:            }
165:
166:            /**
167:             * Tests if this VM option is writeable.  If this VM option is writeable,
168:             * it can be set by the {@link HotSpotDiagnosticMXBean#setVMOption
169:             * HotSpotDiagnosticMXBean.setVMOption} method.
170:             *
171:             * @return <tt>true</tt> if this VM option is writeable; <tt>false</tt>
172:             * otherwise.
173:             */
174:            public boolean isWriteable() {
175:                return writeable;
176:            }
177:
178:            public String toString() {
179:                return "VM option: " + getName() + " value: " + value + " "
180:                        + " origin: " + origin + " "
181:                        + (writeable ? "(read-only)" : "(read-write)");
182:            }
183:
184:            /**
185:             * Returns a <tt>VMOption</tt> object represented by the
186:             * given <tt>CompositeData</tt>. The given <tt>CompositeData</tt>
187:             * must contain the following attributes:
188:             * <p>
189:             * <blockquote>
190:             * <table border>
191:             * <tr>
192:             *   <th align=left>Attribute Name</th>
193:             *   <th align=left>Type</th>
194:             * </tr>
195:             * <tr>
196:             *   <td>name</td>
197:             *   <td><tt>java.lang.String</tt></td>
198:             * </tr>
199:             * <tr>
200:             *   <td>value</td>
201:             *   <td><tt>java.lang.String</tt></td>
202:             * </tr>
203:             * <tr>
204:             *   <td>origin</td>
205:             *   <td><tt>java.lang.String</tt></td>
206:             * </tr>
207:             * <tr>
208:             *   <td>writeable</td>
209:             *   <td><tt>java.lang.Boolean</tt></td>
210:             * </tr>
211:             * </table>
212:             * </blockquote>
213:             *
214:             * @param cd <tt>CompositeData</tt> representing a <tt>VMOption</tt>
215:             *
216:             * @throws IllegalArgumentException if <tt>cd</tt> does not
217:             *   represent a <tt>VMOption</tt> with the attributes described
218:             *   above.
219:             *
220:             * @return a <tt>VMOption</tt> object represented by <tt>cd</tt>
221:             *         if <tt>cd</tt> is not <tt>null</tt>;
222:             *         <tt>null</tt> otherwise.
223:             */
224:            public static VMOption from(CompositeData cd) {
225:                if (cd == null) {
226:                    return null;
227:                }
228:
229:                if (cd instanceof  VMOptionCompositeData) {
230:                    return ((VMOptionCompositeData) cd).getVMOption();
231:                } else {
232:                    return new VMOption(cd);
233:                }
234:
235:            }
236:
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.