Example using HtmlContent

95 views
Skip to first unread message

markds75

unread,
Dec 8, 2011, 3:17:00 PM12/8/11
to jminix-users
I got a bit confused as to how to use the HtmlContent interface in my
project. Laurent kindly put me on the right path, and I thought I'd
share an example here in case others have the same problem.

In the following code, the getTestBean() method returns an instance of
a public inner class that implements HtmlContent. In the Jminix Mini
Console, clicking on the TestBean attribute will render the results of
the toString() as HTML. Note that the method uses the
@ManagedAttribute annotation; as I understand it, HTML rendering is
not currently supported for @ManagedOperations in Jminix 1.0.0.

Hopefully this example will save someone a bit of time.

Mark

import org.jminix.type.HtmlContent;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;

@ManagedResource(objectName="mds:name=TestJMXMonitor")
public class TestJMXMonitor implements HtmlContent {
@ManagedAttribute(description = "Some ID.")
public Integer getID() {
return 555;
}

@ManagedAttribute(description = "Test Operation.")
public TestBean getTestBean() {
return new TestBean();
}

public class TestBean implements HtmlContent {
public String toString() {
return "<p>paragraph 1</p><p><b>bolder</b> text</p>";
}
}
}

Reply all
Reply to author
Forward
0 new messages