1 23 24 25 package com.sun.enterprise.management.offline; 26 27 import java.io.IOException ; 28 29 import javax.management.ObjectName ; 30 import javax.management.MBeanInfo ; 31 import javax.management.MBeanAttributeInfo ; 32 import javax.management.MBeanOperationInfo ; 33 import javax.management.Attribute ; 34 import javax.management.AttributeList ; 35 import javax.management.AttributeNotFoundException ; 36 import javax.management.InvalidAttributeValueException ; 37 38 import com.sun.enterprise.management.support.Delegate; 39 import com.sun.enterprise.management.support.DelegateBase; 40 41 import com.sun.enterprise.config.ConfigContext; 42 import com.sun.enterprise.config.ConfigBean; 43 import com.sun.enterprise.config.ConfigException; 44 45 47 49 class ConfigDelegate extends DelegateBase 50 { 51 private final ConfigBeanHelper mHelper; 52 53 ConfigDelegate( 54 final ConfigContext configContext, 55 final String xPath ) 56 throws ConfigException 57 { 58 super( "ConfigDelegate", null ); 59 mHelper = ConfigBeanHelperFactory.getInstance( configContext ).getHelper( xPath ); 60 } 61 62 ConfigDelegate( 63 final ConfigContext configContext, 64 final ConfigBean configBean ) 65 throws ConfigException 66 { 67 super( "ConfigDelegate", null ); 68 mHelper = ConfigBeanHelperFactory.getInstance( configContext ).getHelper( configBean ); 69 } 70 71 public Object 72 getAttribute( final String attrName ) 73 throws AttributeNotFoundException 74 { 75 final Object result = mHelper.getAttribute(attrName); 76 77 return result; 78 } 79 80 public void 81 setAttribute( final Attribute attr ) 82 throws AttributeNotFoundException , InvalidAttributeValueException 83 { 84 mHelper.setAttribute( attr ); 85 86 flush(); 87 } 88 89 public MBeanInfo 90 getMBeanInfo() 91 { 92 return mHelper.getMBeanInfo(); 93 } 94 95 96 99 public AttributeList 100 getProperties() 101 { 102 return mHelper.getProperties(); 103 } 104 105 108 public String 109 getPropertyValue( final String name ) 110 { 111 return mHelper.getPropertyValue( name ); 112 } 113 114 117 public void 118 setProperty( final Attribute attr ) 119 { 120 mHelper.setProperty( attr ); 121 } 122 123 124 127 public AttributeList 128 getSystemProperties() 129 { 130 return mHelper.getSystemProperties(); 131 } 132 133 134 137 public String 138 getSystemPropertyValue( final String name ) 139 { 140 return mHelper.getSystemPropertyValue( name ); 141 } 142 143 146 public void 147 setSystemProperty( final Attribute attr ) 148 { 149 mHelper.setSystemProperty( attr ); 150 } 151 152 153 public String 154 getDescription() 155 { 156 return mHelper.getDescription(); 157 } 158 159 public void 160 setDescription( final String description ) 161 { 162 mHelper.setDescription( description ); 163 } 164 165 public final Object 166 invoke( 167 String operationName, 168 Object [] args, 169 String [] types ) 170 { 171 Object result = null; 172 final int numArgs = args == null ? 0 : args.length; 173 174 if ( "getProperties".equals( operationName ) && 175 numArgs == 0 ) 176 { 177 result = getProperties(); 178 } 179 else if ( "getPropertyValue".equals( operationName ) && 180 numArgs == 1 && types[0].equals( String .class.getName() ) ) 181 { 182 result = getPropertyValue( (String )args[ 0 ] ); 183 } 184 else if ( "setProperty".equals( operationName ) && 185 numArgs == 1 && types[0].equals( Attribute .class.getName() ) ) 186 { 187 setProperty( (Attribute )args[ 0 ] ); 188 } 189 else if ( "getSystemProperties".equals( operationName ) && 190 numArgs == 0 ) 191 { 192 result = getSystemProperties(); 193 } 194 else if ( "getSystemPropertyValue".equals( operationName ) && 195 numArgs == 1 && types[0].equals( String .class.getName() ) ) 196 { 197 result = getSystemPropertyValue( (String )args[ 0 ] ); 198 } 199 else if ( "setSystemProperty".equals( operationName ) && 200 numArgs == 1 && types[0].equals( Attribute .class.getName() ) ) 201 { 202 setSystemProperty( (Attribute )args[ 0 ] ); 203 } 204 else 205 { 206 result = mHelper.handleInvoke( operationName, args, types ); 207 } 208 209 flush(); 210 211 return result; 212 } 213 214 private void 215 flush() 216 { 217 try 218 { 219 mHelper.getConfigContext().flush(); 220 } 221 catch (ConfigException e) 222 { 223 throw new RuntimeException ( e ); 224 } 225 } 226 } 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | Popular Tags |