1 23 24 29 30 31 package com.sun.enterprise.admin.dottedname.valueaccessor; 32 33 34 import javax.management.MBeanServerConnection ; 35 import javax.management.ObjectName ; 36 import javax.management.Attribute ; 37 38 39 import com.sun.enterprise.admin.dottedname.valueaccessor.PrefixedValueSupport; 40 import com.sun.enterprise.admin.dottedname.valueaccessor.PropertyValueAccessorBase; 41 42 45 public class AnyValueAccessor extends ValueAccessorBase 46 { 47 final ValueAccessor mAttributeAccessor; 48 49 50 public 51 AnyValueAccessor( MBeanServerConnection conn ) 52 { 53 super( conn ); 54 55 mAttributeAccessor = new AttributeValueAccessor( conn ); 56 } 57 58 public Attribute 59 getValue( ObjectName objectName, String valueName ) throws Exception 60 { 61 Attribute attr = null; 62 PropertyValueAccessorBase propertyAccessor= 63 (new PrefixedValueSupport(getMBS()).getPrefixedValueAccessor(valueName)); 64 if ( propertyAccessor!=null ) 65 { 66 attr = propertyAccessor.getValue( objectName, 67 propertyAccessor.extractPrefixedValueName(valueName) ); 68 } 69 else 70 { 71 attr = mAttributeAccessor.getValue( objectName, valueName ); 72 } 73 74 return( attr ); 75 } 76 77 public Attribute 78 setValue( ObjectName objectName, Attribute attr ) throws Exception 79 { 80 Attribute resultAttr = null; 81 82 final String valueName = attr.getName(); 83 PropertyValueAccessorBase propertyAccessor= 84 (new PrefixedValueSupport(getMBS()).getPrefixedValueAccessor(valueName)); 85 if ( propertyAccessor!=null ) 86 { 87 final String propertyName = propertyAccessor.extractPrefixedValueName(valueName); 88 final Attribute newAttr = new Attribute ( propertyName, attr.getValue() ); 89 resultAttr = propertyAccessor.setValue( objectName, newAttr ); 90 } 91 else 92 { 93 resultAttr = mAttributeAccessor.setValue( objectName, attr ); 94 } 95 96 return( resultAttr ); 97 } 98 } 99 100 101 102 | Popular Tags |