1 23 24 25 package com.sun.enterprise.management.offline; 26 27 import java.util.Set ; 28 import java.util.List ; 29 import java.util.Arrays ; 30 31 import javax.management.AttributeNotFoundException ; 32 import javax.management.InvalidAttributeValueException ; 33 34 import com.sun.appserv.management.util.misc.StringUtil; 35 import com.sun.appserv.management.util.misc.GSetUtil; 36 37 import com.sun.enterprise.config.ConfigContext; 38 import com.sun.enterprise.config.ConfigBean; 39 import com.sun.enterprise.config.ConfigException; 40 41 42 final class JavaConfigConfigBeanHelper extends StdConfigBeanHelper 43 { 44 static private final String JVM_OPTIONS_ATTR = "JvmOptions"; 45 46 public 47 JavaConfigConfigBeanHelper( 48 final ConfigContext configContext, 49 final ConfigBean configBean ) 50 { 51 super( configContext, configBean ); 52 53 } 54 55 56 private boolean 57 hasJVMOptions() 58 { 59 return hasValue( JVM_OPTIONS_ATTR ); 60 } 61 62 protected Set <String > 63 _getAttributeNames() 64 { 65 final Set <String > attrNames = super._getAttributeNames(); 66 67 if ( hasJVMOptions() ) 68 { 69 attrNames.add( JVM_OPTIONS_ATTR ); 70 } 71 72 return attrNames; 73 } 74 75 76 protected Class 77 getAttributeClass( final String attrName ) 78 { 79 Class result = null; 80 81 if ( JVM_OPTIONS_ATTR.equals( attrName ) ) 82 { 83 result = String [].class; 84 } 85 else 86 { 87 result = super.getAttributeClass( attrName ); 88 } 89 return result; 90 } 91 92 public Object 93 getAttribute( final String attrName ) 94 throws AttributeNotFoundException 95 { 96 Object result = null; 97 98 if ( JVM_OPTIONS_ATTR.equals( attrName ) ) 99 { 100 result = getJVMOptions(); 101 } 102 else 103 { 104 result = super.getAttribute( attrName ); 105 } 106 return result; 107 } 108 109 public void 110 setAttribute( final String name, final Object value ) 111 throws AttributeNotFoundException , InvalidAttributeValueException 112 { 113 if ( JVM_OPTIONS_ATTR.equals( name ) ) 114 { 115 setJVMOptions( (String [])value ); 116 } 117 else 118 { 119 super.setAttribute( name, value ); 120 } 121 } 122 123 124 private com.sun.enterprise.config.serverbeans.JavaConfig 125 getJavaConfigConfigBean() 126 { 127 return (com.sun.enterprise.config.serverbeans.JavaConfig) 128 getConfigBean(); 129 } 130 131 public String [] 132 getJVMOptions() 133 { 134 final String [] result = getJavaConfigConfigBean().getJvmOptions(); 136 137 return result; 138 } 139 140 public void 141 setJVMOptions( final String [] optionsIn ) 142 { 143 final Set <String > optionsSet = GSetUtil.newUnmodifiableStringSet( optionsIn ); 145 final String [] options = GSetUtil.toStringArray( optionsSet ); 146 Arrays.sort( options ); 147 148 getJavaConfigConfigBean().setJvmOptions( options ); 149 } 150 151 } 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | Popular Tags |