Spring JMX
Spring에서 설정만으로 기본 객체를 MBean으로 등록해 JMX클라이언트가 호출할 수 있게 한다.
@ManagedAttribute와 @ManagedOperation 차이는 getter/setter로 처리할 수 있는 속성은 @ManagedAttribute로 어노테이션하고, 그외 getter/setter가 아닌 메소드호출을 위해서는 @ManagedOperation으로 어노테이션한다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" | |
lazy-init="false"> | |
<property name="autodetect" value="true" /> | |
<property name="namingStrategy" ref="namingStrategy" /> | |
<property name="assembler" ref="assembler" /> | |
</bean> | |
<bean id="attributeSource" | |
class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" /> | |
<bean id="assembler" | |
class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler"> | |
<property name="attributeSource" ref="attributeSource" /> | |
</bean> | |
<bean id="namingStrategy" | |
class="org.springframework.jmx.export.naming.MetadataNamingStrategy"> | |
<property name="attributeSource" ref="attributeSource" /> | |
</bean> | |
<bean id="testBean" class="jmxtest.TestBean" /> |
@ManagedAttribute와 @ManagedOperation 차이는 getter/setter로 처리할 수 있는 속성은 @ManagedAttribute로 어노테이션하고, 그외 getter/setter가 아닌 메소드호출을 위해서는 @ManagedOperation으로 어노테이션한다.
@ManagedOperation
JDK 1.5+ method-level annotation that indicates to expose a given method as JMX operation, corresponding to the ManagedOperation attribute. Only valid when used on a method that is not a JavaBean getter or setter.
@ManagedAttribute
JDK 1.5+ method-level annotation that indicates to expose a given bean property as JMX attribute, corresponding to the ManagedAttribute attribute. Only valid when used on a JavaBean getter or setter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jmxtest; | |
import org.springframework.jmx.export.annotation.ManagedAttribute; | |
import org.springframework.jmx.export.annotation.ManagedOperation; | |
import org.springframework.jmx.export.annotation.ManagedResource; | |
@ManagedResource(objectName="testBean:name=testBean", | |
description="getter/setter는 attribute, 그외 메소드는 operation") | |
public class TestBean { | |
String logLevel; | |
@ManagedAttribute(defaultValue="love") | |
public String getLogLevel() { | |
return logLevel; | |
} | |
@ManagedOperation() | |
public void printf() { | |
System.out.println("hihi"); | |
} | |
@ManagedAttribute(defaultValue="love", description="sss") | |
public void setLogLevel(String logLevel) { | |
this.logLevel = logLevel; | |
} | |
} |
댓글
댓글 쓰기