@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,7 +72,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean
|
||||
* @param methodNames an array of method names indicating the methods to use
|
||||
* @see #setMethodMappings
|
||||
*/
|
||||
public void setManagedMethods(String[] methodNames) {
|
||||
public void setManagedMethods(String... methodNames) {
|
||||
this.managedMethods = new HashSet<String>(Arrays.asList(methodNames));
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean
|
||||
*/
|
||||
public void setMethodMappings(Properties mappings) {
|
||||
this.methodMappings = new HashMap<String, Set<String>>();
|
||||
for (Enumeration en = mappings.keys(); en.hasMoreElements();) {
|
||||
for (Enumeration<?> en = mappings.keys(); en.hasMoreElements();) {
|
||||
String beanKey = (String) en.nextElement();
|
||||
String[] methodNames = StringUtils.commaDelimitedListToStringArray(mappings.getProperty(beanKey));
|
||||
this.methodMappings.put(beanKey, new HashSet<String>(Arrays.asList(methodNames)));
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.jmx.export.assembler;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.modelmbean.ModelMBeanAttributeInfo;
|
||||
import javax.management.modelmbean.ModelMBeanInfo;
|
||||
@@ -34,6 +33,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss
|
||||
|
||||
protected static final String OBJECT_NAME = "bean:name=testBean4";
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetAgeIsReadOnly() throws Exception {
|
||||
ModelMBeanInfo info = getMBeanInfoFromAssembler();
|
||||
@@ -47,7 +47,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss
|
||||
public void testWithFallThrough() throws Exception {
|
||||
MethodNameBasedMBeanInfoAssembler assembler =
|
||||
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
|
||||
assembler.setManagedMethods(new String[]{"getNickName", "setNickName"});
|
||||
assembler.setManagedMethods("getNickName", "setNickName");
|
||||
|
||||
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
|
||||
MBeanAttributeInfo attr = inf.getAttribute("NickName");
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.jmx.export.assembler;
|
||||
@@ -33,6 +33,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler
|
||||
|
||||
protected static final String OBJECT_NAME = "bean:name=testBean5";
|
||||
|
||||
|
||||
@Override
|
||||
protected String getObjectName() {
|
||||
return OBJECT_NAME;
|
||||
@@ -51,7 +52,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler
|
||||
@Override
|
||||
protected MBeanInfoAssembler getAssembler() {
|
||||
MethodNameBasedMBeanInfoAssembler assembler = new MethodNameBasedMBeanInfoAssembler();
|
||||
assembler.setManagedMethods(new String[] {"add", "myOperation", "getName", "setName", "getAge"});
|
||||
assembler.setManagedMethods("add", "myOperation", "getName", "setName", "getAge");
|
||||
return assembler;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user