1 23 24 package com.sun.enterprise.admin.server.core.mbean.config; 25 26 39 40 import javax.management.*; 42 43 import com.sun.enterprise.config.ConfigException; 45 import com.sun.enterprise.config.serverbeans.ServerTags; 46 import com.sun.enterprise.config.serverbeans.JavaConfig; 47 import com.sun.enterprise.config.serverbeans.Profiler; 48 49 import com.sun.enterprise.admin.server.core.mbean.meta.MBeanEasyConfig; 51 import com.sun.enterprise.admin.common.exception.MBeanConfigException; 52 import com.sun.enterprise.admin.common.constant.ConfigAttributeName; 53 import com.sun.enterprise.admin.common.ObjectNames; 54 55 public class ManagedJVM extends ConfigMBeanBase implements ConfigAttributeName.JavaConfig 56 { 57 private static final String [][] MAPLIST = { 58 { kJavaHome, ATTRIBUTE + ServerTags.JAVA_HOME }, 59 { kDebugEnabled, ATTRIBUTE + ServerTags.DEBUG_ENABLED }, 60 { kDebugOptions, ATTRIBUTE + ServerTags.DEBUG_OPTIONS }, 61 { kRmicOptions, ATTRIBUTE + ServerTags.RMIC_OPTIONS}, 62 { kJavacOptions, ATTRIBUTE + ServerTags.JAVAC_OPTIONS}, 63 { kClasspathPrefix, ATTRIBUTE + ServerTags.CLASSPATH_PREFIX}, 64 { kServerClasspath, ATTRIBUTE + ServerTags.SERVER_CLASSPATH}, 65 { kClasspathSuffix, ATTRIBUTE + ServerTags.CLASSPATH_SUFFIX}, 66 { kNativeLibraryPathPrefix, ATTRIBUTE + ServerTags.NATIVE_LIBRARY_PATH_PREFIX}, 67 { kNativeLibraryPathSuffix, ATTRIBUTE + ServerTags.NATIVE_LIBRARY_PATH_SUFFIX}, 68 { kEnvClasspathIgnored, ATTRIBUTE + ServerTags.ENV_CLASSPATH_IGNORED}, 69 }; 70 71 private static final String [] ATTRIBUTES = { 72 kJavaHome + ", String, RW", 73 kDebugEnabled + ", boolean, RW", 74 kDebugOptions + ", String, RW", 75 kRmicOptions + ", String, RW", 76 kJavacOptions + ", String, RW", 77 kClasspathPrefix + ", String, RW", 78 kServerClasspath + ", String, RW", 79 kClasspathSuffix + ", String, RW", 80 kNativeLibraryPathPrefix + ", String, RW", 81 kNativeLibraryPathSuffix + ", String, RW", 82 kEnvClasspathIgnored + ", boolean, RW", 83 }; 84 85 private static final String [] OPERATIONS = 86 { 87 "createProfiler(String name, String classpath, String nativeLibraryPath, Boolean enabled), ACTION", 88 "deleteProfiler(), ACTION", 89 "isProfilerExist(), INFO", 90 "getProfiler(), INFO", 91 "getJvmOptions(), INFO", 92 "setJvmOptions(String[] options), ACTION", 93 }; 94 95 private final String JVM_NODE_PATH = "/server/java-config"; 96 97 100 public ManagedJVM() throws MBeanConfigException 101 { 102 this.setDescriptions(MAPLIST, ATTRIBUTES, OPERATIONS); 103 } 104 105 109 public ManagedJVM(String instanceName) throws MBeanConfigException 110 { 111 this(); initialize(ObjectNames.kJvmType, new String []{instanceName}); 113 } 114 115 119 public void createProfiler(String name, String classpath, String nativeLibraryPath, Boolean enabled) throws ConfigException 120 { 121 Profiler element = new Profiler(); 122 if(name!=null) 123 element.setName(name); 124 if(classpath!=null) 125 element.setClasspath(classpath); 126 if(nativeLibraryPath!=null) 127 element.setNativeLibraryPath(nativeLibraryPath); 128 if(enabled!=null) 129 element.setEnabled(enabled.booleanValue()); 130 JavaConfig javaConfig = (JavaConfig)getBaseConfigBean(); 131 javaConfig.setProfiler(element); 132 133 getConfigContext().flush(); 134 } 135 136 140 public void deleteProfiler() throws ConfigException 141 { 142 JavaConfig javaConfig = (JavaConfig)getBaseConfigBean(); 143 javaConfig.setProfiler(null); 144 getConfigContext().flush(); 145 } 146 147 151 public boolean isProfilerExist() throws ConfigException 152 { 153 JavaConfig javaConfig = (JavaConfig)getBaseConfigBean(); 154 return (javaConfig.getProfiler()!=null); 155 } 156 157 161 public String getProfiler() throws ConfigException 162 { 163 String profilerName = null; 164 JavaConfig javaConfig = (JavaConfig)getBaseConfigBean(); 165 Profiler profiler = javaConfig.getProfiler(); 166 if (profiler != null) 167 { 168 profilerName = profiler.getName(); 169 } 170 return profilerName; 171 } 172 173 176 public String [] getJvmOptions() throws ConfigException 177 { 178 JavaConfig javaConfig = (JavaConfig)getBaseConfigBean(); 179 return javaConfig.getJvmOptions(); 180 } 181 182 185 public void setJvmOptions(String [] options) throws ConfigException 186 { 187 JavaConfig javaConfig = (JavaConfig)getBaseConfigBean(); 188 javaConfig.setJvmOptions(options); 189 getConfigContext().flush(); 190 } 191 } 192 | Popular Tags |