1 23 24 29 package com.sun.enterprise.admin.dottedname.valueaccessor; 30 31 32 import javax.management.Attribute ; 33 import javax.management.AttributeList ; 34 import javax.management.ObjectName ; 35 import javax.management.MBeanServerConnection ; 36 import javax.management.ReflectionException ; 37 import javax.management.MBeanException ; 38 import javax.management.InstanceNotFoundException ; 39 import javax.management.AttributeNotFoundException ; 40 import javax.management.RuntimeOperationsException ; 41 import javax.management.JMException ; 42 43 import javax.management.MBeanServerConnection ; 44 45 public abstract class PrefixedValueAccessorBase extends ValueAccessorBase 46 { 47 String _prefix = null; 49 public PrefixedValueAccessorBase(MBeanServerConnection conn, String prefix) 50 { 51 super( conn ); 52 _prefix = prefix; 53 } 54 String getDottedNamePrefix() 55 { 56 57 if(_prefix==null) 58 throw new RuntimeException ("Prefix is not set by children class"); 59 return _prefix; 60 } 61 62 String extractPrefixedValueName(String dottedName) 63 { 64 return extractPrefixedValueName(dottedName, false); 65 } 66 67 String extractPrefixedValueName(String dottedName, boolean bIncludingPrefix) 68 { 69 int lastIdx = dottedName.lastIndexOf("."+getDottedNamePrefix()); 70 lastIdx++; 71 if(lastIdx<1) 72 { 73 if(dottedName.startsWith(getDottedNamePrefix())) 74 lastIdx = 0; 75 else 76 return null; 77 } 78 if(bIncludingPrefix) 79 return dottedName.substring(lastIdx); 80 else 81 return dottedName.substring(lastIdx+getDottedNamePrefix().length()); 82 } 83 84 boolean isDottedNameForAccessor(String dottedName) 85 { 86 return (extractPrefixedValueName(dottedName)!=null); 87 } 88 } 89 90 91 | Popular Tags |