1 16 17 package org.springframework.jmx.export.assembler; 18 19 import java.lang.reflect.Method ; 20 import java.util.Arrays ; 21 import java.util.Enumeration ; 22 import java.util.HashMap ; 23 import java.util.HashSet ; 24 import java.util.Map ; 25 import java.util.Properties ; 26 import java.util.Set ; 27 28 import org.springframework.util.StringUtils; 29 30 58 public class MethodExclusionMBeanInfoAssembler extends AbstractConfigurableMBeanInfoAssembler { 59 60 private Set ignoredMethods; 61 62 private Map ignoredMethodMappings; 63 64 65 71 public void setIgnoredMethods(String [] ignoredMethodNames) { 72 this.ignoredMethods = new HashSet (Arrays.asList(ignoredMethodNames)); 73 } 74 75 82 public void setIgnoredMethodMappings(Properties mappings) { 83 this.ignoredMethodMappings = new HashMap (); 84 for (Enumeration en = mappings.keys(); en.hasMoreElements();) { 85 String beanKey = (String ) en.nextElement(); 86 String [] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey)); 87 this.ignoredMethodMappings.put(beanKey, new HashSet (Arrays.asList(methodNames))); 88 } 89 } 90 91 92 protected boolean includeReadAttribute(Method method, String beanKey) { 93 return isNotIgnored(method, beanKey); 94 } 95 96 protected boolean includeWriteAttribute(Method method, String beanKey) { 97 return isNotIgnored(method, beanKey); 98 } 99 100 protected boolean includeOperation(Method method, String beanKey) { 101 return isNotIgnored(method, beanKey); 102 } 103 104 111 protected boolean isNotIgnored(Method method, String beanKey) { 112 if (this.ignoredMethodMappings != null) { 113 Set methodNames = (Set ) this.ignoredMethodMappings.get(beanKey); 114 if (methodNames != null) { 115 return !methodNames.contains(method.getName()); 116 } 117 } 118 if (this.ignoredMethods != null) { 119 return !this.ignoredMethods.contains(method.getName()); 120 } 121 return true; 122 } 123 124 } 125 | Popular Tags |