| ||||||||||||||||||||||||||||||
Resin 3.1 Documentation Examples Changes Quercus Database Amber EJB SOA/ESB IoC JMS Servlet JMX Hessian Security Basic Listener Registration MBeanServer |
Resources can be JMX managed by exposing a management interface and registering as an MBean. Files in this tutorial
JMX ResourceAny resource in Resin can be managed by JMX by implementing an MBean interface and by specifying an MBean name. The interface exposes the resource's methods to be managed. The Basic resourceThe package example; public class Basic implements BasicMBean { private String _data = "default"; public void setData(String data) { _data = data; } public String getData() { return _data; } }
package example; public interface BasicMBean { public void setData(String data); public String getData(); } MBean namesMBeans are stored in the MBean server using
an The mbean name consists of a set of <name,value> properties and a "domain" used like a namespace. The properties allow for querying related mbeans. For example, you could request for all mbeans with "J2EEType=Servlet", which would return all the managed servlets. The example uses the name "example:name=basic". "example" is the domain and the bean's single property is "name" with a value of "basic". By convention, an mbean would normally also have a "type" property, but this example is using a name as simple as possible. web.xml configurationThe web.xml (or resin.conf) configures the resource with the <resource> tag just as with other resources. The resources is registered as an MBean by specifying an . <web-app xmlns="http://caucho.com/ns/resin"> <resource mbean-name="example:name=basic" type="example.Basic"> <init> <data>An Example Resource</data> </init> </resource> </web-app>
Using the resource proxyResin's JMX implementation provides a proxy to managed object using the interface for an API. You can, of course, use the standard JMX interface, the proxy interface is much easier to use. <%@ page import='com.caucho.jmx.Jmx, example.BasicMBean' %> <% BasicMBean basic = (BasicMBean) Jmx.find("example:name=basic"); out.println("data: " + basic.getData()); %> data: An example resource CompatibilityThe resource's code is completely compatible with other JMX implementations. The proxy interface, however, is unique to Resin. If you choose, you can use the JMX API to access the resource. The configuration, of course, is Resin-dependent.
|