-
Feb 6th, 2010, 07:20 PM
#1
Manually added beans in exporter work fine, but not autodetection
Using Spring 2.5.6.
On the first try, I was able to define a bean, put it in the simple-minded exporter, and then jconsole was able to see the operations.
I then wanted to add more information, as I didn't get nice parameter naming, and I thought that adding autodetection would be useful. Unfortunately, it doesn't appear to be autodetecting the bean.
The relevant context excerpt is this:
--------------------------
<bean id="logManager" class="com.att.ecom.dynamiccontent.Log4JManager"/>
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r">
<property name="assembler" ref="assembler"/>
<property name="autodetect" value="true"/>
</bean>
<!-- (for Java 5+ annotations-based metadata) -->
<bean id="attributeSource" class="org.springframework.jmx.export.annotation.A nnotationJmxAttributeSource"/>
<bean id="assembler" class="org.springframework.jmx.export.assembler.Me tadataMBeanInfoAssembler">
<property name="attributeSource" ref="attributeSource"/>
</bean>
------------------
The Log4jManager class is this:
-----------------
@ManagedResource(objectName = "bean:name=logBean", description = "Bean for controlling Log4J levels in DynamicContent")
public class Log4JManager {
@ManagedOperation(description = "Set a Log4J logging level for a specific category (package)")
@ManagedOperationParameters({
@ManagedOperationParameter(name = "packageName", description = "Log4J category name"),
@ManagedOperationParameter(name = "level", description = "Log4J level")
})
public void setLogLevel(String packageName, String level) {
LogManager.getLogger(packageName).setLevel(Level.t oLevel(level));
}
@ManagedOperation(description = "Get a Log4J logging level for a specific category (package)")
@ManagedOperationParameters({
@ManagedOperationParameter(name = "packageName", description = "Log4J category name")
})
public String getLogLevel(String packageName) {
return LogManager.getLogger(packageName).getLevel().toStr ing();
}
}
----------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules