?? jmx.xtp
字號:
<s1 title="JMX: Management Extensions"><summarylist/><s2 title="Instrumenting Resources"><p>Instrumenting resources so JMX can manage them consistsof the following steps:</p><ol><li>For a class <code/MyFoo/>, create an interface <code/MyFooMBean/> withthe management interface.<li>Class <code/MyFoo/> needs to <var/implement/> the <code/MyFooMBean/> interface.<li>Register <code/MyFoo/> with the JMX server.</ol><s3 title="Instrumenting a servlet"><p>Resin will automatically register any servlet whichimplement an MBean interface. By default, the JMX name will be:</p><def>web-app:j2eeType=Servlet,name=<var/servlet-name/></def><deftable title="ObjectName attributes"><tr><th>Attribute<th>Value<tr><td>j2eeType<td>Servlet<tr><td>WebModule<td>the <var/contextPath/><tr><td>J2EEApplication<td>the host?<tr><td>J2EEServer<td>the server-id?</deftable><p>The domain is <var/web-app/>, the type propertyis javax.servlet.Servlet and the name property is the valueof <servlet-name>.</p><p>JMX clients will use the name to manage the servlet. For example,a client might use the pattern <var/web-app:type=javax.servlet.Servlet,*/>to retrieve all managed servlets.</p><example title="MyServletMBean.java">package test;public interface MyServletMBean { public int getCount();}</example><example title="MyServlet.java">package test;import java.io.*;import javax.servlet.*;public class MyServlet extends GenericServlet implements MyServletMBean { private int count; public int getCount() { return count; } public void service(ServletRequest request, ServletResponse response) throws IOException { PrintWriter out = response.getWriter(); count++; out.println("Hello, world"); }}</example></s3></s2><s2 title="Managing Resources"><p>Managing resources uses the JMX API, primarily usingthe <code/MBeanServer/> object. In Resin, each web-app hasits own <code/MBeanServer/>.</p><example title="Getting the Count attribute">import javax.management.*;...MBeanServer server = MBeanServerFactory.createMBeanServer();ObjectName name = new ObjectName("web-app:j2eeType=javax.servlet.Servlet," + "name=hello");Object value = server.getAttribute(name, "Count");out.println("Count: " + value);</example><s3 title="/resin-status"><p>The <a href="servlet-library.xtp">resin-status servlet</a> has aprimitive generic JMX management view of JMX managed servlets.By adding a MBean interface to your servlet, you'll automatically geta view of your servlets from /resin-status.</p></s3></s2></s1>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -